Сompiler Ошибки при компиляции Ultimate Chats Control

Izmayl7

Пользователь
Регистрация
9 Июн 2017
Сообщения
527
Симпатии
103
Пол
Мужской
Amx Mod X
AMXX 1.8.2
Ошибка
Код:
//AMXXPC compile.exe
// by the AMX Mod X Dev Team


//// amx_gag2511.sma
// C:\Users\Home\Desktop\amxmodx\scripting\amx_gag2511.sma(295) : warning 213: t
ag mismatch
// C:\Users\Home\Desktop\amxmodx\scripting\amx_gag2511.sma(301) : warning 213: t
ag mismatch
// C:\Users\Home\Desktop\amxmodx\scripting\amx_gag2511.sma(426) : warning 213: t
ag mismatch
// C:\Users\Home\Desktop\amxmodx\scripting\amx_gag2511.sma(456) : warning 213: t
ag mismatch
// C:\Users\Home\Desktop\amxmodx\scripting\amx_gag2511.sma(797) : warning 213: t
ag mismatch
// C:\Users\Home\Desktop\amxmodx\scripting\amx_gag2511.sma(985) : warning 213: t
ag mismatch
// Header size: 2044 bytes
// Code size: 29316 bytes
// Data size: 51276 bytes
// Stack/heap size: 16384 bytes; max. usage is unknown, due to recursion
// Total requirements: 99020 bytes
//
// 6 Warnings.
// Done.
//
// Compilation Time: 0,52 sec
// ----------------------------------------

Press enter to exit ...
Исходник
Код:
C++:
#include <amxmodx>
#include <sqlx>
#tryinclude <reapi>
const REASON_LENGTH = 64;

#define DB_HOST ""     // MySQL Host
#define DB_USER ""        // MySQL User
#define DB_PASS ""        // MySQL Password
#define DB_NAME ""        // MySQL Name

#define CLEAR_PERIOD 30        // Через сколько дней удалять истекшие GAG'и из MySQL

#define SORRY                // Разрешить команду /sorry для извинения игроков
#define MUTEMENU            // Поддержка команды /mute
#define GAG_ACCESS    ADMIN_BAN     // Доступ к функциям гага
#define SORRYTIME     60        // Как часто можно пользоваться командой /sorry. Время в секундах
#define PREFIX        "Gag"         // Префикс в чате
#define SUPERADMIN    ADMIN_RCON    
    // * Админ с флагом L может гагать других админов с иммунитетом
    // * Админ с флагом L может снимать все гаги
    // * Админ без этого флага не сможет снимать чужие гаги
    // *** Если не требуется - закомментируйте ***

#define CHATS_BY_STATS            // Включает функции блокировки чата игрокам, которые не набрали N фрагов/опыта на сервере
    #define VOICE_CONTROL_BY_STATS 0
        // 0 - CSX
        // 1 - CSSTATS MYSQL by SKAJIbnEJIb
        // 2 - CSSTATSX SQL by serfreeman1337
        // 3 - AES 0.5 Vega by serfreeman1337
    #define BLOCK_TEXT_CHAT_BY_STATS
        // Блокировать текстовый чат и голосовой
        // Если закомментировано - блокировуется только голос
#define BLOCK_CHATS_INFO
    // Выводит в текстовый чат сообщение о том, что чат/чаты для игрока заблокированы
#define DEFAULT_BLOCK_TYPE TEXT_CHAT
    // Как по умолчанию GAG'ать 
    // TEXT_CHAT
    // VOICE_CHAT
    // ALL_CHATS
const MIN_FRAGS = 20;
    // Минимальное количество фрагов для доступа к микро
    // Для VOICE_CONTROL_BY_STATS 3 настройка принимает значение ранга юзера(начиная с 1)
const ADMIN_FLAG = ADMIN_IMMUNITY|ADMIN_LEVEL_G;
    // Флаг доступа, для которого не будут работать функции CHATS_BY_STATS
    
new g_BlockTimes[] =     // Время блокировки GAG в минутах
{
    5,
    10,
    15,
    30,
    60,
    180,
    1440,
    0 // навсегда
}

new g_BlockTypes[3][] = // Названия пунктов для блокировки
{
    "Чат",
    "Микрофон",
    "Чат+микрофон"
}

new g_Reasons[][REASON_LENGTH] = // Причины GAG'ов
{
    "Неадекват",
    "Микрофон 18+",
    "Оскорбления",
    "Флуд"
}

new g_AllowCommands[][] = // Разрешенные команды
{
      "/top15",
      "/rs",
      "/rank",
      "/mute",
      "/maps",
      "/vipmenu",
      "/menu",
      "/voteban",
      "/stuck",
      "/spec",
      "/hats",
      "/csmshop",
      "/shop",
      "/rankstats",
      "/tm",
      "/rtv",
      "/guns",
      "/hot",
      "/stats",
      "/timeleft",
      "/thetime"   
}

/* Словарь плагина */
#define MSG_SORRY_FLOOD     "^1[^4%s^1] Прекратите ^4флудить^1! Повторно ^4извиниться ^1можно через ^4%d ^1сек"
#define MSG_SORRY_ADMIN     "^1[^4%s^1] Уважаемый ^3Адмнистратор^1, игрок ^3%s ^1просит ^4снять ^1с него [^4Gag^1]. Причина Gаg'a: ^3%s"
#define MSG_CHAT_IS_BLOCKED     "^1[^4%s^1] ^3%s^1, ваш ^3чат ^4заблокирован^1! Причина: ^3%s"
#define MSG_BLOCK_EXPIRED_TIME     "^1[^4%s^1] До разблокировки ^4осталось ^1примерно ^3%d ^4мин."
#define MSG_BLOCK_EXPIRED     "^1[^4%s^1] Время ^4блокировки ^3истекло^1. Подождите!"
#define MSG_SAY_SORRY         "^1[^4%s^1] Чтобы ^4извиниться^1, ^3напишите ^1в чат ^3/sorry^1. ^1Возможно, ^4разблокируют ^1раньше!"
#define MSG_CHAT_UNBLOCK_ALL     "^1[^4%s^1] Игроку ^4%s ^1был разблокирован ^3чат ^1Администратором: ^4%s"
#define MSG_CHAT_UNBLOCK_PL     "^1[^4%s^1] ^3%s^1, ^4Администратор: ^3%s ^4снял ^1с ^3Вас ^4блокировку ^3чата"

