Quote:
Originally Posted by Jefff
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; }
|
Many, many thanks for this, but how exactly am I to use this within the script?
Just like so?
pawn Код:
if (IsAValidVehicle(vehicleid))