23.08.2012, 22:14
Look at the code, it shows you what it's suppose to do if it doesn't find a vehicle within 66 units.
It will just return the ID of the last vehicle looped through.
This will return -1 if there is no vehicle within 66 units.
It will just return the ID of the last vehicle looped through.
This will return -1 if there is no vehicle within 66 units.
Код:
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; } else if (odist > distance) { return -1; } } return retElement; }