#define MSG_TEXTCHAT_BLOCK_ALL     "^1[^4%s^1] Администратор: ^4%s ^1заблокировал ^4Чат ^1игроку: ^3%s ^4%s^1. Причина: ^3%s"
#define MSG_TEXTCHAT_BLOCK_PL     "^1[^4%s^1] ^3%s^1, Администратор: ^3%s ^1заблокировал ^3Вам ^4Чат ^1%s^4. Причина: ^3%s"
#define MSG_VOICECHAT_BLOCK_ALL "^1[^4%s^1] ^4Администратор: ^3%s ^1заблокировал ^4Микрофон ^1игроку: ^3%s ^4%s^1. Причина: ^3%s"
#define MSG_VOICECHAT_BLOCK_PL     "^1[^4%s^1] ^3%s^1, Администратор: ^4%s ^1заблокировал ^3Вам ^4Микрофон ^1%s^4. Причина: ^3%s"
#define MSG_ALLCHATS_BLOCK_ALL    "^1[^4%s^1] Администратор: ^4%s ^1заблокировал ^4Чат+микрофон ^1игроку: ^3%s ^1%s^4. Причина: ^3%s"
#define MSG_ALLCHATS_BLOCK_PL    "^1[^4%s^1] ^3%s^1, Администратор: ^4%s ^1заблокировал Вам ^1Чат+микрофон ^1%s^4. Причина: ^3%s"

#define MSG_MUTE_ALL_PLAYERS     "^1[^4%s^1] Вы ^3установили ^1mute ^4на ^1всех ^4игроков."
#define MSG_UNMUTE_ALL_PLAYERS     "^1[^4%s^1] Вы ^3сняли ^1mute ^4со ^3всех ^4игроков."
#define MSG_UNMUTE_PLAYER     "^1[^4%s^1] Вы ^3сняли ^1mute ^4с ^3игрока ^4%s^1."
#define MSG_MUTE_PLAYER     "^1[^4%s^1] Вы ^3установили ^1mute ^4на ^3игрока ^4%s^1."
#define MSG_BLOCK_CHATS0    "^1[^4%s^1] ^1Доступ к чату и микрофону ^3закрыт^4!"
#define MSG_BLOCK_CHATS1    "^1[^4%s^1] ^1Доступ к микрофону ^3закрыт^4!"
#define MSG_BLOCK_CHATS2    "^1[^4%s^1] ^4Необходимо получить уровень ^3%s!"
#define MSG_BLOCK_CHATS3    "^1[^4%s^1] ^4Необходимо набрать ^3%i^1/^3%i ^4фрагов"

/* Технические данные */

#if defined CHATS_BY_STATS && !defined _reapi_included
    #include <hamsandwich>
#endif
enum MENU_SETTINGS
{
    Menu,
    SelectTime,
    SelectReason,
    SelectType,
    Pos
};
enum MENUS
{
    GAG,
    MUTE
};
enum BLOCK_TYPES
{
    NONE = -1,
    STATS,
    TEXT_CHAT,
    VOICE_CHAT,
    ALL_CHATS
}
enum queStates
{
    SQL_INIT,
    DROP_TABLE,
    LOAD_PLAYER,
    SAVE_BLOCK,
    REMOVE_BLOCK
};
enum _:BlockInfo
{
    expired,
    reason[REASON_LENGTH],
    admin_steamid[32],
    BLOCK_TYPES:GagBlockType
};

#if !defined MAX_PLAYERS
    const MAX_PLAYERS = 32;
#endif
new Handle:g_hTuple, g_szQuery[1024], g_Data[3];
new g_BlockInfo[MAX_PLAYERS + 1][BlockInfo];
new Trie:g_tAllowCmds;
new pl[MAX_PLAYERS], pnum;
new g_iMutePlayer[MAX_PLAYERS + 1][MAX_PLAYERS + 1];
new g_arrPlayers[MAX_PLAYERS + 1][MAX_PLAYERS];
new g_iMenuInfo[MAX_PLAYERS + 1][MENU_SETTINGS];
#if AMXX_VERSION_NUM < 183
    #include <colorchat>
#endif
#if !defined _reapi_included
    #include <VtcApi>
#endif
#if defined MUTEMENU && !defined _reapi_included
    #include <fakemeta>
#endif
#if defined CHATS_BY_STATS
    #if VOICE_CONTROL_BY_STATS == 0
        #include <csstats>
    #endif
    #if VOICE_CONTROL_BY_STATS == 1
        #include <csstats_mysql>
    #endif
    #if VOICE_CONTROL_BY_STATS == 2
        #include <csstatsx_sql>
    #endif
    #if VOICE_CONTROL_BY_STATS == 3
        #include <aes_v>
    #endif
    #if defined BLOCK_CHATS_INFO
        new g_iFragStats[MAX_PLAYERS + 1]; 
        #if VOICE_CONTROL_BY_STATS == 3
        new g_szAesLevelName[64];
        #endif
    #endif
#endif
#if !defined REAPI_VERSION || REAPI_VERSION < 52145
    #error Needed ReAPI version >= 5.2.0.145
#endif

#define is_blocked_text_chat(%0) (g_BlockInfo[%0][GagBlockType] == TEXT_CHAT || g_BlockInfo[%0][GagBlockType] == ALL_CHATS)
#define is_blocked_voice_chat(%0) (g_BlockInfo[%0][GagBlockType] == VOICE_CHAT || g_BlockInfo[%0][GagBlockType] == ALL_CHATS)

