14.07.2016, 16:25
PHP код:
native IsValidVehicle(vehicleid);
GetClosestVehicle(playerid, Float:range) {
new Float:VehiclePos[4], nearestID;
nearestID = 65535;
for(new vehicleid = 0; vehicleid < MAX_VEHICLES; vehicleid++) {
if(IsValidVehicle(vehicleid)) {
GetVehiclePos(vehicleid, VehiclePos[1], VehiclePos[2], VehiclePos[3]);
if(IsPlayerInRangeOfPoint(playerid, range, VehiclePos[1], VehiclePos[2], VehiclePos[3])) {
nearestID = vehicleid;
break;
}
}
}
return nearestID;
}