AntiSpam - wutta - 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: AntiSpam - wutta (
/showthread.php?tid=253408)
AntiSpam - wutta -
Seven_of_Nine - 06.05.2011
pawn Код:
if(strcmp(LastMessage[playerid],text,true) == 0) {
switch(PlayerInfo[playerid][pSpam]) {
case 0: {
PlayerInfo[playerid][pSpam]++;
}
case 1: {
SendClientMessage(playerid,red,"Calm down, don't spam! :D");
PlayerInfo[playerid][pSpam]++;
return 0;
}
case 2: {
SendClientMessage(playerid,red,"Anti-spam warning, next is a kick!");
PlayerInfo[playerid][pSpam]++;
return 0;
}
case 3: {
SendClientMessage(playerid,red,"You've been kicked for spam!");
new spamtext[128], spamname[30];
PlayerInfo[playerid][pSpam] = 0;
GetPlayerName(playerid,spamname,sizeof(spamname));
format(spamtext,sizeof(spamtext),"ANTISPAM: %s has been kicked for spam.",spamname);
SendClientMessageToAll(red,spamtext);
Kick(playerid);
return 0;
}
}
} else {
format(LastMessage[playerid],128,"%s",text);
PlayerInfo[playerid][pSpam] = 0;
}
The problem is:
Whatever I say, it keeps increasing the PlayerInfo[playerid][pSpam].
So I type: "hi", then I type "test" then it returns "Calm down, don't spam
"
What's this? O.o
Before you rewrite / share your code, I just need to correction :]
Re: AntiSpam - wutta -
Calgon - 06.05.2011
It'll increase forever - that's how you've scripted it, you need to script a timer to run in conjunction with it so that a value is removed every X second (or create another variable which stores the last time a message was sent and compare it to the current time).
Re: AntiSpam - wutta -
Seven_of_Nine - 06.05.2011
Then how do I prevent a player to send the same message twice?
Re: AntiSpam - wutta -
Calgon - 06.05.2011
Oh, my apologies - I misunderstood your code. Make sure you copy 'text' to LastMessage[playerid] after this switch statement, and then also make sure that you're copying it correctly.
Also, use this code for copying your string instead of your current method:
pawn Код:
strcat(LastMessage[playerid], text, 128);
Re: AntiSpam - wutta -
Seven_of_Nine - 06.05.2011
Nice thanks, it works now. I put the formatting outside of the else { }