Home   Help Search Login Register  

Author Topic: How to get array of vehicles  (Read 635 times)

0 Members and 1 Guest are viewing this topic.

Iva

  • Guest
How to get array of vehicles
« on: 20 Sep 2004, 13:45:07 »
Is there some way to get array of all air or land vehicles?

Something like:

_Array = count allvehicles

 ;)

all i need is to get an array of all aircrafts curently on gorund and air  :)

Kammak

  • Guest
Re:How to get array of vehicles
« Reply #1 on: 20 Sep 2004, 18:08:03 »
Add a trigger, type All Present, Repeatedly, with a radius covering the area where your units will be.  Name the trigger, for example "triggerAll"

You can these access it through script as "list triggerAll", which will return an array of all units in the trigger radius.

To count airplanes, use

   planeCount="Plane" countType (list triggerAll)
or
   heloCount="Helicopter" countType (list triggerAll)
or
   airCount="Air" countType (list triggerAll)
for both.

"planeCount", "heloCount", "airCount" are just variable names I made up for the example, you can use any name.

Kammak

  • Guest
Re:How to get array of vehicles
« Reply #2 on: 20 Sep 2004, 18:16:15 »
To build an array from that (just realized I didn't answer your question :) ) do the following:

arrPlanes=[]
if ("Plane" countType [_x]==1) then {arrPlanes=arrPlanes+[_x]} foreach (list triggerAll)

arrPlanes will then be an array of all aircraft within the trigger area.

Iva

  • Guest
Re:How to get array of vehicles
« Reply #3 on: 22 Sep 2004, 12:48:36 »
Ok.... this is nice
But i need some way to do it whitout triggers!
This script will be in addon... not in mission  :-\

Unnamed

  • Guest
Re:How to get array of vehicles
« Reply #4 on: 22 Sep 2004, 13:37:07 »
Unless your going to be using it with your own aircraft addons, you will probably have to ask the mission editor to include one of your functions in every init field, of all the aircraft they place. The function would have code pretty much similar to Kammak's sugegstion. You just need to create the array from the init event of your addon.

Another alternative is to create your own configs that inherit from all the aircraft you want to use and add the function call to there init events.

Or just ask the mission designer to place the appropriate trigger in the editor, same way they would for the Server game logic.

But an automatic list of all the current units, would have been a nice feature for missions and addon designers.