Quantcast
Channel: SA-MP Forums
Viewing all articles
Browse latest Browse all 18226

Problems with a function

$
0
0
Okay so I have this function

Code:

stock GetClosestVehicle(playerid, Float:range)
{
    new    Float:p_X;
    new    Float:p_Y;
    new    Float:p_Z;

    new    Float:Distance;
    new    Float:PretendentDistance = range +1;
    new    Pretendent;

    GetPlayerPos(playerid, p_X, p_Y, p_Z);

    for(new vehicleid=1; vehicleid < MAX_VEHICLES; vehicleid++)
    {
        Distance = GetVehicleDistanceFromPoint(vehicleid, p_X, p_Y, p_Z);

        if(Distance <= range && Distance <= PretendentDistance)
        {
            Pretendent = vehicleid;
            PretendentDistance = Distance;
        }
    }

    return Pretendent;
}

But when I try to check for closest vehicle, it always give me the 1999 ID of a car that doesn't exists, I don't know why is this.

Viewing all articles
Browse latest Browse all 18226

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>