22.06.2013, 17:59
Use this:
pawn Код:
stock GetClosestVehicle(playerid)
{
new
Float:fPos[3],
Float:distance = 30,
Float:curdistance,
currentVehicle;
for(new v = 0; v < MAX_VEHICLES; v++)
{
GetVehiclePos(v, fPos[0], fPos[1], fPos[2]);
curdistance = GetPlayerDistanceFromPoint(playerid, fPos[0], fPos[1], fPos[2]);
if(curdistance < distance)
{
currentVehicle = v;
distance = curdistance;
}
}
return currentVehicle;
}