Help please!
#1

I need an anti cmd spamming! Like the player can 3 times write that cmd not 1000 times!
can anybody help me?
Reply
#2

Here is the link: http://forum.sa-mp.com/index.php?topic=30726.0
Reply
#3

simply use a variable and a timer.

pawn Код:
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;
}
not test / compiled,
Reply
#4

You forgot:
pawn Код:
new spam[MAX_PLAYERS];
Reply
#5

Quote:
Originally Posted by Don Correlli
You forgot:
pawn Код:
new spam[MAX_PLAYERS];
stupid me :X
Reply
#6

Quote:
Originally Posted by Pandabeer1337
simply use a variable and a timer.

pawn Код:
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;
}
not test / compiled,
uhm,i don't fet this code very vell... do I need to ad every my commands under OnPlayerCommandText? like /help .Credits ..etc ?
Reply
#7

unless you want it that you cant spam 3 different commands, than you could just do this:

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;
}
Reply
#8

Quote:
Originally Posted by Pandabeer1337
unless you want it that you cant spam 3 different commands, than you could just do this:

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;
}
isn't this for anti chat spamming?
Reply
#9

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.
Reply
#10

Quote:
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.
ok thank you..but do you have any other idea?

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)