OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: Seven on 22 Sep 2006, 14:26:39

Title: Substract vehicles from array once down
Post by: Seven on 22 Sep 2006, 14:26:39
Hi I'm working on a MP CTF where I have an array of tanks for both sides; Once the count is equal to 0, I want to spawn 2 other tanks after some delay which will be added to the array so count should be back on 2, once 0 again the spawn will active again and so on.
My problem is I don't know how to substract the broken tanks from the array to do the count check;

So in brief:
what do I put in the condition field of my (repeating) trigger?
Code: [Select]
gtready && ....

What I have so far (this is only for resistance side):
init.sqs
Code: [Select]
gtanks = [gt1,gt2,gt3,gt4,gt5,gt6,gt7]
gtready = true

gtanks.sqs
Code: [Select]
!(local server):exit
gtready = false
_tank = "FDF_leopard2_w" createVehicle getMarkerPos "gtspawn"
_tank removemagazine "FDF_tankSmokeLauncher"
_tank removeweapon "FDF_tankSmokeLauncher"
_tank lock false
_tank setdir 180
gtanks = gtanks + [_tank]
~30
_tank1 = "FDF_bmd1" createVehicle getMarkerPos "gtspawn"
_tank1 removemagazine "FDF_tankSmokeLauncher"
_tank1 removeweapon "FDF_tankSmokeLauncher"
_tank1 lock false
_tank1 setdir 180
gtanks = gtanks + [_tank1]
~1
gtready = true
exit

Thank you for any input!  :)
Greetz
Title: Re: Substract vehicles from array once down
Post by: Chris Death on 22 Sep 2006, 15:31:46
You need to put the not broken tanks into a temporary array and then rebuild the original array
by the temporary array.

Just an example by using normal units:

original_array = [w1,w2,w3,w4]
temporary_array = []

"if (alive _x) then {temporary_array = temporary_array + [_x]}" forEach original_array

original_array = temporary_array
temporary_array = []

~S~ CD
Title: Re: Substract vehicles from array once down
Post by: Seven on 22 Sep 2006, 17:50:32
Again sweet & muchos thx Chris! 
fits my needs perfectly :)