23.08.2012, 21:55
I have trying to figoure out, how this works for few hour now with my friend lol. And still not 100% sure, what does this 'Distance' part should do.. could someone explain me? lol
pawn Код:
stock GetNearestVehicle(playerid, Float:distance)
{
new
Float:xX,
Float:yY,
Float:zZ,
retElement = -1
;
for(new i = 0; i < MAX_VEHICLES; i++)
{
GetVehiclePos(i, xX, yY, zZ);
new Float:odist = GetPlayerDistanceFromPoint(playerid, xX, yY, zZ);
if (retElement == -1)
{
retElement = i;
distance = odist;
}
else if (odist < distance)
{
retElement = i;
distance = odist;
}
}
return retElement;
}