19.04.2017, 18:17
Try this out:
PHP код:
#define LoopVehicles(%1) \
for(new %1 = GetVehiclePoolSize(); i != %1; %1--)
stock GetClosestVehicle(playerid, Float:range)
{
new Float: p_X, Float: p_Y, Float: p_Z, Float: Distance = 9999.9, Vehicle = INVALID_VEHICLE_ID, Float: Temp;
GetPlayerPos(playerid, p_X, p_Y, p_Z);
LoopVehicles(i)
{
Temp = GetVehicleDistanceFromPoint(i, p_X, p_Y, p_Z);
if(range <= Temp <= Distance) //if(Temp <= Distance && Temp <= range)
{
Vehicle = i;
Distance = Temp;
}
}
return Vehicle;
}