What does this 'GetNearestVehicle' really do?
#1

I have trying to figoure out, how this works for few hour now with my friend lol. And still not 100% sure, what does this 'Distance' part should do.. could someone explain me? lol

pawn Код:
stock GetNearestVehicle(playerid, Float:distance)
{
    new
            Float:xX,
            Float:yY,
            Float:zZ,
            retElement = -1
    ;
    for(new i = 0; i < MAX_VEHICLES; i++)
    {
        GetVehiclePos(i, xX, yY, zZ);
        new Float:odist = GetPlayerDistanceFromPoint(playerid, xX, yY, zZ);
        if (retElement == -1)
        {
            retElement = i;
            distance = odist;
        }
        else if (odist < distance)
        {
            retElement = i;
            distance = odist;
        }
    }
    return retElement;
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)