OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: Garcia on 13 Sep 2006, 15:30:34
-
I've got a script that I have to initalize from the init.sqs for all units that are playable, but I don't want the script to be executed for the units who is disabled. Now, I know it works to add
? (Unitname != ObjNull) : infront of the execution line, however, since this is for a addon, I want to add that line in the script that is executed from the init.sqs...
i.e, u1, u2, u3 and u4 are playable units. In the init.sqs I have something like this:
[u1] exec "script.sqs"
[u2] exec "script.sqs"
[u3] exec "script.sqs"
[u4] exec "script.sqs"
and then in script.sqs I have some check which exits the script if _this select 0 is not present. So if u1, u2 and u3 are present, then the script runs for them, but not for u4, since he was disabled before the mission started.
-
I'm not quite sure what you mean, but try this:
name the units e.g. u1 u2 u3 u4 for west and for east r1 r2 r3 r4
then make a trigger for each unit
size: 0/0
activation: none
text: Scriptr1
condition: local r1
onActivation: r1 exec "script.sqs"; (where it says r1 you put your units name...)
I'm not 100% sure of that, but it should work like that... :)
-
Name each unit like you did it already
;init.sqs
units_array = []
"if alive _x then {units_array = units_array + [_x]" forEach [u1,u2,u3,u4,r1,r2,r3,r4]
What it does?
It initializes an array (units_array) and then puts each alive unit of given units
inside the brackets into the array.
At the end units_array would look like this: [u1,u2,u3,u4,r1,r2,r3,r4]
if all of these units were choosen and/or enabled.
If one of the units doesn't exist, it will not be inside
units_array.
whatever you want to with the units later, you can do it - forEach units_array
@tommi
When opening this thread i would have expected a similar anwer of you, especially because
i spent one and a half week of showing you this method (remember the init.sqs of your money script problem).
:edit - btw - there's another variant, using the same technique but executing the script straight without putting
them into an array;
"if alive _x then {[_x] exec {script.sqs}}" forEach [u1,u2,u3,u4,r1,r2,r3,r4]
~S~ CD
-
@ CD
I'm too tired to think ::) so I put the system what BIS used on Real Paint Ball