03.06.2009, 13:31
I need an anti cmd spamming! Like the player can 3 times write that cmd not 1000 times!
can anybody help me?
can anybody help me?
forward antispam(playerid);
public OnPlayerCommandText(playerid, cmdtext)
{
if(spam[playerid] >=3) {
SendClientMessage(playerid, RED, "Stop spamming wait 5 sec.");
SetTimerEx("antispam", 30000, false, "i", playerid);
}
if(strcmp("/help", cmdtext, true)==0)
{
spam[playerid]++;
}
return 0;
}
public antispam(playerid) {
spam[playerid] = 0;
SendClientMessage(playerid, RED,"you can now type a command");
return 1;
}
new spam[MAX_PLAYERS];
Originally Posted by Don Correlli
You forgot:
pawn Код:
|
Originally Posted by Pandabeer1337
simply use a variable and a timer.
pawn Код:
|
public OnPlayerCommandText(playerid, cmdtext)
{
spam[playerid]++;
if(spam[playerid] >=3) {
SendClientMessage(playerid, RED, "Stop spamming wait 5 sec.");
SetTimerEx("antispam", 30000, false, "i", playerid);
}
return 0;
}
Originally Posted by Pandabeer1337
unless you want it that you cant spam 3 different commands, than you could just do this:
pawn Код:
|
Originally Posted by Backwardsman97
It would work the same for commands. But you should just put 'spam[playerid]++;' under each command instead of out in the open. It will work like that, but every time you type a random command or a wrong command, it will count towards spamming.
|