View Single Post
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 08-05-2019 , 12:15   Re: Block IP Pattern (With Spaces)
Reply With Quote #10

Code:
#include <amxmodx> #include <regex> #define PATTERN "(\d.*){8}" new whitelist[][] = {     "123.456.789.101:27099",     "123.456.789.101",     "yeah" } new Regex:re, ret; public plugin_init(){     register_clcmd("say", "clcmd_say");     register_clcmd("say_team", "clcmd_say");         new err[32];     re = regex_compile(PATTERN, ret, err, 31, "i");     if (re!=REGEX_OK) log_amx("Error: %s (%d)", err, ret); } public plugin_end() {     regex_free(re);    } public clcmd_say(id){     new arg[64], bool: whitestlist;     read_args(arg, charsmax(arg));         remove_quotes(arg);     trim(arg);         for (new i = 0; i < sizeof(whitelist); i++){         if (contain(arg, whitelist[i])){             whitestlist = true;             break;         }     }         if (strlen(arg) > 7 && !whitestlist){         new match = regex_match_c(arg, re, ret);         if (match > 0){             client_print(id, print_chat, "More digits are not allowed in a single message to avoid IP spam.")             return PLUGIN_HANDLED;         }     }     return PLUGIN_CONTINUE; }
__________________

Last edited by Relaxing; 08-05-2019 at 12:17.
Relaxing is offline