How can I make the order/repair work just in front of a vehicle
#4

Example code to detect if player is near hood and usage.

PHP код:

if(strcmp(cmd"/repair"true) == 0)
{
    new 
    
Float:X,
    
Float:Y,
    
Float:Z,
    
vehicleid = Function;
    
GetVehicleHood(vehicleidXYZ);
    if(
IsPlayerInRangeOfPoint(playerid1.5XYZ))
    {
        
ApplyAnimation(playerid,"CAR""Fixn_Car_Loop",4.1,1,1,1,1,10000);
        
SetVehicleHealth(vehicleid1000.0);
        
RepairVehicle(vehicleid);
    }
    else 
SendClientMessage(playerid, -1"You're not near vehicle's hood.");
    
    return 
1;

or

PHP код:

if(strcmp(cmd"/repair"true) == 0)
{
    new 
    
Float:X,
    
Float:Y,
    
Float:Z;
    
    for(new 
vehicleid 0vehicleid MAX_VEHICLESvehicleid++)
    {
        
GetVehicleHood(vehicleidXYZ);
        if(
IsPlayerInRangeOfPoint(playerid1.5XYZ))
        {
            
ApplyAnimation(playerid,"CAR""Fixn_Car_Loop",4.1,1,1,1,1,10000);
            
SetVehicleHealth(vehicleid1000.0);
            
RepairVehicle(vehicleid);
            break;
        }
        else 
SendClientMessage(playerid, -1"You're not near vehicle's hood.");
    }
    
    return 
1;

Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)