31.08.2010, 18:47
How to make an AntiSpam commands system?
I tried with a Timer but failed
not much but i couldnt use on all cmds i want 
Thanks!
I tried with a Timer but failed


Thanks!
new lastcmd[MAX_PLAYERS];
public OnPlayerCommandText(playerid, cmdtext[]) {
if(GetTickCount() - lastcmd[playerid] < 1000 && lastcmd[playerid] != 0)
{
SendClientMessage(playerid, 0xAA3333AA, "You are using commands too fast! Slow down.");
return 1;
}
lastcmd[playerid] = GetTickCount();
(...)
SetTimerEx ("CmdTimerOff", 3000, false,"i", playerid);
if (GetPVarInt (playerid, "UsouCMD") == 0)
SetPVarInt (playerid, "UsouCMD", 1);
public OnPlayerCommandText (playerid, cmdtext [])
{
SetTimerEx ("CmdTimerOff ", 3000, false,"i", playerid);
if (GetPVarInt (playerid, "UsouCMD") == 0)
{
SetPVarInt (playerid, "UsouCMD", 1);
if (strcmp ("/cmd", cmdtext, true) == 0)
{
SendClientMessage (playerid, COLOR, "TEXT");
return 1;
}
if (strcmp ("/ cmd2" cmdtext, true) == 0)
{
SendClientMessage (playerid, COLOR, "STRING2");
return 1;
}
} / / Close key
//Okay, now let's make an error message if it is Flood, right here.
else {
return SendClientMessage (playerid, COLOR, "Wait a moment please (anti-flood ).");
}
return 0; //return if the command is invalid
}
forward CmdTimerOff (playerid);
public CmdTimerOff (playerid)
{
return DeletePVar (playerid, "UsouCMD");
}