Home   Help Search Login Register  

Author Topic: Checking if an object type in an array is near  (Read 982 times)

0 Members and 1 Guest are viewing this topic.

Offline JasonO

  • OFPEC Patron
  • ****
  • Oh no...
    • The New Life RPG
Checking if an object type in an array is near
« on: 16 May 2007, 19:52:08 »
Hey

I have a part of a mission where I must approach a few vehicles, and I need to check the vehicle's type from an array (well it's all land vehicles like cars, trucks and tanks etc) and if i'm at a certain distance I can continue.

Is there an easy way to check if the vehicle is a land vehicle without having each type in an array? If not then I'll just write an array myself. But after that how would I do a simple check to see if a vehicle of a type in that array is within say 25 meters.

Thanks for your help :)

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Checking if an object type in an array is near
« Reply #1 on: 16 May 2007, 21:17:21 »
Code: [Select]
myCar isKindOf "LandVehicle"
You will need an array with all the other vehicles in it to use this:
Code: [Select]
({(myCar distance _x) < dist} count vehicleArray) > 0
You can make the vehicleArray in your init.sqf or you can place a trigger that covers all the vehicles in question, set it to side present once. In the On Activation:
Code: [Select]
vehicleArray = [] ; {if (_x isKindOf "LandVehicle") then {vehicleArray = vehicleArray + [_x]}} forEach thislist ; if (myCar in vehicleArray) then {vehicleArray = vehicleArray - [myCar]}
« Last Edit: 16 May 2007, 21:28:33 by Mr.Peanut »
urp!