Re: Don't say IPs
PHP Code:
#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])"
will match 1 2 3 . 1 2 3 . 1 2 3 . 1 2 3, 123.123.123.123, 1 23. 12 3 . 1 2 3 .1 23 etc. :)
Eventually you could use my editted version. It checks say and say_team (the original plugin doesn't), blocks the message completely and prints informational message in green to spammer only.
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."
// Variables new iResult, Regex:hPattern, iReturnValue, szError[64], szAllArgs[1024], iSayText, szMessage[256];
#if defined PRINTTOALL new iCount = 1, iPlayers[32] #endif
public plugin_modules() { require_module("regex"); }
public hook_say(id, level, cid) { read_args(szAllArgs, 1023); iResult = regex_match_c(szAllArgs, hPattern, iReturnValue); 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], 251, MESSAGE); szMessage[192] = '^0'; #if defined PRINTTOALL get_players(iPlayers, iCount, "ch"); for (new i = 0; i < iCount; i++) { if (is_user_connected(iPlayers[i])) { message_begin(MSG_ONE_UNRELIABLE, iSayText, _, iPlayers[i]); write_byte(iPlayers[i]); write_string(szMessage); message_end(); } } #else message_begin(MSG_ONE, iSayText, _, id); write_byte(id); write_string(szMessage); message_end(); #endif return PLUGIN_HANDLED; } } return PLUGIN_CONTINUE; }
public plugin_init() { register_plugin(PLUGINNAME, VERSION, AUTHOR); register_clcmd("say", "hook_say"); register_clcmd("say_team", "hook_say"); register_dictionary("admincmd.txt"); iSayText = get_user_msgid("SayText"); hPattern = regex_compile(PATTERN, iReturnValue, szError, 63, "i"); }
public plugin_end() { regex_free(hPattern); }
EDIT:
Quote:
Originally Posted by Danidude
Hey can u edit ur pluin in which the message is shown to everyone?
|
PHP Code:
//Find and uncomment PRINTTOALL = remove // before #define PRINTTOALL
|