SA-MP Forums Archive
Command Spam - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Command Spam (/showthread.php?tid=87428)



Command Spam - [top_Shoter] - 20.07.2009

Is There Anything so if like a command or message is been typed more than twice in a row the 3rd time it will say stop spamming but i need it so commands cant be spammed
dose anyone no one please? thanks for helping.


Re: Command Spam - lilstuh - 20.07.2009

use junkbuster... it will kick the person.

bad: if an admin uses /slap for a reason 2 times. hell get kicked...


Re: Command Spam - StrickenKid - 20.07.2009

make a var indexed to every player, for example:
Код:
new SpamCheck[MAX_PLAYERS];
and make a timer, make sure you have a forward for it,
Код:
//OnGameModeInit:
SetTimer("AntiSpam",5000,1); // occurs every 5 seconds
then every time a player types a message, or sends a command add on to your spamcheck var, for example:
Код:
//OnPlayerCommandText:
SpamCheck[playerid] ++;
// and to stop the spam:
if(SpamCheck[playerid] > 5)
{
  SendClientMessage(playerid, COLOR, "DONT SPAM!!!!");
  return 0;
}
and then for chat spam:
Код:
//OnPlayerText:
SpamCheck[playerid] ++;
if(SpamCheck[playerid] > 5)
{
  SendClientMessage(playerid, COLOR, "DONT SPAM!!!!");
  return 0;
}
and the public function for the timer:
Код:
public AntiSpam()
{
  for(new i=0; i<MAX_PLAYERS; i++)
  {
    SpamCheck[playerid] --;
  }
}
as you see the timer runs every 5 seconds and you will get "DONT SPAM!!!!" if you send a command / msg more than 5 times, so thats 1 command/msg a second you will be able to send without getting do not spam.

you can of curse change it to how you want.


Re: Command Spam - [top_Shoter] - 20.07.2009

Quote:
Originally Posted by <__Ǝthan__>
make a var indexed to every player, for example:
Код:
new SpamCheck[MAX_PLAYERS];
and make a timer, make sure you have a forward for it,
Код:
//OnGameModeInit:
SetTimer("AntiSpam",5000,1); // occurs every 5 seconds
then every time a player types a message, or sends a command add on to your spamcheck var, for example:
Код:
//OnPlayerCommandText:
SpamCheck[playerid] ++;
// and to stop the spam:
if(SpamCheck[playerid] > 5)
{
 SendClientMessage(playerid, COLOR, "DONT SPAM!!!!");
 return 0;
}
and then for chat spam:
Код:
//OnPlayerText:
SpamCheck[playerid] ++;
if(SpamCheck[playerid] > 5)
{
 SendClientMessage(playerid, COLOR, "DONT SPAM!!!!");
 return 0;
}
and the public function for the timer:
Код:
public AntiSpam()
{
 for(new i=0; i<MAX_PLAYERS; i++)
 {
   SpamCheck[playerid] --;
 }
}
as you see the timer runs every 5 seconds and you will get "DONT SPAM!!!!" if you send a command / msg more than 5 times, so thats 1 command/msg a second you will be able to send without getting do not spam.

you can of curse change it to how you want.
dosent work when i add it.? ill try another way editing your idear and let you no how i get on thanks os much mate.


Re: Command Spam - StrickenKid - 20.07.2009

yes, you will have to edit it to fit your script, you cant just take an example i gave you and throw it in an expect it to work, you gotta do some work to, hope you get it working!