Getting closest issue
#1

Alright so the problem is simple, the code works but if you are not in range of that vehicle you will get unknown command display

PHP код:
GetClosestVehicleForPlayer(playerid)
{
    new 
vehicleid INVALID_VEHICLE_ID;
    new 
Float:distance 5.0;
    new 
Float:XFloat:YFloat:Z;
    
GetPlayerPos(playeridXYZ);
    for(new 
0MAX_VEHICLESi++)
    {
        if(!
IsValidVehicle(i)) continue;
        new 
Floattmp GetVehicleDistanceFromPoint(iXYZ);
        if(
tmp distance) continue;
        
vehicleid i;
        
distance tmp;
    }
    return 
vehicleid;

Reply
#2

PHP код:
GetClosestVehicleForPlayer(playerid

    new 
vehicleid INVALID_VEHICLE_ID
    new 
Float:distance 5.0
    new 
Float:XFloat:YFloat:Z
    
GetPlayerPos(playeridXYZ); 
    for(new 
0MAX_VEHICLESi++) 
    { 
        if(!
IsValidVehicle(i)) continue; 
        new 
Floattmp GetVehicleDistanceFromPoint(iXYZ); 
        if(
tmp distance) continue; 
        
vehicleid i
        
distance tmp
    }
    if(
vehicleid != INVALID_VEHICLE_ID) return vehicleid
    else return 
SendClientMessage(playerid,-1,"There are no vehicle near to you!");

probably its because you giving player invalid vehicle id o.o try this code it would work
Reply
#3

Thanks mate
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)