10.04.2019, 03:43
PHP Code:
GetNearestVehicleFromPlayer(playerid, Float:distance = 30.0) {
new
Float:min_dist,
vehicleid = INVALID_VEHICLE_ID,
Float:x,
Float:y,
Float:z;
GetPlayerPos(playerid, x, y, z);
for (new i = (GetVehiclePoolSize() + 1); --i != 0;) {
if ((min_dist = GetVehicleDistanceFromPoint(i, x, y, z)) <= distance) {
vehicleid = i;
distance = min_dist;
}
}
return vehicleid;
}