#5

GetClosestVehicle is faster using "GetVehicleDistanceFromPoint" then calculating the distance in PAWN:
pawn Код:
stock GetClosestVehicle(playerid, Float: fRadius)
{
    new
        Float: fX,
        Float: fY,
        Float: fZ,
        Float: fDist[2],
        iClosestID = INVALID_VEHICLE_ID
    ;
    fDist[1] = fRadius;
    GetPlayerPos(playerid, fX, fY, fZ);
   
    for(new i; i < MAX_VEHICLES; ++i)
    {
        if((fDist[0] = GetVehicleDistanceFromPoint(i, fX, fY, fZ)) < fDist[1])
        {
            iClosestID = i;
            fDist[1] = fDist[0];
        }
    }
    return iClosestID;
}
Reply


Messages In This Thread
? - by Gh0sT_ - 22.08.2011, 13:28
Re: ? - by iMonk3y - 22.08.2011, 13:47
Re: ? - by Gh0sT_ - 22.08.2011, 17:52
Re: ? - by Riddick94 - 22.08.2011, 17:56
Re: ? - by RyDeR` - 22.08.2011, 18:09
Re: ? - by Gh0sT_ - 22.08.2011, 18:34
Re: ? - by Gh0sT_ - 24.08.2011, 16:22
Re: ? - by AndreT - 24.08.2011, 16:27
Re: ? - by iMonk3y - 24.08.2011, 16:29
Re: ? - by Gh0sT_ - 24.08.2011, 16:30

Forum Jump:


Users browsing this thread: 1 Guest(s)