OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: j-man on 30 Jan 2005, 20:29:00
-
I'm trying to create a script that will pick a car from a list that is closest to the player and send it out. I've managed to get the distances between tha player and the cars, but I found no easy way of checking which distance is the smallest. Is there something i'm missing ???
-
something like this:
(_cars is your array of cars)
_i = 0
#loop
_car = _cars select _i
{?_car distance player < _x distance player} foreach (_cars - [_car]):_closest = _car;goto "next"
_i = _i + 1
goto "loop"
#next
code that will use that car
-
dont forget ur
i = i + 1
:D !
-
oops, my bad.
I'll fix that right now...