public plugin_natives()
{
    register_native("ucc_is_client_gaged", "native_ucc_is_client_gaged");
    register_native("ucc_set_client_gag", "native_ucc_set_client_gag");
#if defined MUTEMENU    
    register_native("ucc_is_client_muted", "native_ucc_is_client_muted");
    register_native("ucc_set_client_muted", "native_ucc_set_client_muted");
#endif
}

public plugin_init()
{
#define PNAME "Ultimate Chats Control"
#define VERSION "4.6"
#define AUTHOR "neygomon"
    register_plugin(PNAME, VERSION, AUTHOR);
    register_cvar("ucc_version", VERSION, FCVAR_SERVER | FCVAR_SPONLY);
#if defined _reapi_included    
    if(has_vtc())
    {
        register_clcmd("amx_gagmenu", "ClCmdGagMenu");
    #if defined CHATS_BY_STATS
        RegisterHookChain(RG_CBasePlayer_Spawn, "CBasePlayer_Spawn_Post", true);
    #endif
    }
    #if !defined MUTEMENU
    else    set_fail_state("Needed meta plugin VTC [https://my-amxx.ru/threads/257/]");
    #endif
    #if defined MUTEMENU
    RegisterHookChain(RG_CSGameRules_CanPlayerHearPlayer, "CanPlayerHearPlayer_Pre", false);
    #endif
#else
    register_clcmd("amx_gagmenu", "ClCmdGagMenu");
    #if defined CHATS_BY_STATS
        RegisterHam(Ham_Spawn, "player", "CBasePlayer_Spawn_Post", true);
    #endif
#endif
#if defined MUTEMENU
    register_clcmd("say /mute", "ClCmdMuteMenu");
    register_clcmd("say_team /mute", "ClCmdMuteMenu");
    #if !defined _reapi_included
    register_forward(FM_Voice_SetClientListening, "SetClientListening_Pre", false);
    #endif
#endif
#if defined SORRY
    register_clcmd("say /sorry", "SaySorry");
    register_clcmd("say_team /sorry", "SaySorry");
#endif
    register_clcmd("say", "SayChat");
    register_clcmd("say_team", "SayChat");
    
    register_srvcmd("uсc_flush", "SrvCmdFlush");
    
    register_menucmd(register_menuid("UCC Menu"), 1023, "MenuHandler");
    
    set_task(60.0, "CheckBlockedUsers", .flags = "b");
}

public plugin_cfg()
{
    SQL_Init();
#if defined CHATS_BY_STATS && defined BLOCK_CHATS_INFO && VOICE_CONTROL_BY_STATS == 3
    set_task(1.0, "task__aes_get_level_name"); // fucking serfreeman1337. govnocoder
#endif
    g_tAllowCmds = TrieCreate();
    for(new i; i < sizeof g_AllowCommands; ++i)
        TrieSetCell(g_tAllowCmds, g_AllowCommands[i], i);
}
#if defined CHATS_BY_STATS && defined BLOCK_CHATS_INFO && VOICE_CONTROL_BY_STATS == 3
public task__aes_get_level_name()
{
    aes_get_level_name(MIN_FRAGS, g_szAesLevelName, charsmax(g_szAesLevelName), LANG_SERVER);
}
#endif
public client_putinserver(id)
{
    if(is_user_bot(id) || is_user_hltv(id))
        return;
    
    arrayset(g_iMutePlayer[id],      0, sizeof g_iMutePlayer[]);
    g_BlockInfo[id][expired]        = -1;
    g_BlockInfo[id][reason][0]      = EOS;
    g_BlockInfo[id][admin_steamid][0]= EOS;
    g_BlockInfo[id][GagBlockType]       = NONE;
#if defined CHATS_BY_STATS
    if(!get_chats_access(id))
    {
        set_user_block(id, ALL_CHATS);
    #if defined BLOCK_TEXT_CHAT_BY_STATS
        g_BlockInfo[id][GagBlockType] = STATS;
    #endif
    }
#endif
    new szIP[16], szAuth[32];
    get_user_ip(id, szIP, charsmax(szIP), 1);
    get_user_authid(id, szAuth, charsmax(szAuth));
    
    formatex(g_szQuery, charsmax(g_szQuery), 
        "SELECT `expired_time`, `reason`, `admin_steamid`, `block_type` FROM `ucc_gag` WHERE (`ip` = '%s' OR `steamid` = '%s') AND `expired_time` >= '0'", 
            szIP, szAuth
    );

    g_Data[0] = LOAD_PLAYER;
    g_Data[1] = id;
    SQL_ThreadQuery(g_hTuple, "SQL_ThreadsHandler", g_szQuery, g_Data, sizeof(g_Data));
}
#if defined MUTEMENU
    #if defined _reapi_included
    public CanPlayerHearPlayer_Pre(const iReciever, const iSender)
    {
        if(iSender != iReciever)
        {
            if(g_iMutePlayer[iReciever][iSender])
            {
                SetHookChainReturn(ATYPE_INTEGER, false);
                return HC_SUPERCEDE;
            }
        }
        return HC_CONTINUE;
    }
    #else
    public SetClientListening_Pre(iReciever, iSender)
    {
        if(iSender != iReciever)
        {
            if(g_iMutePlayer[iReciever][iSender])
            {    
                engfunc(EngFunc_SetClientListening, iReciever, iSender, false);
                forward_return(FMV_CELL, false);
                return FMRES_SUPERCEDE;
            }    
        }
        return FMRES_IGNORED;
    }
    #endif
