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.