Repair command [help]
#3

This should do the job:
PHP код:
new pTimeREPAIR[MAX_PLAYERS]; // on top
CMD:repair(playeridparams[])
{
    if((
pTimeREPAIR[playerid]-gettime()) > 0) {
        new 
string[85];
        
format(string,sizeof string,"Wait %d Seconds before using this command again!",pTimeREPAIR[playerid]-gettime());
        
SendClientMessage(playerid, -1string);
        return 
1;
    }
    new 
string[128], veh;
    if(!
IsPlayerLoggedIn(playerid) || PlayerInfo[playerid][pAsshole] == 1) return SendClientMessage(playeridCOLOR_GREY"You are not allowed to use command.");
    if(
PlayerInfo[playerid][pJob] != JOB_MECHANIC && PlayerInfo[playerid][pVIPJob] != JOB_MECHANIC && !IsATower(playerid)) return SendClientMessage(playeridCOLOR_GREY"You are not mechanic.");
    if(
sscanf(params"i"veh)) return SendClientMessage(playeridCOLOR_WHITE"How to use: /repair [IDof the car /dl]");
    new 
Float:vHGetVehicleHealth(GetPlayerVehicleID(playerid), vH);
    new 
Float:vel[3]; GetVehicleVelocity(GetPlayerVehicleID(playerid), vel[0], vel[1], vel[2]);
    if(
vH 250) return SendClientMessage(playeridCOLOR_GREY"the car's engine is too hot to repair it.");
    if(
GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playeridCOLOR_GREY"You have to be on the driving seat to repair the car.");
    if(
vel[0] != || vel[1] != || vel[2] != 0) return SendClientMessage(playeridCOLOR_GREY"You can't repair while moving");
    
RepairVehicle(GetPlayerVehicleID(playerid));
    
PlayerInfo[playerid][pJobSkill][JOB_MECHANIC] ++;
    
PlayerPlaySound(playerid,1133,0.0,0.0,0.0);
    
format(stringsizeof(string), "* %s fixes the car's engine."RPN(playerid));
       
SendNearbyMessage(playerid15stringCOLOR_PURPLECOLOR_PURPLECOLOR_PURPLECOLOR_PURPLECOLOR_PURPLE);
       
pTimeREPAIR[playerid] = gettime()+60;
    return 
1;

What is gettime()?
Reply


Messages In This Thread
Repair command [help] - by Diabloa - 11.05.2016, 19:14
Re: Repair command [help] - by Sew_Sumi - 11.05.2016, 19:20
Re: Repair command [help] - by jlalt - 11.05.2016, 19:22
Re: Repair command [help] - by Sew_Sumi - 11.05.2016, 19:23
Re: Repair command [help] - by Dayrion - 11.05.2016, 19:23

Forum Jump:


Users browsing this thread: 1 Guest(s)