Checking if a player is near ANY vehicle.
#7

Quote:
Originally Posted by milanosie
View Post
Untested, modify it to your liking to return 0 if dis > 10


pawn Code:
public GetClosestVehicleFromPlayer(playerid)
{
    new Float:dis = 99999999.0;
    new veh = -1;
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    for(new i = 1; i < MAX_VEHICLES; i++)
    {
        new Float:distance = GetVehicleDistanceFromPoint(i, x, y, z);
        if(distance < dis)
        {
            dis = distance;
            veh = i;
        }
    }
    return veh;
}
Thank you, I'll edit it now :3
Reply


Messages In This Thread
Checking if a player is near ANY vehicle. - by vIBIENNYx - 21.09.2012, 17:29
Re: Checking if a player is near ANY vehicle. - by C00K13M0N$73R - 21.09.2012, 17:35
Re: Checking if a player is near ANY vehicle. - by vIBIENNYx - 21.09.2012, 17:38
Re: Checking if a player is near ANY vehicle. - by Danyal - 21.09.2012, 17:40
Re: Checking if a player is near ANY vehicle. - by vIBIENNYx - 21.09.2012, 17:45
Re: Checking if a player is near ANY vehicle. - by milanosie - 21.09.2012, 17:48
Re: Checking if a player is near ANY vehicle. - by vIBIENNYx - 21.09.2012, 17:50

Forum Jump:


Users browsing this thread: 1 Guest(s)