09.11.2012, 18:40
Good day everyone. I have a problem with this function, why does it returns 0 always?
pawn Код:
stock GetClosestVehicle(playerid)
{
new
Float: finalDistance = 5.0,
Float: userPos[3],
Float: Distance,
Closest = INVALID_VEHICLE_ID
;
GetPlayerPos(playerid, userPos[0], userPos[1], userPos[2]);
for (new i; i != MAX_VEHICLES; ++i)
{
if ((Distance = GetVehicleDistanceFromPoint(i, userPos[0], userPos[1], userPos[2])) < finalDistance)
{
finalDistance = Distance;
Closest = i;
}
}
printf("Closest: %d", Closest);
return Closest;
}