22.01.2013, 21:03
pawn Код:
stock GetClosestVehicleForPlayer(playerid)
{
new
Float:Pos[4],
Float:DefaultDistance = 999999999.9,
ClosestVehicleID = INVALID_VEHICLE_ID;
GetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]);
for(new vehicleid = 1; vehicleid != MAX_VEHICLES; vehicleid++)
if(IsValidVehicle(vehicleid))
{
Pos[3] = GetVehicleDistanceFromPoint(vehicleid,Pos[0],Pos[1],Pos[2]);
if(Pos[3] < DefaultDistance)
{
DefaultDistance = Pos[3];
ClosestVehicleID = vehicleid;
}
}
return ClosestVehicleID;
}