[SOLVED] Anti Command Spam.
#9

It's pretty simple and can be done in many different ways. While reading your posts I had thought of a pretty cool method. Now for the benefit for everyone else I will create the snippet.

pawn Код:
#define MAX_COMMAND_FREQUENCY 4 //effects how many times a player can type a command without being stopped
new PlayerCmdFrq[MAX_PLAYERS]; //Player Command Frequency
forward UpdateCmdFreq();

public OnPlayerCommandText(playerid,cmdtext[])
{
    PlayerCmdFrq[playerid]++;
    if(PlayerCmdFrq[playerid]>MAX_COMMAND_FREQUENCY)
    {
        SendClientMessage(playerid,0xFF0000FF,"You can't use commands so often.");
        return 1;
    }
    //Then your commands and everything else go here
}
public OnGameModeInit()
{
    SetTimer("UpdateCmdFreq",2000,1);
}
public UpdateCmdFreq()
{
    for(new playerid;playerid<MAX_PLAYERS;playerid++)
    {
      if(PlayerCmdFrq[playerid])PlayerCmdFrq[playerid]--;
    }
}
This will allow a player to do up to 4 but then only let them do 1 per second, which that 1 will roll over to the next second (allowing a build up of 4 again).

Enjoy it!
Reply


Messages In This Thread
[SOLVED] Anti Command Spam. - by BP13 - 23.07.2009, 16:16
Re: Anti Command Spam. - by Correlli - 23.07.2009, 16:36
Re: Anti Command Spam. - by BP13 - 23.07.2009, 17:23
Re: Anti Command Spam. - by Correlli - 23.07.2009, 17:28
Re: Anti Command Spam. - by BP13 - 23.07.2009, 17:59
Re: Anti Command Spam. - by Correlli - 23.07.2009, 18:04
Re: Anti Command Spam. - by BP13 - 23.07.2009, 18:31
Re: Anti Command Spam. - by BP13 - 26.07.2009, 09:10
Re: Anti Command Spam. - by Joe Staff - 26.07.2009, 09:34
Re: Anti Command Spam. - by [top_Shoter] - 26.07.2009, 09:37

Forum Jump:


Users browsing this thread: 3 Guest(s)