IfIsAnyFBIVehNear Stock help
#2

with this you are getting the closest vehicle.
PHP Code:
GetClosestVehicle(playerid)
{
    new 
closestdist 999999999closestvehicle = -1;
    new 
Float:x[2],Float:y[2],Float:z[2],distance;
    for(new 
iMAX_VEHICLESi++)
    {
        
GetVehiclePos(i,x[0],y[0],z[0]);
        
//if(x[0] == 0.0 && y[0] == 0.0 && z[0] == 0.0) return -1;
        
GetPlayerPos(playerid,x[1],y[1],z[1]);
        
distance floatround(GetDistanceBetweenPoints(x[0],y[0],z[0],x[1],y[1],z[1]));
        if(
distance closestdist) {
            
closestdist distance;
            
closestvehicle i;
        }
    }
    return 
closestvehicle;

it simply loops trought the vehicles and sees what the nearest vehicle is.

so you can use this in your cmd like
PHP Code:
fbiranger GetClosestVehicle(playerid); 
then you need to use
PHP Code:
IsPlayerNearVehicle(playeridfbirangerrange
with this useful function
PHP Code:
IsPlayerNearVehicle(playeridvehicleidFloat:range)
{
    new 
Float:XFloat:YFloat:Z;
    
GetVehiclePos(vehicleidXYZ);
    if(
IsPlayerInRangeOfPoint(playeridrangeXYZ))return true;
    else return 
false;

and you need to do another check to see if the car has the model of the fbi rancher.
PHP Code:
GetVehicleModel 
You have the cars list here :
Reply


Messages In This Thread
IfIsNearFBIVeh help - by MarioKamani - 02.03.2018, 10:22
Re: IfIsAnyFBIVehNear Stock help - by PepsiCola23 - 02.03.2018, 10:57
Re: IfIsAnyFBIVehNear Stock help - by MarioKamani - 02.03.2018, 12:35
Re: IfIsAnyFBIVehNear Stock help - by PepsiCola23 - 02.03.2018, 12:39
Re: IfIsAnyFBIVehNear Stock help - by MarioKamani - 02.03.2018, 17:20

Forum Jump:


Users browsing this thread: 1 Guest(s)