Home   Help Search Login Register  

Author Topic: count vehicles in convoy  (Read 541 times)

0 Members and 1 Guest are viewing this topic.

Offline Blanco

  • Former Staff
  • ****
count vehicles in convoy
« on: 02 Nov 2004, 04:42:46 »
I need to know how I can count the vehicles in a convoy.
When I name one vehicle and count the units in the vehicles group, the total number isn't right, because gunners, commanders are counted too. (I think)

an example :

I make a convoy with two trucks and one M113.  
I name the M113 as "veh1"

Then somewhere in my script :

Quote
_c = count units group veh1

_c is 4, but I have only 3 vehicles...
What do I have to count to get total number of vehicles in the convoy?
Only the drivers?








« Last Edit: 02 Nov 2004, 04:44:32 by Blanco »
Search or search or search before you ask.

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:count vehicles in convoy
« Reply #1 on: 02 Nov 2004, 05:09:52 »
I'd use the "counttype" command instead.

"LandVehicle" counttype units group1 <= 0

You can replace "LandVehicle" with any classname, and the command will 'count' a unit if it is of that class, or any class that inherits from that class. You can look at the 'object class tree' (or whatever it is called) in the unofficial com ref to see the default BIS options, or else look at the config of whatever vehicle you are using.

I can give you more specific help if you want, too.
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline Blanco

  • Former Staff
  • ****
Re:count vehicles in convoy
« Reply #2 on: 02 Nov 2004, 05:38:34 »
I also need an array with the vehicles.
I tried this :

Code: [Select]
_veh = _this select 0
_grp = group _veh

_i = 0
_veharray = []

#findvehicles
_obj = units _grp select _i
?"LandVehicle" counttype [_obj] == 1 : _veharray = _veharray + [_obj]
~1
_i = _i + 1
?_i < count units _grp : goto "findvehicles"  

hint format ["%1",count _veharray]

it returns 0 in a group with two trucks and one M113.
When I change the type to "man" it returns 4
(two truck drivers, one M113 driver and 1 gunner)

"Land" returns 4 aswell
"APC" returns 0, should be 1
"Car" returns 0, should be 2

What am I doing wrong?
« Last Edit: 02 Nov 2004, 05:46:37 by Blanco »
Search or search or search before you ask.

Unnamed

  • Guest
Re:count vehicles in convoy
« Reply #3 on: 02 Nov 2004, 10:50:29 »
Try this:

Code: [Select]
{If !((Vehicle _x) In _veharray) Then {_veharray=_veharray+[Vehicle _x]}} Foreach (units _grp)
Then just count the array for the convoy size.

Offline Blanco

  • Former Staff
  • ****
Re:count vehicles in convoy
« Reply #4 on: 02 Nov 2004, 15:14:19 »
It was smart frum you to use the vehicle command here,That's a line to remember.

It returns 3 now
It works great, thx a lot

:thumbsup:

« Last Edit: 02 Nov 2004, 15:21:00 by Blanco »
Search or search or search before you ask.