OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: j-man on 30 Jan 2005, 20:29:00

Title: smallest number
Post 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 ???
Title: Re:smallest number
Post by: Triggerhappy on 30 Jan 2005, 20:52:26
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
Title: Re:smallest number
Post by: Fragorl on 31 Jan 2005, 00:56:24
dont forget ur
i = i + 1
 :D !
Title: Re:smallest number
Post by: Triggerhappy on 31 Jan 2005, 03:13:44
oops, my bad.
I'll fix that right now...