Inrange
#2

You could try:

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;
}
Modify to suit your needs.
Reply


Messages In This Thread
Inrange - by iGetty - 21.09.2011, 12:49
Re: Inrange - by Stigg - 21.09.2011, 12:54
Re: Inrange - by iGetty - 21.09.2011, 12:55
Re: Inrange - by aRoach - 21.09.2011, 12:55

Forum Jump:


Users browsing this thread: 3 Guest(s)