#endif
#if defined SORRY
public SaySorry(id)
{
    if(is_blocked_text_chat(id))
    {
        static iFloodTime[MAX_PLAYERS + 1], systime;
        if(iFloodTime[id] > (systime = get_systime()))
            ChatColor(id, 0, MSG_SORRY_FLOOD, PREFIX, iFloodTime[id] - systime);
        else
        {
            new sName[32]; 
            get_user_name(id, sName, charsmax(sName));

            get_players(pl, pnum, "ch");
            for(new i; i < pnum; ++i)
            {
                if(get_user_flags(pl[i]) & GAG_ACCESS)
                    ChatColor(pl[i], 0, MSG_SORRY_ADMIN, PREFIX, sName, g_BlockInfo[id][reason]);
            }

            iFloodTime[id] = systime + SORRYTIME;
        }
    }
    return PLUGIN_HANDLED;
}
#endif
public SayChat(id)
{
#if defined CHATS_BY_STATS && defined BLOCK_TEXT_CHAT_BY_STATS
    if(!is_blocked_text_chat(id) && g_BlockInfo[id][GagBlockType] != STATS)
#else
    if(!is_blocked_text_chat(id))
#endif
        return PLUGIN_CONTINUE;

    new sMessage[128]; 
    read_args(sMessage, charsmax(sMessage));
    remove_quotes(sMessage);

    if(TrieKeyExists(g_tAllowCmds, sMessage))
        return PLUGIN_CONTINUE;    
    else if(is_blocked_text_chat(id))
    {
        new sName[32], ost; 
        get_user_name(id, sName, charsmax(sName));
        ChatColor(id, 0, MSG_CHAT_IS_BLOCKED, PREFIX, sName, g_BlockInfo[id][reason]);
        
        if(g_BlockInfo[id][expired] > 0)
        {
            if((ost = g_BlockInfo[id][expired] - get_systime()) / 60 > 0)
                ChatColor(id, 0, MSG_BLOCK_EXPIRED_TIME, PREFIX, ost / 60);
            else     ChatColor(id, 0, MSG_BLOCK_EXPIRED, PREFIX);
        }
        
        ChatColor(id, 0, MSG_SAY_SORRY, PREFIX);
    }
    #if defined CHATS_BY_STATS && defined BLOCK_CHATS_INFO
    else
    {
        ChatColor(id, 0, MSG_BLOCK_CHATS0, PREFIX);
        #if VOICE_CONTROL_BY_STATS == 3
        ChatColor(id, 0, MSG_BLOCK_CHATS2, PREFIX, g_szAesLevelName);
        #else
        ChatColor(id, 0, MSG_BLOCK_CHATS3, PREFIX, g_iFragStats[id], MIN_FRAGS);
        #endif
    }
    #endif
    return PLUGIN_HANDLED;
}
#if defined CHATS_BY_STATS
public CBasePlayer_Spawn_Post(const id)
{
    if(!is_user_connected(id))    
        return;
    if(get_chats_access(id) && !is_blocked_voice_chat(id))
    {
        VTC_UnmuteClient(id);
    #if defined BLOCK_TEXT_CHAT_BY_STATS
        g_BlockInfo[id][GagBlockType] = (g_BlockInfo[id][GagBlockType] > STATS) ? g_BlockInfo[id][GagBlockType] : NONE;
    #endif
    }
    #if defined BLOCK_CHATS_INFO
    else if(!is_blocked_voice_chat(id))
    {
        #if defined BLOCK_TEXT_CHAT_BY_STATS
        ChatColor(id, 0, MSG_BLOCK_CHATS0, PREFIX);
        #else
        ChatColor(id, 0, MSG_BLOCK_CHATS1, PREFIX);
        #endif
        #if VOICE_CONTROL_BY_STATS == 3
        ChatColor(id, 0, MSG_BLOCK_CHATS2, PREFIX, g_szAesLevelName);
        #else
        ChatColor(id, 0, MSG_BLOCK_CHATS3, PREFIX, g_iFragStats[id], MIN_FRAGS);
        #endif
    }
    #endif
}
#endif
public SrvCmdFlush()
{
    g_Data[0] = DROP_TABLE;
    SQL_ThreadQuery(g_hTuple, "SQL_ThreadsHandler", "TRUNCATE `ucc_gag`", g_Data, sizeof(g_Data));

    for(new id; id < sizeof g_BlockInfo; ++id)
    {
        g_BlockInfo[id][expired]       = -1;
        g_BlockInfo[id][reason][0]     = EOS;
        g_BlockInfo[id][admin_steamid][0]= EOS;
        g_BlockInfo[id][GagBlockType]      = NONE;
    }
    
    log_amx("%s [v: %s][a: %s] flushed all gags", PNAME, VERSION, AUTHOR);
}

public CheckBlockedUsers()
{
    get_players(pl, pnum);    
    for(new i, sys = get_systime(); i < pnum; ++i)
    {
        if(g_BlockInfo[pl[i]][expired] > 0)
        {
            if(sys > g_BlockInfo[pl[i]][expired])
                user_unblock(pl[i]);
        }
    }
}

public ClCmdGagMenu(id)
{
    if(get_user_flags(id) & GAG_ACCESS)
    {
        g_iMenuInfo[id][SelectTime] = 0;
        g_iMenuInfo[id][Pos] = 0;
        g_iMenuInfo[id][Menu] = any:GAG;
        g_iMenuInfo[id][SelectType] = any:DEFAULT_BLOCK_TYPE;
        
        ShowMenu(id, 0);
    }    
    
    return PLUGIN_HANDLED;
}

public ClCmdMuteMenu(id)
{
    g_iMenuInfo[id][Pos] = 0;
    g_iMenuInfo[id][Menu] = any:MUTE;

    ShowMenu(id, 0);
    return PLUGIN_HANDLED;
}

