Checking if a player is close to car.
#2

Try using:
pawn Код:
stock GetClosestVehicle(playerid, Float:dis)
{
    new Float:X, Float:Y, Float:Z;
    if(GetPlayerPos(playerid, X, Y, Z))
    {
        new vehicleid = INVALID_VEHICLE_ID;
        for(new v, Float:temp, Float:VX, Float:VY, Float:VZ; v != MAX_VEHICLES; v++)
        {
            if(GetVehiclePos(v, VX, VY, VZ))
            {
                VX -= X, VY -= Y, VZ -= Z;
                temp = VX * VX + VY * VY + VZ * VZ;
                if(temp < dis) dis = temp, vehicleid = v;
            }
        }
        dis = floatpower(dis, 0.5);
        return vehicleid;
    }
    return INVALID_VEHICLE_ID;
}
Adjust to suit your needs.
Reply


Messages In This Thread
Checking if a player is close to car. - by Supercop - 20.10.2011, 12:25
Re: Checking if a player is close to car. - by Stigg - 20.10.2011, 12:57
Re: Checking if a player is close to car. - by Supercop - 20.10.2011, 13:02
Re: Checking if a player is close to car. - by Supercop - 20.10.2011, 13:12
Re: Checking if a player is close to car. - by Supercop - 20.10.2011, 19:44
Re: Checking if a player is close to car. - by =WoR=Varth - 20.10.2011, 21:52
Re: Checking if a player is close to car. - by Supercop - 21.10.2011, 08:00

Forum Jump:


Users browsing this thread: 1 Guest(s)