mute help anti spam
#1

PHP Code:
    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.");     
        
SpamTimes[playerid] = 0;
        return 
0;   
    }  
    } else return 
SpamTimes[playerid] = 0
the problem is,i wanted to make if he writes messages too fast he`ll eventually get muted at the fifth message.

the problem is you get muted even if you write 5 messages with 1 hours between them.
Reply
#2

You have to check the time difference between the player messages. Before performing your code.

You can do that by using gettime(); statement.

For example whenever player send message to chat, store the time in some variable like, time[playerid] = gettime();
and when the player sends the message again, run a code where you check the time difference between his/her messages using

new time_new = time[playerid] - gettime();

time_new will store the time difference between the player last message, could be 2 or 3.

Like,

PHP Code:
if(time_new == 2// Means the difference between the player messages is 2 seconds. Means he has sent the message 2 seconds later from his the last message he sent.
{
        
// Your Code.

Reply
#3

PHP Code:
SpamCheck[playerid] = gettime();
    if(
gettime() - 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.");     
        
SpamTimes[playerid] = 0;
        return 
0;   
    }  
    } else 
SpamTimes[playerid] = 0
tried this,still didnt work
Reply
#4

Try this,

Code:
if(SpamCheckT(playerid, 2) == 1)
{  
	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.");      
		SpamTimes[playerid] = 0; 
		return 0;    
	}   
} else SpamTimes[playerid] = 0;
Add this somewhere in your script
PHP Code:
stock SpamCheckT(playeridtime)
{
    new 
time_spam gettime() - SpamCheck[playerid];
    if(
time_spam time) return 1;
    
SpamCheck[playerid] = gettime();
    return 
0;

Reply
#5

Code:
SpamCheck[playerid] = gettime(); 
if(gettime() - SpamCheck[playerid] < 1000 && SpamCheck[playerid] != 0)
If this is where these 2 lines are, then of course it's going to mute as it's setting SpamCheck to gettime, then checking the time which is going to be very much equal, and then it'll mute.

Also, unless you are actually making the player muted permanently, and not for 5 minutes, it's almost a waste to commit that to the DB, unless they log whilst muted, in which case that would be an idea to track the mute.
Reply
#6

Quote:
Originally Posted by Sew_Sumi
View Post
Code:
SpamCheck[playerid] = gettime(); 
if(gettime() - SpamCheck[playerid] < 1000 && SpamCheck[playerid] != 0)
If this is where these 2 lines are, then of course it's going to mute as it's setting SpamCheck to gettime, then checking the time which is going to be very much equal, and then it'll mute.
Yeah, I think thats because of me, I did some wrong explanations above.
Reply
#7

use gettick, like so:
PHP Code:
new TextTickOne[MAX_PLAYERS];
new 
TextTickTwo[MAX_PLAYERS];
#define MAX_WAIT_TIME 500 //max waiting time in MS (half a second here)
public OnPlayerText(playeridtext[])
{
    if(
TextTickTwo[playerid] == && TextTickOne[playerid] ==TextTickOne[playerid] = GetTickCount();
    else if(
TextTickOne[playerid] != && TextTickTwo[playerid] == 0TextTickTwo[playerid] = GetTickCount();
    else if(
TextTickOne[playerid] != && TextTickTwo[playerid] != && TextTickTwo[playerid] - TextTickOne[playerid] < MAX_WAIT_TIME)
    {
        
SendClientMessage(playerid, -1" Hi, stop spamming you asshole");
        
TextTickOne[playerid] = 0;
        
TextTickTwo[playerid] = 0;
        return 
0;
        }
    else  if(
TextTickOne[playerid] != && TextTickTwo[playerid] != && TextTickTwo[playerid] - TextTickOne[playerid] >= MAX_WAIT_TIME)
        {
            
TextTickOne[playerid] =0;
            
TextTickTwo[playerid] =0;
            }
    return 
1;
}
public 
OnPlayerDisconnect(playeridreason)
{
    
TextTickOne[playerid] =0;
    
TextTickTwo[playerid] =0;
    return 
1;

EDIT: wew too many ppl commented while i was writing this, welp anyway if their way works go for it and ignore mine, goodluck, if you want me to explain any parts of my code above please tell me here or in PM.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)