const MENU_ITEMS = 5;
ShowMenu(id, iPos)
{
    new sAuth[25];
    new start, end;
    new iLen, sMenu[512];
    new iKeys = MENU_KEY_0|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8;
    get_players(g_arrPlayers[id], pnum, "ch");
    get_user_authid(id, sAuth, charsmax(sAuth));
    
    start = iPos * MENU_ITEMS; 
    end   = start + MENU_ITEMS;
    
    switch(g_iMenuInfo[id][Menu])
    {
        case GAG: iLen = formatex(sMenu, charsmax(sMenu), "\d[\rAMX Gag\d] \yВыберите игрока\w\R%d/%d^n^n", iPos + 1, (pnum / MENU_ITEMS + ((pnum % MENU_ITEMS) ? 1 : 0)));
        case MUTE:iLen = formatex(sMenu, charsmax(sMenu), "\d[\rMute\d] \yВыберите игрока\w\R%d/%d^n^n", iPos + 1, (pnum / MENU_ITEMS + ((pnum % MENU_ITEMS) ? 1 : 0)));
    }
    
    if(start >= pnum)
        start = iPos = g_iMenuInfo[id][Pos] = 0;
    if(end > pnum)
        end = pnum;
    
    switch(g_iMenuInfo[id][Menu])
    {
        case GAG:
        {
        #if defined SUPERADMIN
            for(new i = start, bool:superadmin = bool:(get_user_flags(id) & SUPERADMIN), sName[32], plr, a; i < end; ++i)
        #else
            for(new i = start, sName[32], plr, a; i < end; ++i)
        #endif
            {
                plr = g_arrPlayers[id][i];
                get_user_name(plr, sName, charsmax(sName));

                if(id == plr)
                    iLen += formatex(sMenu[iLen], charsmax(sMenu) - iLen, "\r%d. \d%s \y[\rЭто Вы\y]^n", ++a, sName);
            #if defined SUPERADMIN        
                else if(!superadmin && get_user_flags(plr) & ADMIN_IMMUNITY)
            #else
                else if(get_user_flags(plr) & ADMIN_IMMUNITY)
            #endif
                    iLen += formatex(sMenu[iLen], charsmax(sMenu) - iLen, "\r%d. \d%s \y[\rImmunity\y]^n", ++a, sName);    
            #if defined CHATS_BY_STATS    
                else if(g_BlockInfo[plr][GagBlockType] == STATS)
                    iLen += formatex(sMenu[iLen], charsmax(sMenu) - iLen, "\r%d. \d%s \y[\rLowStats\y]^n", ++a, sName);
            #endif
                else if(g_BlockInfo[plr][GagBlockType] > NONE)
                {
                #if defined SUPERADMIN
                    if(superadmin || strcmp(g_BlockInfo[plr][admin_steamid], sAuth) == 0)
                    {
                        iKeys |= (1 << a++);
                        iLen += formatex(sMenu[iLen], charsmax(sMenu) - iLen, "\r%d. \w%s \d[\yUngag\d]^n", a, sName);
                    }
                    else    iLen += formatex(sMenu[iLen], charsmax(sMenu) - iLen, "\r%d. \d%s^n", ++a, sName);
                #else
                    iKeys |= (1 << a++);
                    iLen += formatex(sMenu[iLen], charsmax(sMenu) - iLen, "\r%d. \w%s \d[\yUngag\d]^n", a, sName);
                #endif
                }
                else 
                {
                    iKeys |= (1 << a++);
                    iLen += formatex(sMenu[iLen], charsmax(sMenu) - iLen, "\r%d. \w%s%s^n", a, sName, VTC_IsClientSpeaking(plr) ? " \d[\rSpeaking\d]" : "");
                }
            }
        
            if(!g_BlockTimes[g_iMenuInfo[id][SelectTime]]) 
                iLen += formatex(sMenu[iLen], charsmax(sMenu) - iLen, "^n\r6. \wЗаткнуть \rНавсегда^n");
            else     iLen += formatex(sMenu[iLen], charsmax(sMenu) - iLen, "^n\r6. \wЗаткнуть: на \y%d \wмин^n", g_BlockTimes[g_iMenuInfo[id][SelectTime]]);
            
            iLen += formatex(sMenu[iLen], charsmax(sMenu) - iLen, "\r7. \wБлокировать \y%s^n", g_BlockTypes[g_iMenuInfo[id][SelectType]]);
            iLen += formatex(sMenu[iLen], charsmax(sMenu) - iLen, "\r8. \wПричина: \r%s^n^n", g_Reasons[g_iMenuInfo[id][SelectReason]]);
        }
        case MUTE:
        {
            for(new i = start, sName[32], plr, a; i < end; ++i)
            {    
                plr = g_arrPlayers[id][i];
                get_user_name(plr, sName, charsmax(sName));

                if(id == plr)
                    iLen += formatex(sMenu[iLen], charsmax(sMenu) - iLen, "\r%d. \d%s \y[\rЭто Вы\y]^n", ++a, sName);
                else
                {
                    iKeys |= (1 << a++);
                    iLen += formatex(sMenu[iLen], charsmax(sMenu) - iLen, "\r%d. \w%s%s^n", a, sName, g_iMutePlayer[id][plr] ? " \d[\yMuted\d]" : "");
                }
            }
        
            iLen += formatex(sMenu[iLen], charsmax(sMenu) - iLen, "^n\r7. \wЗаглушить \rвсех^n\r8. \wСнять Mute со \rвсех^n^n");
        }
    }

    if(end != pnum)
    {
        formatex(sMenu[iLen], charsmax(sMenu) - iLen, "\r9. \yДалее^n\r0. \r%s", iPos ? "Назад" : "Выход");
        iKeys |= MENU_KEY_9;
    }
    else formatex(sMenu[iLen], charsmax(sMenu) - iLen, "\r0. \r%s", iPos ? "Назад" : "Выход");

    show_menu(id, iKeys, sMenu, -1, "UCC Menu");
    return PLUGIN_HANDLED;
}

