closest vehicle
#1

hello.
how i can get a closest vehicle without the current vehicle id?
for e.g. i am in a vehicle (id 2) and near me there is a vehicle (id 3).

when i am using this, i always get id 2. how i can get id 3?
PHP код:
stock GetClosestVehicle(playeridFloat:radius)
{
    new 
Float:CarXFloat:CarZFloat:CarYFloat:DisFloat:Dis2,vehicleid;
    
Dis 99999.99;
    
vehicleid INVALID_VEHICLE_ID;
    for(new 
0MAX_VEHICLESi++)
    {
        
GetVehiclePos(iCarXCarYCarZ);
        
Dis2 GetPlayerDistanceFromPoint(playeridCarXCarYCarZ);
        if(
Dis2 Dis && Dis2 radius)
        {
                
Dis Dis2;
                
vehicleid i;
        }
    }
    return 
vehicleid;

Reply
#2

if(Dis2 < Dis && Dis2 < radius)
change this to this --
if(Dis2 < Dis && Dis2 < radius && i != GetPlayerVehicleID(playerid))
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)