Jump to content
Sign in to follow this  
GuideZ

waitUntil with sleep or just sleep?

Recommended Posts

I have a bunch of units lined up, and have them firing on a radio trigger. I would like to do something like:

Unit1 fire "m16a4"; sleep 2.0; Unit2 fire "m16a4"; sleep 2.0;

But both units fire at almost exactly the same time when I preview the mission. Do I have to export the mission in order to get the sleep functionality, or am I missing something? I also tried something like:

Unit1 fire "m16a4"; waitUntil {sleep 2.0; Unit1 fire "m16a4"}; Unit2 fire "m16a4";

As it stands right now, I have 8 units firing on separate radio commands. A little annoying.

Here is what I want my final outcome to be: I setup 8 units in a line, 50 meters between each one. I want them to fire three shots each, with the next unit firing only when the previous unit fires first.

Share this post


Link to post
Share on other sites

this

null=[] spawn { Unit1 fire "m16a4"; sleep 2.0; Unit2 fire "m16a4"; sleep 2.0;}

or this where you can just add units to the array

null=[] spawn {{ _x fire "m16a4"; sleep 2.0;} foreach [uni1,unit2,unit3];}

Share this post


Link to post
Share on other sites

Omnigosh, I had to lookup "spawn" to see what it does. I would have never guessed :p , I will give that code a try.

Spawn

"Starts running a new script (SQF). Additional arguments are passed in local _this variable.

*edit*

For those wondering, here was the final output:

null=[] spawn {{ _x fire MWeap; sleep 2.0; _x fire MWeap; sleep 2.0; _x fire MWeap; sleep 3.0;} foreach [Fire1,Fire2,Fire3,Fire4,Fire5,Fire6,Fire7,Fire8];}

Edited by GuideZ

Share this post


Link to post
Share on other sites

Some script scopes don't allow use of sleep and will throw errors. If this is the case, then just wrap your code into spawn and it will work.

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  

×