public MenuHandler(id, iKey)
{
    switch(iKey)
    {
        case 5:
        {
            switch(g_iMenuInfo[id][Menu])
            {
                case GAG:
                {
                    if(++g_iMenuInfo[id][SelectTime] > charsmax(g_BlockTimes)) 
                        g_iMenuInfo[id][SelectTime] = 0;
                        
                    ShowMenu(id, g_iMenuInfo[id][Pos]);
                }
                case MUTE:    
                    MuteHandler(id, g_arrPlayers[id][g_iMenuInfo[id][Pos] * MENU_ITEMS + iKey]);
            }
        }
        case 6:
        {
            switch(g_iMenuInfo[id][Menu])
            {
                case GAG:
                {
                    if(++g_iMenuInfo[id][SelectType] > charsmax(g_BlockTypes))
                        g_iMenuInfo[id][SelectType] = 0;
                    
                    ShowMenu(id, g_iMenuInfo[id][Pos]);
                }
                case MUTE:
                {
                    arrayset(g_iMutePlayer[id], 1, sizeof g_iMutePlayer[]);
                    ChatColor(id, 0, MSG_MUTE_ALL_PLAYERS, PREFIX);
                }
            }
            
        }
        case 7:
        {
            switch(g_iMenuInfo[id][Menu])
            {
                case GAG:
                {
                    if(++g_iMenuInfo[id][SelectReason] > charsmax(g_Reasons)) 
                        g_iMenuInfo[id][SelectReason] = 0;
                    
                    ShowMenu(id, g_iMenuInfo[id][Pos]);
                }
                case MUTE:
                {
                    arrayset(g_iMutePlayer[id], 0, sizeof g_iMutePlayer[]);
                    ChatColor(id, 0, MSG_UNMUTE_ALL_PLAYERS, PREFIX);
                }
            }
        }
        case 8: ShowMenu(id, ++g_iMenuInfo[id][Pos]);
        case 9: 
        {
            if(g_iMenuInfo[id][Pos]) 
                ShowMenu(id, --g_iMenuInfo[id][Pos]);
        }
        default:
        {
            switch(g_iMenuInfo[id][Menu])
            {
                case GAG:
                {
                    GagHandler(
                        id, 
                        g_arrPlayers[id][g_iMenuInfo[id][Pos] * MENU_ITEMS + iKey], 
                        g_BlockTimes[g_iMenuInfo[id][SelectTime]], 
                        g_Reasons[g_iMenuInfo[id][SelectReason]],
                        any:(g_iMenuInfo[id][SelectType] + 1)
                    );
                }
                case MUTE:
                {
                    MuteHandler(id, g_arrPlayers[id][g_iMenuInfo[id][Pos] * MENU_ITEMS + iKey]);
                }
            }
        }
    }
    return PLUGIN_HANDLED;
}

GagHandler(id, player, blocktime, blockreason[REASON_LENGTH], BLOCK_TYPES:block_type)
{
    if(!is_user_connected(player))
        return;

    new sNameAdmin[32], sNamePlayer[32];
    get_user_name(id, sNameAdmin, charsmax(sNameAdmin));
    get_user_name(player, sNamePlayer, charsmax(sNamePlayer));

    if(g_BlockInfo[player][GagBlockType] > STATS)
    {
        user_unblock(player);

        ChatColor(0, player, MSG_CHAT_UNBLOCK_ALL, PREFIX, sNamePlayer, sNameAdmin);
        ChatColor(player, 0, MSG_CHAT_UNBLOCK_PL, PREFIX, sNamePlayer, sNameAdmin);
    }
    else
    {
        user_block(player, id, blocktime, blockreason, block_type);

        new blocktimeinfo[32];
        if(!blocktime)
            formatex(blocktimeinfo, charsmax(blocktimeinfo), "навсегда");
        else    formatex(blocktimeinfo, charsmax(blocktimeinfo), "на %d минут", blocktime);
        
        switch(block_type)
        {
            case TEXT_CHAT:
            {
                ChatColor(0, player, MSG_TEXTCHAT_BLOCK_ALL, PREFIX, sNameAdmin, sNamePlayer, blocktimeinfo, blockreason);
                ChatColor(player, 0, MSG_TEXTCHAT_BLOCK_PL, PREFIX, sNamePlayer, sNameAdmin, blocktimeinfo, blockreason);
            }
            case VOICE_CHAT:
            {
                ChatColor(0, player, MSG_VOICECHAT_BLOCK_ALL, PREFIX, sNameAdmin, sNamePlayer, blocktimeinfo, blockreason);
                ChatColor(player, 0, MSG_VOICECHAT_BLOCK_PL, PREFIX, sNamePlayer, sNameAdmin, blocktimeinfo, blockreason);
            }
            case ALL_CHATS:
            {
                ChatColor(0, player, MSG_ALLCHATS_BLOCK_ALL, PREFIX, sNameAdmin, sNamePlayer, blocktimeinfo, blockreason);
                ChatColor(player, 0, MSG_ALLCHATS_BLOCK_PL, PREFIX, sNamePlayer, sNameAdmin, blocktimeinfo, blockreason);
            }
        }
    }
    ShowMenu(id, g_iMenuInfo[id][Pos]);
}

MuteHandler(id, player)
{
    if(!is_user_connected(player))
        return;
    
    new sNamePlayer[32];
    get_user_name(player, sNamePlayer, charsmax(sNamePlayer));

    g_iMutePlayer[id][player] = !g_iMutePlayer[id][player];
    ChatColor(id, 0, g_iMutePlayer[id][player] ? MSG_MUTE_PLAYER : MSG_UNMUTE_PLAYER, PREFIX, sNamePlayer);
    
    ShowMenu(id, g_iMenuInfo[id][Pos]);
}

