Closest vehicle to player
#2

pawn Код:
new Float:dist = FLOAT_INFINITY, Float:tempdist, closest = -1, Float:x, Float:y, Float:z;
        for(new i=0; i<MAX_VEHICLES; i++)
        {
            if(IsVehicleStreamedIn(i, playerid))
            {
                GetVehiclePos(i, x, y, z);
                tempdist = GetVehicleDistanceFromPoint(GetPlayerVehicleID(playerid), x, y, z);
                if(tempdist > dist) continue;
                closest = i;
                dist = GetVehicleDistanceFromPoint(GetPlayerVehicleID(playerid), x, y, z);
            }
        }
        if(closest == -1) return SendErrorMessage(playerid, "No vehicles nearby to attach. Use /TOW [VEHICLE ID] to attach a specific trailer to your vehicle.");
This is a part of my script, it is NOT a copy and paste job. Look at it, edit it and learn. You may need to define FLOAT_INFINITY.
Reply


Messages In This Thread
Closest vehicle to player - by Sphex - 30.04.2012, 19:38
Re: Closest vehicle to player - by MP2 - 30.04.2012, 19:42
Re: Closest vehicle to player - by Sphex - 30.04.2012, 19:47
Re: Closest vehicle to player - by Joe Staff - 30.04.2012, 19:55
Re: Closest vehicle to player - by MP2 - 30.04.2012, 22:04

Forum Jump:


Users browsing this thread: 2 Guest(s)