Acest plugin blochează ip-urile în nick-uri, dar și în chat.

 

Spoiler

#include <amxmodx>
#include <regex>

/*
const PATH_STRLEN = 96;
new szMsg[128], szTime[32], szFile[PATH_STRLEN + 14], pFile,g_szLogsDir[PATH_STRLEN]
*/

new Regex:g_rPattern, g_iRegexReturn,szName[32],szError[2],szAuthId[65], szIp[32], iUserId;

public plugin_init() {
    register_plugin("Spambot kicker", "0.1", "Subb98");

    if((g_rPattern = regex_compile("((?:\s*\d+\s*\.){3})|(.ru)|(.ua)|(.su)|(.com)|(.net)|(.kz)", g_iRegexReturn, szError, charsmax(szError))) < REGEX_OK) {
        regex_free(g_rPattern);
        set_fail_state("Regex compile error");
    }

    /*get_localinfo("amxx_logs", g_szLogsDir, charsmax(g_szLogsDir));
    add(g_szLogsDir, charsmax(g_szLogsDir), "/spambot_kicker");
    if(!dir_exists(g_szLogsDir)) {
        mkdir(g_szLogsDir);
    }*/
}

public client_authorized(id) {
    get_user_name(id, szName, charsmax(szName));
    if(regex_match_c(szName, g_rPattern, g_iRegexReturn)) {
        iUserId = get_user_userid(id);
        get_user_authid(id, szAuthId, charsmax(szAuthId));
        get_user_ip(id, szIp, charsmax(szIp),1);
        server_cmd("kick #%d ^"Advertising in name^"", iUserId);
        //Logging("#%d %s <%s> [%s] has been kicked", iUserId, szName, szAuthId, szIp);
    }
}

public client_infochanged(id)
{
    get_user_name(id, szName, charsmax(szName));
    if(regex_match_c(szName, g_rPattern, g_iRegexReturn)) {
        iUserId = get_user_userid(id);
        get_user_authid(id, szAuthId, charsmax(szAuthId));
        get_user_ip(id, szIp, charsmax(szIp),1);
        server_cmd("kick #%d ^"Advertising in name^"", iUserId);
        //Logging("#%d %s <%s> [%s] has been kicked", iUserId, szName, szAuthId, szIp);
    }
}

Logging(const szMessage[], any:...) {
    vformat(szMsg, charsmax(szMsg), szMessage, 2);
    get_time("%Y%m%d.log", szTime, charsmax(szTime));
    formatex(szFile, charsmax(szFile), "%s/%s", g_szLogsDir, szTime);
    pFile = fopen(szFile, "at");
    get_time("%Y/%m/%d - %H:%M:%S", szTime, charsmax(szTime));
    fprintf(pFile, "%s: %s^n", szTime, szMsg);
    fclose(pFile);
}