Timer for command???
#1

How to set a timer for a command so you can only do it once every 2 mins?
Reply
#2

Top
pawn Code:
new usedcommand[MAX_PLAYERS];
OnConnect..
pawn Code:
usedcommand[playerid] =0;

OnDisConnect..
pawn Code:
usedcommand[playerid] =0;

InYourCommand..
pawn Code:
usedcommand[playerid] =10; // 10 seconds?

InYourCommand..
pawn Code:
if(usedcommand[playerid]) return SendClientMessage(playerid,COLOR,"Plz Wait");

GameModeInit..
pawn Code:
SetTimer("loltimer",1000,1);

EndOfScript..
pawn Code:
public loltimer()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(usedcommand[i] > 0)
        {
            usedcommand[i] --;
        }
    }
}
Reply
#3

Thanks,Works Perfectly!
Reply
#4

2 Topics meaning 1 things...
[/sigh]
Reply
#5

Wouldn't you need to make a forward function for "loltimer"?
Reply
#6

pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
  if(strcmp("/command", cmdtext, true, 9) == 0)
  {
    if(GetPVarInt(playerid,"WAITBEFOREUSINGITAGAIN")>GetTickCount())return SendClientMessage(playerid,Colour,"ERROR : You must wait before using a command");
    SetPVarInt(playerid,"WAITBEFOREUSINGITAGAIN",GetTickCount()+5000); // 1000 = 1 secs
    // Put some codes here
  }
  return 1;
}
Same goes to dcmd and zcmd

EDIT : Oh shi... Better look at the time and date next time >.>
Reply
#7

lol how long ago did i post this xD
Reply
#8

Sigh, use SetTimerEx
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)