01.01.2016, 18:20
PHP код:
GetClosestVehicleForPlayer(playerid)
{
new vehicleid = INVALID_VEHICLE_ID;
new Float:distance = 5.0;
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
for(new i = 0; i < MAX_VEHICLES; i++)
{
if(!IsValidVehicle(i)) continue;
new Float: tmp = GetVehicleDistanceFromPoint(i, X, Y, Z);
if(tmp > distance) continue;
vehicleid = i;
distance = tmp;
}
if(vehicleid != INVALID_VEHICLE_ID) return vehicleid;
else return SendClientMessage(playerid,-1,"There are no vehicle near to you!");
}