Problems with a function
#1

Okay so I have this function

Код:
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.
Reply


Messages In This Thread
Problems with a function - by Antenastyle - 19.04.2017, 13:27
Re: Problems with a function - by Marricio - 19.04.2017, 13:33
Re: Problems with a function - by Antenastyle - 19.04.2017, 13:41
Re: Problems with a function - by Marricio - 19.04.2017, 13:47
Re: Problems with a function - by Antenastyle - 19.04.2017, 13:51
Re: Problems with a function - by JustNothing - 19.04.2017, 14:06
Re: Problems with a function - by Antenastyle - 19.04.2017, 14:30
Re: Problems with a function - by JustNothing - 19.04.2017, 15:45
Re: Problems with a function - by Antenastyle - 19.04.2017, 18:05
Re: Problems with a function - by Logic_ - 19.04.2017, 18:17

Forum Jump:


Users browsing this thread: 2 Guest(s)