Command Timer Help!
#1

hi this is my code

pawn Code:
if(!strcmp("/vr", cmdtext, true))
{
 
   {
    if(IsPlayerInAnyVehicle(playerid))
       
            {
            new VehicleID;
            VehicleID = GetPlayerVehicleID(playerid);
            RepairVehicle(VehicleID);
            return SendClientMessage(playerid, YELLOW," Sucessfully Fixed The Vehicle ");
            }
            else return SendClientMessage(playerid,RED,"ERROR: You are not in a Vehicle!");
           

        }
return 1;
}

i wanna make command text timer like player cant use it again and again..
Like He Can Use It Only Once In 2 min and if he used it he must wait for 2 min.

_________________________________________

I have searched alot on forums but not got any solution . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Reply
#2

Here, without any timers

At the top of the Script:
pawn Code:
new WaitTimeForCMD[MAX_PLAYERS];
OnPlayerCommandText:
pawn Code:
if(!strcmp("/vr", cmdtext, true))
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        if((GetTickCount()-WaitTimeForCMD[playerid])>120000)return SendClientMessage(playerid,RED,"ERROR: Wait 2Minutes to use this CMD again!");
        new VehicleID;
        VehicleID = GetPlayerVehicleID(playerid);
        RepairVehicle(VehicleID);
        WaitTimeForCMD[playerid]=GetTickCount();
        return SendClientMessage(playerid,YELLOW," Sucessfully Fixed The Vehicle ");
    }
    else return SendClientMessage(playerid,RED,"ERROR: You are not in a Vehicle!");
}
Reply
#3

Quote:
Originally Posted by Pablo Borsellino
View Post
Here, without any timers

At the top of the Script:
pawn Code:
new WaitTimeForCMD[MAX_PLAYERS];
OnPlayerCommandText:
pawn Code:
if(!strcmp("/vr", cmdtext, true))
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        if((GetTickCount()-WaitTimeForCMD[playerid])>120000)return SendClientMessage(playerid,RED,"ERROR: Wait 2Minutes to use this CMD again!");
        new VehicleID;
        VehicleID = GetPlayerVehicleID(playerid);
        RepairVehicle(VehicleID);
        WaitTimeForCMD[playerid]=GetTickCount();
        return SendClientMessage(playerid,YELLOW," Sucessfully Fixed The Vehicle ");
    }
    else return SendClientMessage(playerid,RED,"ERROR: You are not in a Vehicle!");
}
what is gettickcount is that settimer
Reply
#4

No gettickcount is'nt SetTimer. Read »this«! A gettickcount is something like a timestamp gettime() but the timestamp starts from zero if the Server starts Its better for your ressources if you use this method and not SetTimer.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)