Thread: Don't say IPs
View Single Post
guipatinador
SourceMod Donner Party
Join Date: Oct 2009
Location: Poortugal
Old 06-18-2012 , 14:37   Re: Don't say IPs
Reply With Quote #73

Astro i think you should add admin immunity

PHP Code:
/*
Copyleft 2005
Plugin topic: http://www.amxmodx.org/forums/viewtopic.php?p=90172


Don't say IPs
=============
Messages like "hey join my server 213.34.231.23" are automatically blocked... and another message is printed instead. :-P
Or, you can choose to just ban violators by setting cvar ip_banviolators to 1 and ip_banminutes to how many minutes the violator should be banned. 0 is permanent, 5 is default.

/JGHG


VERSIONS
========
050204    0.1    First version


CREDITS
=======
Requested by lord_inuyasha88.
*/

#include <amxmodx>
#include <regex>

#define PLUGINNAME    "Don't say IPs"
#define VERSION        "0.1"
#define AUTHOR        "JGHG"

#define PATTERN                "(?:(?:2\s*5\s*[0-5]|2\s*[0-4]\s*[0-9]|1\s*[0-9]\s*[0-9]|[1-9]?\s*[0-9])\s*\.\s*){3}(?:2\s*5\s*[0-5]|2\s*[0-4]\s*[0-9]|1\s*[0-9]\s*[0-9]|[1-9]?\s*[0-9])"

//#define PRINTTOALL
#define MESSAGE "[DIP] Your message contained IP address and was blocked."

#define ADMINLEVEL ADMIN_IMMUNITY // change this if you want. More info http://www.amxmodx.org/funcwiki.php?go=module&id=1

// Variables
new iResultRegex:hPatterniReturnValueszError[64], szAllArgs[1024],  iSayTextszMessage[256];

#if defined PRINTTOALL
new iCount 1iPlayers[32]
#endif

public plugin_modules() 

    
require_module("regex");
}

public 
hook_say(idlevelcid
{
    if(!(
get_user_flags(id) & ADMINLEVEL))
    {
        
read_args(szAllArgs1023);
        
        
iResult regex_match_c(szAllArgshPatterniReturnValue);
        
        switch (
iResult
        {
            case 
REGEX_MATCH_FAIL
            {
                
log_amx("REGEX_MATCH_FAIL! %s"szError);
                return 
PLUGIN_CONTINUE;
            }
            case 
REGEX_PATTERN_FAIL
            {
                
log_amx("REGEX_PATTERN_FAIL! %s"szError);
                return 
PLUGIN_CONTINUE;
            }
            case 
REGEX_NO_MATCH
            {
                return 
PLUGIN_CONTINUE;
            }
            default:{
                
szMessage[0] = 0x04;
                
format(szMessage[1], 251MESSAGE);
                
szMessage[192] = '^0';
                
                
#if defined PRINTTOALL
                
get_players(iPlayersiCount"ch");
                
                for (new 
0iCounti++)
                {
                    if (
is_user_connected(iPlayers[i]))
                    {
                        
message_begin(MSG_ONE_UNRELIABLEiSayText_iPlayers[i]);
                        
write_byte(iPlayers[i]);
                        
write_string(szMessage);
                        
message_end();
                    }
                }
                
#else
                
message_begin(MSG_ONEiSayText_id);
                
write_byte(id);
                
write_string(szMessage);
                
message_end();
                
#endif
                
                
return PLUGIN_HANDLED;
            }
        }
    }
    return 
PLUGIN_CONTINUE
}

public 
plugin_init() 
{
    
register_plugin(PLUGINNAMEVERSIONAUTHOR);
    
    
register_clcmd("say""hook_say");
    
register_clcmd("say_team""hook_say");
    
    
register_dictionary("admincmd.txt");
    
    
iSayText get_user_msgid("SayText");
    
    
hPattern regex_compile(PATTERNiReturnValueszError63"i");
}

public 
plugin_end() {
    
regex_free(hPattern);   

You can change admin level here:
PHP Code:
#define ADMINLEVEL ADMIN_IMMUNITY 
__________________
PM for help = ignore

Last edited by guipatinador; 06-18-2012 at 16:46.
guipatinador is offline