GetClosestVehicle
#1

Hi all,

I have the following command:

Код:
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;
}


new vehicleid = GetClosestVehicle(playerid, 10.0);
However, unfortunately when I print the contents of vehicleid on executing the command right next to a vehicle, it only prints the value of 0, which means this isn't working.

Pulling my hair out with this...any ideas?
Reply


Messages In This Thread
GetClosestVehicle - by Jonesy96 - 14.07.2016, 15:40
Re: GetClosestVehicle - by Stinged - 14.07.2016, 16:20
Re: GetClosestVehicle - by Luicy. - 14.07.2016, 16:25
Re: GetClosestVehicle - by Jonesy96 - 14.07.2016, 16:28
Re: GetClosestVehicle - by Konstantinos - 14.07.2016, 16:30
Re: GetClosestVehicle - by Jonesy96 - 14.07.2016, 16:53

Forum Jump:


Users browsing this thread: 2 Guest(s)