BadNames Detector

Сообщения
2,713
Реакции
2,995
Помог
59 раз(а)
Пользователь wopox1337 разместил новый ресурс:

BadNames Detector - Игрокам с не допустимыми именами блокируется чат и микрофон.

Плагин ограничит в общении игроков, имеющих стандартный никнейм (Strikes, etc...). Список никнеймов указывается в конфигурационном файле, BadNames.ini. Лёгок в работе.
Узнать больше об этом ресурсе...
 
Сообщения
30
Реакции
3
Good work wopox1337, thank you for sharing it with us. "Спасибо"

Found litle problem with adminchat.amxx plugins /teamsay@
 

Вложения

Сообщения
263
Реакции
335
Помог
4 раз(а)
wopox1337, А регулярки скушает?)))
Код:
(?i)^(\(\d+\)|)Strikes$
(?i)^Strikes$
 
Сообщения
2,713
Реакции
2,995
Помог
59 раз(а)
SonG, Если научить - то съест запросто =).
Возможно fantom подскажет, как научить.
11 Май 2017
Georgi-Arts, Поместите плагин BadNames_detector.amxx выше adminchat.amxx
 
Сообщения
70
Реакции
22
Так что там с регулярками-то? Нет желания обновить плагин? Есть одна гадина. Заходит под ником VALVE-MS или VAlVE - MS и т.д. и звук в чат противный издает со свистом.
 
Сообщения
70
Реакции
22
fire-dance, а если он добавит к нику "com", или 458, или lol . Например так steamboost_valve-ms_lolll
 
Сообщения
70
Реакции
22
fire-dance, жди в гости примерно такие SteamBoost [ VALVE-MS RU ] , Steam Boost [ VALVE-MS RU ] , BoostSteam [VALVE-MS RU]
 
Сообщения
957
Реакции
1,184
Помог
52 раз(а)
Для тех кто хочет юзать регулярки (в файл вместо имен писать регулярные выражения):
Код:
/*
        Плагин: Bad Name Detector
        Автор: wopox1337
        Описание: Игрокам с не допустимыми именами блокируется чат и микрофон.
            Имена берутся из файла '/amxmodx/configs/BadNames.ini"
        
        Квары: badname_punishtype [a|b|ab]
                a - блокировать микрофон;
                b - блокировать чат;
*/

new const BADNAME_CONFIG[] = "/BadNames.ini";

#include <amxmodx>
#include <engine>
#include <regex>

new const VERSION[] = "0.0.3a";
const MAX_REGEX_LENGTH    = 200;

new Array:g_aBadNames, g_iBadNamesSize;
new g_bitBlockFlags;

enum
{
    BLOCK_VOICE        =    (1<<0),
    BLOCK_CHAT        =    (1<<1)
}

new g_bPunishedChatPlayers;

#define get_bit(%1,%2)        (%1 & (1 << (%2 & 31)))
#define set_bit(%1,%2)        (%1 |= (1 << (%2 & 31)))
#define reset_bit(%1,%2)    (%1 &= ~(1 << (%2 & 31)))

    //Thanks to Vaqtincha for this macros
#define ContainWord(%1,%2)             (containi(%1,%2) != -1)

new g_iMsgId_SendAudio;

public plugin_init()
{
    register_plugin("Bad Name Detector", VERSION, "wopox1337");
    register_cvar("badname_detector", VERSION, FCVAR_SERVER | FCVAR_SPONLY);
    
    register_cvar("badname_punishtype", "ab");
    
    new szCvarString[3];
    get_cvar_string("badname_punishtype", szCvarString, charsmax(szCvarString))
    
    if(ContainWord(szCvarString, "a"))
    {
        g_bitBlockFlags |= BLOCK_VOICE
    }
    if(ContainWord(szCvarString, "b"))
    {
        g_bitBlockFlags |= BLOCK_CHAT
        
        register_clcmd("say",        "hCommand_Say");
        register_clcmd("say_team",    "hCommand_Say");
        
        g_iMsgId_SendAudio = get_user_msgid("SendAudio");
    }
    
    if(!g_bitBlockFlags)
    {
        set_fail_state("CVar badname_punishtype = '' (empty), plugin stopped!");
    }

    g_aBadNames = ArrayCreate(MAX_REGEX_LENGTH);
}

