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

Can I run a script more than once ?

Recommended Posts

Example.... if I use this script and I need to add it say to 3 players can I call the script 3 times or do I need 3 of the same scripts Rescue1.sqf ,Rescue2.sqf and Rescue3.sqf ?

Rescue.sqf

_per = _this select 0;  // Person who had the addAction
_ldr = _this select 1;  // Person who used the addAction
_act = _this select 2;  // ID of the addAction

// Remove the rescue option
_per removeAction _act;
_per switchMove "AmovPercMstpSsurWnonDnon";
// Join the VIP to the group.  
[_per] joinSilent group _ldr;
_per EnableAI "MOVE";

Share this post


Link to post
Share on other sites

Since there are only local variables used*, you can run it 100 times for 100 different players. :)

*No reference to a specific unit i mean

btw:

switchMove has only local effect, so in multiplayer the animation won't be played for all clients at the same time.

and

enableAI has to be executed where the unit is local, looks like the server in this case. Unit is local after the joinSilent. Sorry.

You need some workarounds for those. :)

Edited by sxp2high

Share this post


Link to post
Share on other sites

thanks,

Just so i know if i have for example a Waituntill{_per} do something.

Could I still use it multiple times ?

Sorry just trying to understand scripts how they work and if I can utilise the same scripts

Share this post


Link to post
Share on other sites

Sure, why not. Scripts are running separate on each client (and the server) and per call ... and they do not store any data from the previous call. (except you make it so)

Each time you call them, they do the same thing.

waitUntil will wait until the condition is true on each client. (And the server)

But if you call the script 2 times (on the same client) before the waitUntil condition is true, it will wait 2 times... because, like i said, they run separate.

For example:

Lets say you have this inside somescript.sqf:

waitUntil {condition};
hint "hello world";

Now you call it 2 times and set the condition to true after it:

nul = execVM "somescript.sqf";
nul = execVM "somescript.sqf";
condition = false;

You will now get 2 hints. (At the same time of course)

Hope that helps. :)

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  

×