Jump to content
dlegion

waituntil with sleep technical question

Recommended Posts

hello! i got a huge doubt about waituntil and sleep...here is an example (while (true) its not relevant, i just put it to better give the idea of a looping code):

while {true} do {
       waitUntil {sleep 600;{alive _x} count allPlayers isEqualTo 0};  
}; 

this looping code will wait 600 seconds for 1 single time and then check in loop every 0.5 seconds the "alive players" condition?
OR
the looping code will wait 600 seconds, check the "alive players" condition, then wait 600 seconds, then check "alive players" condition and so on ?

if my ultimate goal is to check a condition every 600 seconds, what i should do ?
thanks guys!

 

Share this post


Link to post
Share on other sites

it checks every 600 seconds.
what do u wan't to do? that waitUntil looks not sensefull in this snippet but I guess u wannt to do some more things...

Share this post


Link to post
Share on other sites

thanks man !
nice i was hoping for this, but got that doubt due to a script working when it should have waited....but in fact its possible that it waited and for pure luck it checked condition exactly the few seconds when it was true!
the code its just an example...i'm optimizing all my scripts....already gained 10+fps on my mission! yeah !

Share this post


Link to post
Share on other sites

Why not test yourself?

private _n = 0;
while {true} do
{	waitUntil
	{	systemChat str (_n);
		_n=_n + 1;
		sleep 6;
		{alive _x} count allPlayers isEqualTo 0;
    }; 
}; 

 

  • Like 1

Share this post


Link to post
Share on other sites

niiceee!
didnt thinked about it, good idea !

Share this post


Link to post
Share on other sites

pushed by the wave of the holy optimization, i wish to know if there's a way to slow down also editor-placed triggers!
i tried with sleep, but dont seem to work!
thanks !

Share this post


Link to post
Share on other sites

What do I mean with slow down? I think they are checked every frame and u can't change that. The only option is to use "server only" option to hold it local to server or to script a local trigger if I need it for specific clients only

sent from mobile using Tapatalk

Share this post


Link to post
Share on other sites

ah...eh ok... i hoped in a simple solution like put a "sleep 10;" in condition...but seems way more complex :(
i dont know if i can remove that and script it, because its linked to sector, and others are squares and have to be rotated in a very precise way...will think about how do this, thanks !

Share this post


Link to post
Share on other sites
2 minutes ago, dlegion said:

ah...eh ok... i hoped in a simple solution like put a "sleep 10;" in condition...but seems way more complex :(
i dont know if i can remove that and script it, because its linked to sector, and others are squares and have to be rotated in a very precise way...will think about how do this, thanks !

 

I wouldn't worry too much about triggers, they are generally very performance friendly.

Share this post


Link to post
Share on other sites

Triggers are checked only twice a second so they're pretty light performance-wise. Unless of course they evaluate too heavy conditions.

Share this post


Link to post
Share on other sites
14 minutes ago, dlegion said:

pushed by the wave of the holy optimization, i wish to know if there's a way to slow down also editor-placed triggers!
i tried with sleep, but dont seem to work!
thanks !

What performance gain do you expect from that?

As long as your condition check fits inside the triggers condition field there's not much to worry about.

 

Get your stuff working first.

If it does what you want then you can start improving the performance, if needed at all.

 

Cheers

Share this post


Link to post
Share on other sites

its not too many of them...i think they are 10 or less, but there is really no hurry to check condistions....so i thinked about make them even more performance friendly :)
@Grumpy Old Man  ..yep you right, will probably be not noticeable, and afterall its more a theory than pratical...

Share this post


Link to post
Share on other sites

You can setup all that stuff for a scripted trigger as wel.
I usually place markers with the wanted size and heading in the editor an just get its settings in the script and setup the trigger with those settings. That way I don't need to copy those values manually...

sent from mobile using Tapatalk

Share this post


Link to post
Share on other sites

nice! interesting solution !!
i give it a try just for the sake of experimenting ! thanks !

Share this post


Link to post
Share on other sites

seems almost all problems can be solved...but how for the timeup timer ?
(i mean the trigger should activate its effects only if "ANY" stay on it for 10 seconds)
i didnt found a command for that !

ah sorry, my fault...reaading with more attention that :
https://community.bistudio.com/wiki/setTriggerTimeout
had solution in it!

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

×