user_block(id, admin, blocktime, blockreason[REASON_LENGTH], BLOCK_TYPES:block_type)
{
    set_user_block(id, block_type);

    new szName[64], szIP[16], szAuth[32];
    get_user_name(id, szName, charsmax(szName));
    get_user_ip(id, szIP, charsmax(szIP), 1);
    get_user_authid(id, szAuth, charsmax(szAuth));

    new szAdminName[64], szAdminIP[16], szAdminAuth[32];
    get_user_name(admin, szAdminName, charsmax(szAdminName));
    get_user_ip(admin, szAdminIP, charsmax(szAdminIP), 1);
    get_user_authid(admin, szAdminAuth, charsmax(szAdminAuth));

    new iSystime = get_systime();
    g_BlockInfo[id][expired] = !blocktime ? 0 : iSystime + blocktime * 60;
    formatex(g_BlockInfo[id][reason], charsmax(g_BlockInfo[][reason]), blockreason);
    formatex(g_BlockInfo[id][admin_steamid], charsmax(g_BlockInfo[][admin_steamid]), szAdminAuth);
    
    mysql_escape_string(szName, charsmax(szName));
    mysql_escape_string(szAdminName, charsmax(szAdminName));
    mysql_escape_string(g_BlockInfo[id][reason], charsmax(g_BlockInfo[][reason]));

    formatex(g_szQuery, charsmax(g_szQuery), 
        "INSERT INTO `ucc_gag` (`name`, `steamid`, `ip`, `admin_name`, `admin_steamid`, `admin_ip`, `create_time`, `expired_time`, `reason`, `block_type`) \
            VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%d', '%d', '%s', '%d') \
        ON DUPLICATE KEY UPDATE `name` = '%s', `ip` = '%s', `admin_name` = '%s', `admin_steamid` = '%s', `admin_ip` = '%s', `create_time` = '%d', `expired_time` = '%d', `reason` = '%s', `block_type` = '%d'", 
            szName, szAuth, szIP, szAdminName, szAdminAuth, szAdminIP, iSystime, g_BlockInfo[id][expired], g_BlockInfo[id][reason], any:block_type, 
            szName, szIP, szAdminName, szAdminAuth, szAdminIP, iSystime, g_BlockInfo[id][expired], g_BlockInfo[id][reason], any:block_type
    );
        
    g_Data[0] = SAVE_BLOCK;
    SQL_ThreadQuery(g_hTuple, "SQL_ThreadsHandler", g_szQuery, g_Data, sizeof(g_Data));
}

user_unblock(id)
{
    if(is_blocked_voice_chat(id))
        VTC_UnmuteClient(id);
    
    g_BlockInfo[id][expired]       = -1;
    g_BlockInfo[id][reason][0]     = EOS;
    g_BlockInfo[id][admin_steamid][0]= EOS;
    g_BlockInfo[id][GagBlockType]      = NONE;
    
    new szIP[16], szAuth[32];
    get_user_ip(id, szIP, charsmax(szIP), 1);
    get_user_authid(id, szAuth, charsmax(szAuth));
    
    formatex(g_szQuery, charsmax(g_szQuery), "UPDATE `ucc_gag` SET `expired_time` = '-1' WHERE `ip` = '%s' OR `steamid` = '%s'", szIP, szAuth);
    
    g_Data[0] = REMOVE_BLOCK;
    SQL_ThreadQuery(g_hTuple, "SQL_ThreadsHandler", g_szQuery, g_Data, sizeof(g_Data));
}

SQL_Init()
{
    SQL_SetAffinity("mysql");
    g_hTuple = SQL_MakeDbTuple(DB_HOST, DB_USER, DB_PASS, DB_NAME, 1);
    
    new errcode, errstr[128], Handle:hTest = SQL_Connect(g_hTuple, errcode, errstr, charsmax(errstr));
    if(hTest == Empty_Handle)
    {
    #if AMXX_VERSION_NUM < 183
        new szError[128]; formatex(szError, charsmax(szError), "[SQL ERROR #%d] %s", errcode, errstr);
        set_fail_state(szError);
    #else
        set_fail_state("[SQL ERROR #%d] %s", errcode, errstr);
    #endif
    }
    else
    {
        SQL_FreeHandle(hTest);
#if AMXX_VERSION_NUM >= 183
        SQL_SetCharset(g_hTuple, "utf8");
#endif
        new iClearPeriod = get_systime() - 86400 * CLEAR_PERIOD;
        // superfix compile for amxx 1.8.2
        new iLen = formatex(g_szQuery, charsmax(g_szQuery), 
            "CREATE TABLE IF NOT EXISTS `ucc_gag` ( \
             `id` smallint(6) NOT NULL AUTO_INCREMENT, \
             `name` varchar(32) NOT NULL, \
             `steamid` varchar(32) NOT NULL, \
             `ip` varchar(16) NOT NULL, \
             `admin_name` varchar(32) NOT NULL, \
             `admin_steamid` varchar(32) NOT NULL, \
             `admin_ip` varchar(32) NOT NULL, \
             `create_time` int(11) NOT NULL, ");
        formatex(g_szQuery[iLen], charsmax(g_szQuery), 
            "`expired_time` int(11) NOT NULL, \
             `reason` varchar(%d) NOT NULL, \
             `block_type` int(11) NOT NULL, \
              PRIMARY KEY (`id`), \
              UNIQUE KEY `steamid` (`steamid`) \
            )ENGINE=InnoDB DEFAULT CHARSET=utf8; \
            DELETE FROM `ucc_gag` WHERE (`expired_time` < '%d' AND `expired_time` > '0') OR (`expired_time` = '-1' AND `create_time` < '%d');", 
                REASON_LENGTH, iClearPeriod, iClearPeriod);

        g_Data[0] = SQL_INIT;
        SQL_ThreadQuery(g_hTuple, "SQL_ThreadsHandler", g_szQuery, g_Data, sizeof(g_Data));
    }
}

