Jump to content

Recommended Posts

Hi folks

 

I have two unitPlay scripts in my mission, and currently make them work separately using radio triggers. Radio Alpha for heli1, Radio Bravo for heli2 etc. Each trigger has this in the init: 

 

Radio Alpha: nul = [] execVM "heli1.sqf"

Radio Bravo: nul = [] execVM "heli2.sqf"

 

 

I would like to call both heli scripts using just one trigger. I tried this in the init of a trigger, but it didn't really work:

 

nul = [] execVM "heli1.sqf"; nul = [] execVM "heli2.sqf";

 

... it only triggered one of the scripts. 

 

 

Is there an easy way to do this? I find unitCapture / unitPlay to be a bit quirky sometimes, so though there might be a known technique here. Do I need to write in a short delay between the two?

 

Cheers

RM

 

 

Share this post


Link to post
Share on other sites

I have no clue why both scripts are not executed but you could make the code better organized by functions. like this:

 

in init.sqf:

launchHelos =
{
 execVM "heli1.sqf";
 execVM "heli2.sqf";
};

 

then in trigger just call it like this:  

 

call launchHelos;

 

Share this post


Link to post
Share on other sites

@gc8 thank you mate, i was wondering about embedding them somewhere else, but didnt know how to do it. I will try that later tonight mate ... thank you again :)

KITD FOHS
 

___

 

Worked a treat - thank you!

Share this post


Link to post
Share on other sites

Sorry guys, one last question on this..

 

How would I build in a few second's delay between each script?

 

I am trying this, but no joy:

 

launchHelos =

 

{

 

 execVM "heli1.sqf";

 

 {sleep 5};

 

 execVM "heli2.sqf";

 

 {sleep 5};

 

 execVM "heli3.sqf";

 

};

 

Sorry for such a noob question..

 

 

____

 

Edit, so this works:

 

launchHelos =

 

{

 execVM "heli1.sqf";


 [] spawn {sleep 1; execVM "heli2.sqf"};


 [] spawn {sleep 2; execVM "heli3.sqf"};


};

 

Don't know if this is the best way, but it get me in business :)

Share this post


Link to post
Share on other sites
12 minutes ago, reggaeman007jah said:

launchHelos =

 

{

 

 execVM "heli1.sqf";

 

 {sleep 5};

 

 execVM "heli2.sqf";

 

 {sleep 5};

 

 execVM "heli3.sqf";

 

};

As always, it's a good idea to actually look at the commands you use (call) and find out how they work.

Call doesn't allows sleeps, spawn does. So the correct way would be:

launchHelos =
{
  execVM "heli1.sqf";
  sleep 5;
  execVM "heli2.sqf";
  sleep 5;
  execVM "heli3.sqf";
};

_nul = [] spawn launchHelos //from a trigger

Of course, saving this as a function seems pretty ridiculous, simple

_nul = [] spawn {
  execVM "heli1.sqf";
  sleep 5;
  execVM "heli2.sqf";
  sleep 5;
  execVM "heli3.sqf";
};

should work.

  • Like 2

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

×