Home   Help Search Login Register  

Author Topic: Kill Crew not Vehicle  (Read 1100 times)

0 Members and 1 Guest are viewing this topic.

Offline Odin

  • Members
  • *
Kill Crew not Vehicle
« on: 20 Jul 2008, 14:46:06 »
 :dunno: G'day I just cant seem to get this to work for me. I can kill a men using this
Code: [Select]
_seek = random 100
_xx = (getMarkerPos "gas" select 0)
_yy = (getMarkerPos "gas" select 1)

_veharray = [_xx,_yy,0] nearObjects ["Man", (25 + _seek)]
{_x setdammage ((getdammage _x) + 1)} forEach _veharray

But when I try to kill crew members of  Vehicles using this
Code: [Select]
_array1 = [_xx,_yy,0] nearObjects ["Vehicle", (100 + _seek)]
{_x setDammage 1} forEach (crew _array1);

I just get this error
Quote
'{_x setdamage 1} foreach (|#|(crew _array1);' error crew: Type Array, expected Object

Any Ideas?

Thx Odin

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Kill Crew not Vehicle
« Reply #1 on: 20 Jul 2008, 15:06:18 »
_array1 is a list of vehicles, not a vehicle itself. Thus, you need to iterate through it, then iterate through the crew using two separate forEach loops.
There isn't a class called "vehicle", instead use "AllVehicles" (which includes infantry). Remember also that men on foot have a single crewman (that is, themselves!).
Code: (kill all men, on foot or in vehicles) [Select]
_array1 = [_xx,_yy,0] nearObjects ["AllVehicles", (100 + _seek)]
{ { _x setDammage 1} forEach (crew _x) } forEach _array1;
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Odin

  • Members
  • *
Re: Kill Crew not Vehicle
« Reply #2 on: 21 Jul 2008, 13:13:22 »
Thanx again Spooner, that works great  :good:

Cheers
Odin