public SQL_ThreadsHandler(failstate, Handle:query, err[], errcode, data[], datasize)
{
    switch(failstate)
    {
        case TQUERY_CONNECT_FAILED, TQUERY_QUERY_FAILED:
        {
            log_amx("[SQL ERROR #%d] %s", errcode, err);
            return;
        }
    }
    
    switch(data[0])
    {
        case SQL_INIT, DROP_TABLE, SAVE_BLOCK, REMOVE_BLOCK: {}
        case LOAD_PLAYER:
        {
            if(SQL_NumResults(query))
            {
                new id = data[1];
                
                g_BlockInfo[id][expired] = SQL_ReadResult(query, 0);
                g_BlockInfo[id][GagBlockType] = any:SQL_ReadResult(query, 3);
                SQL_ReadResult(query, 1, g_BlockInfo[id][reason], charsmax(g_BlockInfo[][reason]));
                SQL_ReadResult(query, 2, g_BlockInfo[id][admin_steamid], charsmax(g_BlockInfo[][admin_steamid]));
                
                set_user_block(id, g_BlockInfo[id][GagBlockType]);
            }
        }
    }
}

public native_ucc_is_client_gaged(plugin, params)
{
    enum { index = 1, exp_time, gag_reason, gag_type };

    new id = get_param(index);
    
    if(is_user_connected(id))
    {
        set_param_byref(exp_time, g_BlockInfo[id][expired]);
        set_string(gag_reason, g_BlockInfo[id][reason], charsmax(g_BlockInfo[][reason]));
        
        if(params > 3)
            set_param_byref(gag_type, any:g_BlockInfo[id][GagBlockType]);
        
        return (g_BlockInfo[id][GagBlockType] > NONE);
    }
    
    log_error(AMX_ERR_NATIVE, "Client %d not connected or index out of range!", id);
    return -1;
}

public native_ucc_set_client_gag(plugin, params)
{
    enum { index = 1, admin_id, block_time, gag_reason, gag_type };
    
    new id    = get_param(index);
    new admin = get_param(admin_id);
    new type = (params > 4) ? get_param(gag_type) : any:ALL_CHATS;
    
    if(!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "Client %d not connected or index out of range!", id);
        return 0;
    }
    if(!is_user_connected(admin))
        admin = 0;
    
    new szReason[REASON_LENGTH];
    get_string(gag_reason, szReason, charsmax(szReason));
    
    user_block(id, admin, get_param(block_time), szReason, any:type);
    return 1;
}
#if defined MUTEMENU    
    public native_ucc_is_client_muted(plugin, params)
    {
        enum { index = 1, player };
        
        new id = get_param(index);
        new victim = get_param(player);
        
        if(!is_user_connected(id))
        {
            log_error(AMX_ERR_NATIVE, "Client %d not connected or index out of range!", id);
            return -1;
        }
        if(!is_user_connected(victim))
        {
            log_error(AMX_ERR_NATIVE, "Client %d not connected or index out of range!", victim);
            return -1;
        }
        
        return g_iMutePlayer[id][victim];
    }
    
    public native_ucc_set_client_muted(plugin, params)
    {
        enum { index = 1, player, muted };
        
        new id = get_param(index);
        new victim = get_param(player);
        new set_mute = get_param(muted);
        
        if(!is_user_connected(id))
        {
            log_error(AMX_ERR_NATIVE, "Client %d not connected or index out of range!", id);
            return 0;
        }
        if(!is_user_connected(victim))
        {
            log_error(AMX_ERR_NATIVE, "Client %d not connected or index out of range!", victim);
            return 0;
        }
        
        
        g_iMutePlayer[id][victim] = (set_mute > 0) ? 1 : 0;
        return 1;
    }
#endif
public plugin_end()
{
    SQL_FreeHandle(g_hTuple);
    TrieDestroy(g_tAllowCmds);
}

set_user_block(id, BLOCK_TYPES:block_type)
{
    g_BlockInfo[id][GagBlockType] = block_type;

    switch(block_type)
    {
        case VOICE_CHAT, ALL_CHATS:
        {
            VTC_MuteClient(id);
            client_cmd(id, "-voicerecord");
        }
    }
}
#if defined CHATS_BY_STATS
bool:get_chats_access(id)
{
    if(get_user_flags(id) & ADMIN_FLAG)
        return true;
#if VOICE_CONTROL_BY_STATS == 0
    new st[8], bh[HIT_RIGHTLEG + 1];
    if(!get_user_stats(id, st, bh))
        return false;
#endif
#if VOICE_CONTROL_BY_STATS == 1
    new st[22];
    if(csstats_get_user_stats(id, st) <= 0)
        return false;
#endif
#if VOICE_CONTROL_BY_STATS == 2
    new st[8], bh[HIT_RIGHTLEG + 1];
    if(!get_user_stats_sql(id, st, bh))
        return false;
#endif
#if VOICE_CONTROL_BY_STATS == 3
    new st[1]; st[0] = aes_get_player_level(id);
    if((st[0] = aes_get_player_level(id)) == -1)
        return false;
#endif
#if defined BLOCK_CHATS_INFO
    g_iFragStats[id] = st[0];
#endif
    return (st[0] < MIN_FRAGS) ? false : true;
}
#endif
stock ChatColor(id, id2, const szMessage[], any:...)
{
    new szMsg[190]; 
    vformat(szMsg, charsmax(szMsg), szMessage, 4);
    
    if(id)
    {
        client_print_color(id, print_team_default, szMsg);
    }
    else
    {
        get_players(pl, pnum, "c");
        for(new i; i < pnum; ++i)
        {
            if(pl[i] != id2)
            {
                client_print_color(pl[i], print_team_default, szMsg);
            }
        }
    }
}

#if !defined replace_string
    #define replace_string replace_all
#endif
stock mysql_escape_string(output[], len)
{
    static const szReplaceIn[][] = { "\\", "\0", "\n", "\r", "\x1a", "'", "^"" };
    static const szReplaceOut[][] = { "\\\\", "\\0", "\\n", "\\r", "\Z", "\'", "\^"" };
    for(new i; i < sizeof szReplaceIn; i++)
        replace_string(output, len, szReplaceIn[i], szReplaceOut[i]);
}
Здравствуйте. помогите поправить!)) Скомпилировался, но варнингами при компиляции. Заранее спасибо!)
 
Последнее редактирование:
Сверху Снизу