public plugin_cfg()
{
    new szFileName[128], iFilePointer;
    get_localinfo("amxx_configsdir", szFileName, charsmax(szFileName));
    add(szFileName, charsmax(szFileName), BADNAME_CONFIG);
    
    iFilePointer = fopen(szFileName, "rt");
    if(!iFilePointer)
    {
        set_fail_state("Config file '%s' not loaded!", szFileName);
    }

    new szLine[MAX_REGEX_LENGTH];
    while(!feof(iFilePointer))
    {
        fgets(iFilePointer, szLine, charsmax(szLine));
        trim(szLine);

        if(!szLine[0] || szLine[0] == ';')
        {
            continue;
        }
        
        ArrayPushString(g_aBadNames, szLine);
    }
    fclose(iFilePointer);

    g_iBadNamesSize = ArraySize(g_aBadNames);
    if(!g_iBadNamesSize)
    {
        set_fail_state("Names are not found in the file '%s'!", szFileName);
    }
}

public client_infochanged(pPlayerId)
{
    if(!is_user_connected(pPlayerId) || is_user_bot(pPlayerId) || is_user_hltv(pPlayerId))
    {
        return PLUGIN_CONTINUE;
    }

    CheckNickname(pPlayerId);

    return PLUGIN_CONTINUE;
}

public CheckNickname(pPlayerId)
{
    new szNewName[MAX_NAME_LENGTH], szOldName[MAX_NAME_LENGTH];

    get_user_name(pPlayerId, szOldName, charsmax(szOldName));
    get_user_info(pPlayerId, "name", szNewName, charsmax(szNewName));

    if(equal(szNewName, szOldName))
    {
        return PLUGIN_CONTINUE;
    }

    for(new i, reg_expr[MAX_REGEX_LENGTH]; i < g_iBadNamesSize; i++)
    {
        ArrayGetString(g_aBadNames, i, reg_expr, charsmax(reg_expr));

        if(regex_match_simple(szNewName, reg_expr) > 0)
        {
            Get_PunishPlayer(pPlayerId, szNewName);
            return PLUGIN_CONTINUE;
        }
    }
    Reset_PunishBits(pPlayerId);

    return PLUGIN_CONTINUE;
}

public client_disconnected(pPlayerId)
{
    reset_bit(g_bPunishedChatPlayers, pPlayerId);
}

public hCommand_Say(pPlayerId)
{
    if(get_bit(g_bPunishedChatPlayers, pPlayerId))
    {
        client_print(pPlayerId, print_chat, "[BLOCKED] Ваш чат заблокирован! Смените ник со стандартного для разблокировки чата!");
        SendAudio(pPlayerId, "sound/buttons/blip1.wav");
        
        return PLUGIN_HANDLED;
    }

    return PLUGIN_CONTINUE;
}

public Get_PunishPlayer(pPlayerId, const szPlayerName[])
{
    if(g_bitBlockFlags & BLOCK_VOICE)
    {
        set_speak(pPlayerId, SPEAK_MUTED);
    }
    if(g_bitBlockFlags & BLOCK_CHAT)
    {
        set_bit(g_bPunishedChatPlayers, pPlayerId);
    }

    set_task(5.0, "task_ShowMessage", pPlayerId);
    
    // Логирование (temp)
    log_to_file("BadNames_Detected.log", "Player: '%s'", szPlayerName);
}

public task_ShowMessage(pPlayerId)
{
    if(!is_user_connected(pPlayerId))
    {
        return PLUGIN_HANDLED;
    }
    
    set_hudmessage(.red = 255, .x = 0.4, .y = -1.0, .effects = 1, .fxtime = 3.0, .holdtime = 5.0);
    show_hudmessage(pPlayerId, "Вам заблокирован доступ к чату^nсмените ник для разблокировки!");
    
    return PLUGIN_CONTINUE;
}

public plugin_end()
{
    ArrayDestroy(g_aBadNames);
}

Reset_PunishBits(pPlayerId)
{
    reset_bit(g_bPunishedChatPlayers, pPlayerId);
    set_speak(pPlayerId, SPEAK_ALL);
}

stock SendAudio(pPlayerId, const szDirSound[])
{
   message_begin(MSG_ONE_UNRELIABLE, g_iMsgId_SendAudio, .player = pPlayerId);
   write_byte(pPlayerId);
   write_string(szDirSound);
   write_short(PITCH_NORM);
   message_end();
}
 
Сообщения
957
Реакции
1,184
Помог
52 раз(а)
marisantas, По хорошему надо еще бы компиляцию паттернов сделать и ложить в массив, но признаюсь честно - лень) Если у кого будет жедание может доделать)
 

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу