#1

I want to create a command that repairs your vehicle, but I have issues with the timer.

PHP код:
CMD:repairmycar(playeridparams[])
{
    if(!
IsPlayerInAnyVehicle(playerid))
        return 
SendErrorMessage(playerid"You are not in a vehicle!");
        
    if(
GetPlayerState(playerid) != 2)
        return 
SendErrorMessage(playerid"You are not in the driver seat!");
        
    if(
IsPlayerInRangeOfPoint(playerid6.0, -2417.77442303.79791.8781))
        return 
SendErrorMessage(playerid"You should be in range of the point to /repairmycar !");
        
    
SendClientMessage(playeridCOLOR_WHITE"Your vehicle will be ready in one hour (1 minute).");
    
GivePlayerMoney(playerid, - 200);
        
    
RepairVehicle(GetPlayerVehicleID(playerid));  
    return 
1;

I need help with kicking the player out of the vehicle and make the vehicle respawn after 1 minute. Thanks in advance.
Reply
#2

First of all to set a timer you would need SetTimerEx second of all if you use SetVehicleToRespawn you wont need RepairVehicle so i'm gonna go with RepairVehicle to avoid setting the vehicle's position again.
PHP код:
CMD:repairmycar(playeridparams[]) 

    if(!
IsPlayerInAnyVehicle(playerid)) 
        return 
SendErrorMessage(playerid"You are not in a vehicle!"); 
         
    if(
GetPlayerState(playerid) != 2
        return 
SendErrorMessage(playerid"You are not in the driver seat!"); 
         
    if(
IsPlayerInRangeOfPoint(playerid6.0, -2417.77442303.79791.8781)) 
        return 
SendErrorMessage(playerid"You should be in range of the point to /repairmycar !"); 
         
    
SendClientMessage(playeridCOLOR_WHITE"Your vehicle will be ready in one hour (1 minute)."); 

    
GivePlayerMoney(playerid, - 200); 
    
RemovePlayerFromVehicle(GetPlayerVehicleID(playerid));//remove him from the car
    
SetTimerEx("RepairCar",60000,false,"d",GetPlayerVehicleID(playerid));//set the timer
    
return 1
}  
forward RepairCar(pvehicleid);
public 
RepairCar(pvehicleid)
{
    
RepairVehicle(pvehicleid);//repair the car after 60 seconds
    
return 1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)