SA-MP Forums

Go Back   SA-MP Forums > SA-MP Server > Server Support

Reply
 
Thread Tools Display Modes
Old 02/02/2018, 05:15 PM   #1
PepsiCola23
Gangsta
 
Join Date: May 2015
Posts: 681
Reputation: 3
Default mute help anti spam

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.
PepsiCola23 is offline   Reply With Quote
Old 04/02/2018, 05:48 PM   #2
Inn0cent
Huge Clucker
 
Inn0cent's Avatar
 
Join Date: May 2013
Location: Pakistan
Posts: 360
Reputation: 45
Default Re: mute help anti spam

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.

__________________
Inn0cent is offline   Reply With Quote
Old 04/02/2018, 05:55 PM   #3
PepsiCola23
Gangsta
 
Join Date: May 2015
Posts: 681
Reputation: 3
Default Re: mute help anti spam

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
PepsiCola23 is offline   Reply With Quote
Old 04/02/2018, 06:02 PM   #4
Inn0cent
Huge Clucker
 
Inn0cent's Avatar
 
Join Date: May 2013
Location: Pakistan
Posts: 360
Reputation: 45
Default Re: mute help anti spam

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;

__________________
Inn0cent is offline   Reply With Quote
Old 04/02/2018, 06:04 PM   #5
Sew_Sumi
Banned
 
Join Date: Jun 2008
Location: Azerbaijan
Posts: 6,455
Reputation: 525
Default Re: mute help anti spam

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.
Sew_Sumi is offline   Reply With Quote
Old 04/02/2018, 06:06 PM   #6
Inn0cent
Huge Clucker
 
Inn0cent's Avatar
 
Join Date: May 2013
Location: Pakistan
Posts: 360
Reputation: 45
Default Re: mute help anti spam

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.
__________________
Inn0cent is offline   Reply With Quote
Old 04/02/2018, 06:08 PM   #7
RogueDrifter
High-roller
 
RogueDrifter's Avatar
 
Join Date: Dec 2017
Location: SA-MP Drifting world.
Posts: 1,175
Reputation: 351
Default Re: mute help anti spam

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.
__________________

[Github]:Link [Gists]:Link [Forum]:Link [Server]:Link [Discord]:Link


RogueDrifter is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] Zero Admin V3.9 Vip Sys, 5 Admin Levels, Anti JetPack, Anti Spam, Anti Advertisements [y_commands] zero_cool Filterscripts 19 19/02/2018 10:08 AM
Anti Flood/Anti Spam/Anti Database Hack CROSS_Hunter Server Support 3 11/09/2012 08:29 AM
[FilterScript] Spam Prevention System (Anti Spam) Luka P. Filterscripts 9 14/09/2011 01:56 PM
[PEDIDO] Sistema Anti-Flood/Anti-Spam ViCtOr_Mc Português/Portuguese 15 28/08/2011 02:27 PM
[FilterScript] [K.A.S] Knight's Anti Cheat (Anti: Armas, Spam, DB, MaxPing, Palavrões, Money Hack) The Knight Lançamentos/Releases 5 05/05/2011 04:41 AM


All times are GMT. The time now is 03:58 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.