Én ezt a kódot használom. Valahol fentvan itt a fórumon a topik amiböl kiszdtem
stock GetVehicleWithinDistance(playerid, &Float:dist = 0.0)
{
new Float:temp_distance = Float:0x7F800000, Float:distance = 0.0, temp_vehicle = INVALID_VEHICLE_ID, Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
for(new vehicleid = 1; vehicleid <= MAX_VEHICLES; vehicleid++)
{
if(IsValidVehicle(vehicleid))
{
distance = GetVehicleDistanceFromPoint(vehicleid, x, y, z);
if(temp_distance > distance)
{
temp_distance = distance;
temp_vehicle = vehicleid;
}
}
}
dist = temp_distance;
return temp_vehicle; // return legközelebb lévo jármu azonosítószáma (vehicleid)
}