anti spam chat
#1

im trying to make if you write more than 5 times on chat fast you get muted.
the problem is as soon as i put this code the compiler gets a lot of errors like this

PHP Code:
test\include\YSI\y_hooks/impl.inc(323) : warning 219local variable "i" shadows a variable at a preceding level
test
\include\YSI\y_master/once.inc(343) : warning 219local variable "i" shadows a variable at a preceding level
test
\include\YSI\y_master/once.inc(399) : warning 219local variable "i" shadows a variable at a preceding level
test
\include\YSI\y_master/once.inc(446) : warning 219local variable "i" shadows a variable at a preceding level
test
\include\YSI\y_commands.inc(874) : warning 219local variable "i" shadows a variable at a preceding level
test
\include\YSI\y_commands.inc(967) : warning 219local variable "i" shadows a variable at a preceding level
test
\include\YSI\y_commands.inc(1049) : warning 219local variable "i" shadows a variable at a preceding level
test
\include\YSI\y_commands.inc(1121) : warning 219local variable "id" shadows a variable at a preceding level
test
\include\YSI\y_commands.inc(1184) : warning 219local variable "i" shadows a variable at a preceding level
test
\include\YSI\y_commands.inc(1361) : warning 219local variable "i" shadows a variable at a preceding level
test
\include\YSI\y_commands.inc(1399) : warning 219local variable "i" shadows a variable at a preceding level
test
\include\YSI\y_commands.inc(1880) : warning 219local variable "i" shadows a variable at a preceding level
test
\include\YSI\y_commands.inc(2598) : warning 219local variable "i" shadows a variable at a preceding level
test
\include\YSI\y_commands.inc(2650) : warning 219local variable "i" shadows a variable at a preceding level
test
\include\YSI\y_commands.inc(2686) : warning 219local variable "i" shadows a variable at a preceding level
test
\include\YSI\y_commands.inc(2724) : warning 219local variable "i" shadows a variable at a preceding level
test
\include\sscanf2.inc(149) : warning 219local variable "i" shadows a variable at a preceding level
test
\include\sscanf2.inc(193) : warning 219local variable "i" shadows a variable at a preceding level
test
\include\geoip.inc(398) : warning 219local variable "id" shadows a variable at a preceding level
test
\include\geoip.inc(455) : warning 219local variable "i" shadows a variable at a preceding level
test
\include\AutoAFK.inc(136) : warning 219local variable "i" shadows a variable at a preceding level
test
\gamemodes\serverteste.pwn(1461) : warning 219local variable "i" shadows a variable at a preceding level
test
\gamemodes\serverteste.pwn(1505) : warning 219local variable "i" shadows a variable at a preceding level
test
\gamemodes\serverteste.pwn(1606) : error 017undefined symbol "SetTunning"
test\gamemodes\serverteste.pwn(1605) : warning 204symbol is assigned a value that is never used"carid"
test\gamemodes\serverteste.pwn(1605 -- 1624) : warning 219local variable "i" shadows a variable at a preceding level
test
\gamemodes\serverteste.pwn(1635) : warning 219local variable "i" shadows a variable at a preceding level
test
\gamemodes\serverteste.pwn(1659) : error 017undefined symbol "Decimal"
test\gamemodes\serverteste.pwn(1671) : error 017undefined symbol "Decimal"
test\gamemodes\serverteste.pwn(1683) : warning 219local variable "i" shadows a variable at a preceding level
test
\gamemodes\serverteste.pwn(1709) : error 017undefined symbol "Decimal"
test\gamemodes\serverteste.pwn(1715) : error 017undefined symbol "Decimal"
test\gamemodes\serverteste.pwn(1727) : warning 219local variable "i" shadows a variable at a preceding level
test
\gamemodes\serverteste.pwn(1749) : error 017undefined symbol "Decimal"
test\gamemodes\serverteste.pwn(1755) : error 017undefined symbol "Decimal"
test\gamemodes\serverteste.pwn(1767) : warning 219local variable "i" shadows a variable at a preceding level
test
\gamemodes\serverteste.pwn(1807) : warning 219local variable "i" shadows a variable at a preceding level
test
\gamemodes\serverteste.pwn(1817) : warning 219local variable "i" shadows a variable at a preceding level
test
\gamemodes\serverteste.pwn(1832) : warning 219local variable "i" shadows a variable at a preceding level
test
\gamemodes\serverteste.pwn(1850) : warning 219local variable "i" shadows a variable at a preceding level
test
\gamemodes\serverteste.pwn(1993) : warning 219local variable "i" shadows a variable at a preceding level
test
\gamemodes\serverteste.pwn(2051) : warning 219local variable "i" shadows a variable at a preceding level
test
\gamemodes\serverteste.pwn(2114) : error 017undefined symbol "BanA"
test\gamemodes\serverteste.pwn(2127) : error 017undefined symbol "ABroadCast"
test\gamemodes\serverteste.pwn(2134) : error 017undefined symbol "ABroadCast"
test\gamemodes\serverteste.pwn(2141) : error 017undefined symbol "ABroadCast"
test\gamemodes\serverteste.pwn(2146) : error 017undefined symbol "ABroadCast"
test\gamemodes\serverteste.pwn(2154) : warning 219local variable "i" shadows a variable at a preceding level
test
\gamemodes\serverteste.pwn(2162) : warning 219local variable "i" shadows a variable at a preceding level
test
\gamemodes\serverteste.pwn(2200) : error 017undefined symbol "InsertCrime"
test\gamemodes\serverteste.pwn(4259) : error 017undefined symbol "CSEvent"
test\gamemodes\serverteste.pwn(4260) : error 017undefined symbol "KartEvent"
test\gamemodes\serverteste.pwn(4664) : warning 219local variable "i" shadows a variable at a preceding level
test
\gamemodes\serverteste.pwn(4697) : error 017undefined symbol "FactionName"
test\gamemodes\serverteste.pwn(4705) : error 017undefined symbol "FactionName"
test\gamemodes\serverteste.pwn(4722) : error 017undefined symbol "FactionName"
test\gamemodes\serverteste.pwn(4736) : error 017undefined symbol "FactionName"
test\gamemodes\serverteste.pwn(4768) : error 017undefined symbol "SafeboxLog"
test\gamemodes\serverteste.pwn(4771) : error 017undefined symbol "SafeboxLog"
test\gamemodes\serverteste.pwn(4779) : error 017undefined symbol "SafeboxLog"
test\gamemodes\serverteste.pwn(4782) : error 017undefined symbol "SafeboxLog"
test\gamemodes\serverteste.pwn(4809) : warning 219local variable "i" shadows a variable at a preceding level
test
\gamemodes\serverteste.pwn(4862) : error 017undefined symbol "Decimal"
test\gamemodes\serverteste.pwn(4864) : error 017undefined symbol "Decimal"
test.pwn error 017undefined symbol "Decimal"
Compilation aborted.Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
26 Errors
.
[
Finished in 5.5s
PHP Code:
    new string[180];
    
SpamCheck[playerid] = GetTickCount();
    if(
GetTickCount() - SpamCheck[playerid] < 1000 && SpamCheck[playerid] != 0
        {
            
SpamTimes[playerid]++;
            if(
SpamTimes[playerid] == 5
            {
                
PlayerData[playerid][Muted] = 1;
                
PlayerData[playerid][MutedTime] += 20;
                new 
str[128]; // blah blah
                
mysql_format(SQLstr,128,"UPDATE `users` SET `Muted`='1' ,`MutedTime`='%d' WHERE `id` = '%d' LIMIT 1",PlayerData[playerid][MutedTime],PlayerData[playerid][ID]);
                
mysql_tquery(SQLstr"""");
                
SendClientMessage(playeridCOLOR_GREY"You have been auto-muted for spamming. You will be unmuted in 20 seconds.");    
                return 
0;    
        }
        else 
SpamTimes[playerid] = 0
Reply
#2

Missing bracket maybe?

Code:
new string[180]; 
    SpamCheck[playerid] = GetTickCount(); 
    if(GetTickCount() - SpamCheck[playerid] < 1000 && SpamCheck[playerid] != 0)  
        { 
            SpamTimes[playerid]++; 
            if(SpamTimes[playerid] == 5)  
            { 
                PlayerData[playerid][Muted] = 1; 
                PlayerData[playerid][MutedTime] += 20; 
                new str[128]; // blah blah 
                mysql_format(SQL, str,128,"UPDATE `users` SET `Muted`='1' ,`MutedTime`='%d' WHERE `id` = '%d' LIMIT 1",PlayerData[playerid][MutedTime],PlayerData[playerid][ID]); 
                mysql_tquery(SQL, str, "", ""); 
                SendClientMessage(playerid, COLOR_GREY, "You have been auto-muted for spamming. You will be unmuted in 20 seconds.");     
                return 0;   
             }  
        } 
        else SpamTimes[playerid] = 0;
Reply
#3

u have syntax error in script, probably brecket is missing.
EDITED: OptimusBloodHunter already wrote it.
Reply
#4

i solved it and i got a new problem:

you get muted just by typing 5 messages in chat..it doesnt matter if you write fast or wait 1 minute between messages..you still get muted.

and after you get muted for the first time,after the mute expires,you can flood the chat as long as you want,you wont get muted again.

Quote:

SpamCheck[playerid] = GetTickCount();
if(GetTickCount() - SpamCheck[playerid] < 1000 && SpamCheck[playerid] != 0)
{
SpamTimes[playerid]++;
if(SpamTimes[playerid] == 5)
{
PlayerData[playerid][Muted] = 1;
PlayerData[playerid][MutedTime] += 20;
new str[128]; // blah blah
mysql_format(SQL, str,128,"UPDATE `users` SET `Muted`='1' ,`MutedTime`='%d' WHERE `id` = '%d' LIMIT 1",PlayerData[playerid][MutedTime],PlayerData[playerid][ID]);
mysql_tquery(SQL, str, "", "");
SendClientMessage(playerid, COLOR_GREY, "You have been auto-muted for spamming. You will be unmuted in 20 seconds.");
return 0;
}
}
else SpamTimes[playerid] = 0;

Reply
#5

do u have a timer?
Reply
#6

no i dont
Reply
#7

so where is reset for this SpamTimes[] ?
Reply
#8

Quote:

else SpamTimes[playerid] = 0;

there it is
Reply
#9

you have no any reset for this, u're just increasing and increasing, that's a reason why u're getting this.

try this:
at the top of code
PHP Code:
SpamMessages[MAX_PLAYERS],SpamChecker[MAX_PLAYERS]; 
put this code at OnPlayerConnect (or if u have a login system, place at login)
PHP Code:
SpamChecker[playerid] = SetTimerEx("CheckSpam",1000,1,"i",playerid); // u can increase this timer. 
now, put this code at OnPlayerText
PHP Code:
if(PlayerData[playerid][MutedTime] <= 0SpamMessages[playerid] ++;
if(
SpamMessages[playerid] >= 5)
{
    
PlayerData[playerid][Muted] = 1;
    
PlayerData[playerid][MutedTime] += 20;
    new 
str[128]; // blah blah
    
mysql_format(SQLstr,128,"UPDATE `users` SET `Muted`='1' ,`MutedTime`='%d' WHERE `id` = '%d' LIMIT 1",PlayerData[playerid][MutedTime],PlayerData[playerid][ID]); 
    
mysql_tquery(SQLstr""""); 
    
SendClientMessage(playeridCOLOR_GREY"You have been auto-muted for spamming. You will be unmuted in 20 seconds."); 
    return 
0

and now, build the reset function.
PHP Code:
forward CheckSpam(playerid);
public 
CheckSpam(playerid)
{
    if(
SpamMessages[playerid] >= && PlayerData[playerid][MutedTime] <= 0)
    {
        
PlayerData[playerid][Muted] = 1;
        
PlayerData[playerid][MutedTime] += 20;
        new 
str[128]; // blah blah
        
mysql_format(SQLstr,128,"UPDATE `users` SET `Muted`='1' ,`MutedTime`='%d' WHERE `id` = '%d' LIMIT 1",PlayerData[playerid][MutedTime],PlayerData[playerid][ID]); 
        
mysql_tquery(SQLstr""""); 
        
SendClientMessage(playeridCOLOR_GREY"You have been auto-muted for spamming. You will be unmuted in 20 seconds."); 
    }
    else 
SpamMessages[playerid] = 0;
    return 
1;

place this code at OnPlayerDisconnect
PHP Code:
KillTimer(SpamChecker[playerid]); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)