Home   Help Search Login Register  

Author Topic: Substract vehicles from array once down  (Read 1518 times)

0 Members and 1 Guest are viewing this topic.

Offline Seven

  • Members
  • *
  • Am I a llama?
Substract vehicles from array once down
« 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

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re: Substract vehicles from array once down
« Reply #1 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
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

Offline Seven

  • Members
  • *
  • Am I a llama?
Re: Substract vehicles from array once down
« Reply #2 on: 22 Sep 2006, 17:50:32 »
Again sweet & muchos thx Chris! 
fits my needs perfectly :)