Player next to vehicle
#1

Hi all
If any one has the code of
a function that Detect the vehicleid next to the playerid pleas share it
Reply
#2

PHP код:
stock GetNearestVehicle(playeridFloat:dis)
{
    new 
Float:LFloat:OFloat:II;
    if(
GetPlayerPos(playeridLOII))
    {
        new 
vehicleid INVALID_VEHICLE_ID;
        for(new 
vFloat:tempFloat:VLFloat:VOFloat:VII!= MAX_VEHICLESv++)
        {
            if(
GetVehiclePos(vVLVOVII) && != GetPlayerVehicleID(playerid))
            {
                
VL -= LVO -= OVII -= II;
                
temp VL VL VO VO VII VII;
                if(
temp disdis tempvehicleid v;
            }
        }
        
dis floatpower(dis0.5);
        return 
vehicleid;
    }
    return 
INVALID_VEHICLE_ID;

Reply
#3

gonna test and ++ REP if it works thnsk
Reply
#4

If that doesn't work then heres one.
PHP код:
stock GetClosestVehicle(playerid)
{
    new 
Float:xFloat:yFloat:z;
    new 
Float:distFloat:closedist=50closevehfound 0;
    for(new 
i=1MAX_VEHICLESi++)
    {
        if(
GetVehiclePos(ixyz) && != GetPlayerVehicleID(playerid))
        {
            
dist GetPlayerDistanceFromPoint(playeridxyz);
            if(
dist closedist)
            {
                
found 1;
                
closedist dist;
                
closeveh i;
            }
        }
    }
    if(
found == 1) return closeveh;
    return 
0;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)