25.10.2010, 13:55
How to set a timer for a command so you can only do it once every 2 mins?
new usedcommand[MAX_PLAYERS];
usedcommand[playerid] =0;
usedcommand[playerid] =0;
usedcommand[playerid] =10; // 10 seconds?
if(usedcommand[playerid]) return SendClientMessage(playerid,COLOR,"Plz Wait");
SetTimer("loltimer",1000,1);
public loltimer()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(usedcommand[i] > 0)
{
usedcommand[i] --;
}
}
}
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;
}