29.06.2018, 18:56
I made func like that too you can try:
PHP код:
GetClosestVehicle(playerid)
{
new Float:vx, Float:vy, Float:vz, last_vehicle = -1, Float:last_distance = 99999;
for(new vi = 1, vj = GetVehiclePoolSize(); vi <= vj; vi++)
{
GetVehiclePos(vi, vx, vy, vz);
if(vi == INVALID_VEHICLE_ID || GetPlayerDistanceFromPoint(playerid, vx, vy, vz) > last_distance) continue;
last_vehicle = vi;
last_distance = GetPlayerDistanceFromPoint(playerid, vx, vy, vz);
}
return last_vehicle;
}