Jump to content
Sign in to follow this  
1para{god-father}

Advice on running another .sqf from a .sqf

Recommended Posts

Trying to undestand why my code will not work after I run another .SQF does it simply stop and wait untill that code is completed then carry on the code ?

can i get round that ?

example.sqf


Some code i.e create markers etc...  all runs correct then i run another SQF as below that is a loop to check things 

null = [] execVM "checkloop.sqf"; 

HINT "THIS will never work ???"""


I never grt to see the hint , or any code below the null = [] execVM "checkloop.sqf";

Share this post


Link to post
Share on other sites

Is it really a loop that never returns a value? If so spawn it instead. Otherwise it's waiting for the checkloop.sqf to finish.

Share this post


Link to post
Share on other sites

Make sure to run Arma with -showScriptErrors, or check the error log. I suspect there is a bug in checkloop.sqf. execVM executes separately like spawn, so it should continue and show the hint, but may not if an error occurred. Also, you don't need a return variable there, you can remove "null =".

Share this post


Link to post
Share on other sites

Thanks, I am running it with showScriptErrors - and get no error at all.

Also looked at my .RPT and nothing these as well, well not to do with this.

so very confused, as it will not carry on after I start this script.

checkloop.sqf

mymissionmarkers is array of marker names

(this all works BTW)

private["_temvariable","_cv","_sc","_vardone","_vardone2","_objects","_marker","_eastside","_westside"];
missioncomp = 0;

while {missioncomp == 0} do {
_temvariable = [];
{if ((count (nearestObjects [(getmarkerpos _x),["MAN"],50])) > 0) then {_temvariable = _temvariable + [_x]};} foreach mymissionmarkers;
sleep 0.1;
_cv = count _temvariable;
if (_cv > 0) then
{
	_sc = 0;
	_vardone2 = 0;
	while {_vardone2 == 0} do {
		if (_sc < _cv) then
		{
			_marker = _temvariable select _sc;
			_objects = nearestObjects [(getmarkerpos _marker),["MAN"],50];
			_westside = [];
			_eastside = [];
			{if (side _x == WEST) then {_westside = _westside + [_x]};} foreach _objects;
			{if (side _x == EAST) then {_eastside = _eastside + [_x]};} foreach _objects;
			if ((count _westside) > (count _eastside)) then
			{
				_marker setMarkerColorLocal "ColorGreen";
				_marker setMarkerAlphaLocal 0.9; 
				} else {
				if (count _eastside > 0) then 
				{
					_marker setMarkerColorLocal mymarkercolour;
					_marker setMarkerAlphaLocal 0.9; 
				};
			};
			_sc = _sc + 1;
			} else {
			_vardone2 = 1;
		};
	};
};
sleep 0.1;
_temvariable = [];
{if ((getMarkerColor _x) == "ColorGreen") then {_temvariable = _temvariable + [_x]};} foreach mymissionmarkers;
_cv = count _temvariable;
if (_cv == (count mymissionmarkers)) then
{
	missioncomp = 1;
};
};
{deletemarker _x} foreach mymissionmarkers;
mymissionmarkers =[];


Share this post


Link to post
Share on other sites

The way I understand it, it'd be waiting for a return value from your checkloop.sqf.

Use spawn instead, there you go!

Share this post


Link to post
Share on other sites

If its an SQF from an SQF file I find that this works: [] execVM "checkloop.sqf";

without the null =

Outside of an SQF file such as a trigger ingame its a different story.

Edited by Rejenorst

Share this post


Link to post
Share on other sites

I ran the code you posted with a hint after the execVM, and the hint came up almost immediately. I also added a player sideChat inside the while loop of checkloop.sqf and it was continuously outputting to the screen. I also tried it with a marker assigned to mymissionmarkers and it seemed to work, so all I can say is that it looks like it should work. There is probably another factor involved that I can't think of :) Do you have hundreds of markers? Maybe it's just slow?

Share this post


Link to post
Share on other sites
I ran the code you posted with a hint after the execVM, and the hint came up almost immediately. I also added a player sideChat inside the while loop of checkloop.sqf and it was continuously outputting to the screen. I also tried it with a marker assigned to mymissionmarkers and it seemed to work, so all I can say is that it looks like it should work. There is probably another factor involved that I can't think of :) Do you have hundreds of markers? Maybe it's just slow?

OK it is working !

I forgot to try without null =

So it was waiting for a return value - thanks guys know I know !

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×