Raised This Month: $51 Target: $400
 12% 

advanced chat protection


Post New Thread Reply   
 
Thread Tools Display Modes
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 06-30-2016 , 03:18   Re: Bmp
Reply With Quote #11

Updateeeeee.
Craxor is offline
Send a message via ICQ to Craxor
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 06-02-2017 , 17:43   Re: Bmp
Reply With Quote #12

Just for the sake of time i've made another verison of this plugin, much better coded than all plugins, but i don't wanne post as an official big plugin or something else because i don't wanne continue support it, here's the code:

PHP Code:
const MAX_PLAYERS_NUM 32;
#define cm(%0) ( sizeof(%0) - 1 )

#include <amxmodx>

#pragma semicolon 1

new const gWarnMessage[ ]    =    "You have been detected for spam, please don't try again or you will be punished!";
new const 
gBlockedWord[ ]    =    "You have been detected for using an illegal word!";

new const 
HUD_KICK_MESSAGE[ ]    =    "You are gonna be KICKED for chat-spamming!";
new const 
HUD_BAN_MESSAGE [ ]    =    "You are gonna be BANNED for chat-spamming!";


new 
gLastUserMessage[MAX_PLAYERS_NUM 1][192];
new 
gBlockTimes[MAX_PLAYERS_NUM 1];
new 
Float:g_FloodingMAX_PLAYERS_NUM 1] = { 0.0, ... };
new 
g_FloodMAX_PLAYERS_NUM 1] = {0, ...};
new Array:
g_Stroke Invalid_Array;


new 
g_iPunishTypegUseLoggBlockTimesCvgFloodTime;

public 
plugin_init( )
{
    
register_plugin"chat protection""1.0""craxor" );
 
    
register_clcmd"say""hook_say" );
    
register_clcmd"say_team""hook_say" );

    
g_iPunishType register_cvar"acp_punish_type" "1"  );
    
gUseLog register_cvar"acp_log""1" );
    
gBlockTimesCv register_cvar"acp_warns""3" );
    
gFloodTime register_cvar"acp_flood_time""0.75" );
}


public 
client_putinserverid 
{
    
gLastUserMessage[id][0] = EOS;
    
gBlockTimesid ] = 0;
    
g_Floodid ] = 0;
    
g_Floodingid ] = 0.0;
}

public 
hook_sayid )
{
    static 
Stroke[64], Size 0;
    new 
UserMessage192 ], szUserName32 ]; 

    new 
Float:MAXCHAT get_pcvar_floatgFloodTime );
    new 
Float:nexTime get_gametime();

    
read_argsUserMessagecmUserMessage ) );
    
get_user_nameidszUserNamecmszUserName ) );


    
/*    Here will detect for blocked words. */
    
if( ArraySize(g_Stroke) )
    {    
        for (
Size 0Size ArraySize(g_Stroke); Size++)
        {
            
ArrayGetString(g_StrokeSizeStrokecharsmax(Stroke));
        
            if (
containi(UserMessageStroke) != -1)
            {
                
client_printidprint_chatgBlockedWord );

                if( 
get_pcvar_numgUseLog ) > 
                {
                    new 
szBuffer64 ];
                    
formatexszBuffer63" (  [AMXX] %s: %s  )"szUserNameUserMessage );
        
                    
log_to_file"addons/amxmodx/logs/AdvancedChatProtectionLogs.txt"szBuffer );
                }
        
                return 
PLUGIN_HANDLED;
            }

        }
    }

    
/*    Here will check for the words if is the same the previous one OR if interval between message are too shourt    */
    
if( equaliUserMessagegLastUserMessage[id] ) || g_Flooding[id] > nexTime )
    {        
        
client_printidprint_chatgWarnMessage );

        if( 
g_Flood[id] >= )
        {
            
g_Flooding[id] = nexTime MAXCHAT 3.0;
            
gBlockTimesid ] = get_pcvar_numgBlockTimesCv ) + 1;
        }
        
        
g_Flood[id]++;
        
gBlockTimesid ]++;

        if( 
gBlockTimesid ] > get_pcvar_numgBlockTimesCv ) )
        {
            
show_motdidget_pcvar_numg_iPunishType ) ? HUD_BAN_MESSAGE HUD_KICK_MESSAGE );

            
gBlockTimesid ] = 0;
            
clamp(get_pcvar_numg_iPunishType ), 01);
        
            
set_task4.2"DoThePunish"id );    
        }


        if( 
get_pcvar_numgUseLog ) > 
        {
            new 
szBuffer64 ];
            
formatexszBuffer63" (  [AMXX] %s: %s  )"szUserNameUserMessage );

            
log_to_file"addons/amxmodx/logs/AdvancedChatProtectionLogs.txt"szBuffer );
        }
        return 
PLUGIN_HANDLED;

        
    }

    else
    {
        
gBlockTimesid ] = 0;
        
g_Flooding[id] = nexTime MAXCHAT;

        if( 
UserMessage[0] != EOS 
            
copygLastUserMessage[id], charsmaxgLastUserMessage[] ), UserMessage );

        return 
PLUGIN_CONTINUE;    
    }
    return 
PLUGIN_CONTINUE;
}

public 
plugin_cfg( )
{
    static 
File 0Buffer[64], Location[256];
    
    
g_Stroke ArrayCreate(64 /* maximum length */);
    
    
get_localinfo("amxx_configsdir"Locationcharsmax(Location));
    
    
add(Locationcharsmax(Location), "/AcpWords.ini ");
    
    if (!
file_exists(Location))
    {
        
File fopen(Location"w+" /* write file */);
        
        if (
File)
        {
            
fclose(File);
        }
    }
    
    
File fopen(Location"rt" /* read file as text */);
    
    if (
File)
    {
        while (!
feof(File))
        {
            
fgets(FileBuffercharsmax(Buffer));
            
            
trim(Buffer);
            
            if (!
strlen(Buffer) || Buffer[0] == ';')
            {
                continue;
            }
            
            
ArrayPushString(g_StrokeBuffer);
        }
        
        
fclose(File);
    }
}


public 
DoThePunishid )
{
    new 
szName[32];
    
get_user_nameidszNamecharsmaxszName ) );

    switch( 
get_pcvar_numg_iPunishType ) )
    {
        case 
0server_cmd"amx_kick %s" szName );
        case 
1server_cmd"amx_banip %s 999"szName);
    }
    

Features:

- > Check interval between the messages like antiflood.amxx
- > Check the mesages if they are the same for blocking bind messages (as bmp do).
- > Check for some words and block the entire phrase ( from an .ini folder ).
__________________
Project: Among Us

Last edited by Craxor; 06-02-2017 at 17:48.
Craxor is offline
Send a message via ICQ to Craxor
Reply



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

Forum Jump


All times are GMT -4. The time now is 00:37.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode