GetClosestVehicle(playerid, radius)
#6

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;
}
Reply


Messages In This Thread
GetClosestVehicle(playerid, radius) - by armyoftwo - 11.11.2010, 14:15
Re: GetClosestVehicle(playerid, radius) - by rs.pect - 11.11.2010, 14:26
Re: GetClosestVehicle(playerid, radius) - by armyoftwo - 11.11.2010, 14:27
Re: GetClosestVehicle(playerid, radius) - by Babul - 11.11.2010, 14:32
Re: GetClosestVehicle(playerid, radius) - by armyoftwo - 11.11.2010, 14:42
Re: GetClosestVehicle(playerid, radius) - by The_Moddler - 11.11.2010, 14:47

Forum Jump:


Users browsing this thread: 3 Guest(s)