Jump to content
Sign in to follow this  
whiztler

WaitUntil {trueVar}

Recommended Posts

Below case is a script that runs at the beginning of a mission:

if (!isServer) exitWith {};
trueVar = false;
waitUntil {trueVar};

After 1+ hour into the mission:

trueVar = true;
publicVariableServer "trueVar";

When the trueVar init is broadcasted to the server, the server will be dealing with lots of AI's, combat, etc. FPS drops but no lower than 17.

Is it possible that due to server lag or the fact that the game is already been at it for over an hour that the waitUntil {tueVar}; is no longer working? Anyone experienced this before?

Edited by whiztler

Share this post


Link to post
Share on other sites

Not sure if its a typo but do you notice the spelling mistake?

waitUntil {tueVar};

waitUntil {trueVar};

Share this post


Link to post
Share on other sites

Thanks, the snippet is just an example. fixed

Share this post


Link to post
Share on other sites

There used to be a max threshold of 10,000 iterations in a loop, I am not sure if it's still in nor if waitUntil is affected by it.

If it's one hour away you might want to add a sleep or it's checked every frame.

waitUntil{sleep 5; trueVar};

Share this post


Link to post
Share on other sites

You could also use a publicVariableEventhandler instead.

Share this post


Link to post
Share on other sites
There used to be a max threshold of 10,000 iterations in a loop, I am not sure if it's still in nor if waitUntil is affected by it.

If it's one hour away you might want to add a sleep or it's checked every frame.

waitUntil{sleep 5; trueVar};

Not entirely correct.

Loops, are only limited to 10k iterations within a Non-Schedule Environment, for example, code running within a event handler.

Also, see Threads for more information about the Scheduled / Non-Scheduled Environment.

Also, waitUntil does not run every frame, because it is also caught within the Scheduled Environment.

Going back to initial question, it should still work, should not be dependent on time after mission start. Although, what you are trying to achive, should be done though a public variable event handler.

/** Server */

// Some variable
TAG_myVariable = false;

// The public variable event handler, that will execute, everytime defined variable is modified over the network
"TAG_myVariable" addPublicVariableEventHandler {
  // Log the variable name and it's new value
  ["Variable (%1) has changed and is now (%2)", _this select 0, _this select 1] call BIS_fnc_logFormat;
};

/** Client */

// Set a new value to the variable we added a event handler to
TAG_myVariable = true;

// Broadcast value over to the server, causing the event handler to execute and log the name and new value of the variable
publicVariableServer "TAG_myVariable";

Share this post


Link to post
Share on other sites

Thanks guys. Always keen to learn new things about scripting for Arma.

Edited by whiztler

Share this post


Link to post
Share on other sites

Also, waitUntil does not run every frame, because it is also caught within the Scheduled Environment.

Yes. Someone ought to change the wiki.

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  

×