Home   Help Search Login Register  

Author Topic: smallest number  (Read 510 times)

0 Members and 1 Guest are viewing this topic.

j-man

  • Guest
smallest number
« 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 ???

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:smallest number
« Reply #1 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
« Last Edit: 31 Jan 2005, 03:14:11 by Triggerhappy »

Offline Fragorl

  • Coding Team
  • Former Staff
  • ****
Re:smallest number
« Reply #2 on: 31 Jan 2005, 00:56:24 »
dont forget ur
i = i + 1
 :D !

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:smallest number
« Reply #3 on: 31 Jan 2005, 03:13:44 »
oops, my bad.
I'll fix that right now...