[APS] Text Chat

reapi module gmx [APS] Text Chat 0.1.84-alpha

Нет прав для скачивания
Установка
  1. Скопируйте файлы согласно директориям
  2. Откройте aps_text_chat.sma и скомпилируйте плагин (инструкция).
  3. Скопируйте скомпилированный aps_text_chat.amxx в директорию "addons/amxmodx/plugins".
  4. Раскомментируйте aps_text_chat.amxx в /amxmodx/configs/plugins-aps.ini
Настройки
В .sma
Флаг доступа для блокировки голосового чата
Код:
const FLAG_ACCESS = ADMIN_CHAT;      // Gags flag access
aps_text_ingore_list.ini
Список разрешенных команд при заблокированном чате
Код:
timeleft
thetime
nextmap
API
Код:
#if defined _aps_plmenu_included
    #endinput
#endif
#define _aps_plmenu_included

enum APS_PlMenu_Item {
    APS_PlMenu_InvalidItem = -1,
};

enum APS_PlMenu_Handler {
    APS_PlMenu_Handler_Default = -2,
    APS_PlMenu_Handler_Invaild = -1,
};

forward APS_PlMenu_Inited();
forward APS_PlMenu_CheckAccess(const player, const target, const APS_PlMenu_Item:item);

// handler(const admin, const player, const reason[], const itme, const extra)
stock APS_PlMenu_Handler:APS_PlMenu_CreateHandler(const handler[]) {
    return APS_PlMenu_Handler:CreateOneForward(get_plugin(-1), handler, FP_CELL, FP_CELL, FP_STRING, FP_CELL, FP_CELL);
}

stock APS_PlMenu_DestroyHandler(APS_PlMenu_Handler:handler) {
    if (handler >= 0) {
        DestroyForward(handler);
    }
}

stock APS_PlMenu_Item:APS_PlMenu_Add(
    const APS_Type:type, const title[],
    const APS_PlMenu_Handler:handler = APS_PlMenu_Handler_Default,
    const APS_PlMenu_Handler:resonHandler = APS_PlMenu_Handler_Default,
    const APS_PlMenu_Handler:timeHandler = APS_PlMenu_Handler_Default,
    const APS_PlMenu_Handler:extraHandler = APS_PlMenu_Handler_Invaild,
    const bool:needConfirm = true
) {
    new pluginID = APS_PlMenu_GetPluginID();
    if (pluginID == -1) {
        return APS_PlMenu_InvalidItem;
    }
    new func = get_func_id("APS_PlMenu_Add", pluginID);
    if (func == -1) {
        return APS_PlMenu_InvalidItem;
    }
 
    if (callfunc_begin_i(func, pluginID) != 1) {
        return APS_PlMenu_InvalidItem;
    }
    callfunc_push_int(_:type);
    callfunc_push_str(title);
    callfunc_push_int(_:handler);
    callfunc_push_int(_:resonHandler);
    callfunc_push_int(_:timeHandler);
    callfunc_push_int(_:extraHandler);
    callfunc_push_int(_:needConfirm);
    return APS_PlMenu_Item:callfunc_end();
}

stock bool:APS_PlMenu_NextStep(const admin, const value) {
    new pluginID = APS_PlMenu_GetPluginID();
    if (pluginID == -1) {
        return false;
    }
    new func = get_func_id("APS_PlMenu_NextStep", pluginID);
    if (func == -1) {
        return false;
    }
 
    if (callfunc_begin_i(func, pluginID) != 1) {
        return false;
    }
    callfunc_push_int(admin);
    callfunc_push_int(value);
    callfunc_end();
 
    return true;
}

stock bool:APS_PlMenu_PrevStep(const admin) {
    new pluginID = APS_PlMenu_GetPluginID();
    if (pluginID == -1) {
        return false;
    }
    new func = get_func_id("APS_PlMenu_PrevStep", pluginID);
    if (func == -1) {
        return false;
    }
 
    if (callfunc_begin_i(func, pluginID) != 1) {
        return false;
    }
    callfunc_push_int(admin);
    callfunc_end();
 
    return true;
}

stock APS_PlMenu_GetPlayer(const admin) {
    new pluginID = APS_PlMenu_GetPluginID();
    if (pluginID == -1) {
        return -1;
    }
    new func = get_func_id("APS_PlMenu_GetPlayer", pluginID);
    if (func == -1) {
        return -1;
    }
 
    if (callfunc_begin_i(func, pluginID) != 1) {
        return -1;
    }
    callfunc_push_int(admin);
    return callfunc_end();
}

stock bool:APS_PlMenu_Show(const admin, const player = 0, const APS_PlMenu_Item:item = APS_PlMenu_InvalidItem, const reason = -1, const time = -1, const extra = 0) {
    new pluginID = APS_PlMenu_GetPluginID();
    if (pluginID == -1) {
        return false;
    }
    new func = get_func_id("APS_PlMenu_Show", pluginID);
    if (func == -1) {
        return false;
    }
 
    if (callfunc_begin_i(func, pluginID) != 1) {
        return false;
    }
    callfunc_push_int(admin);
    callfunc_push_int(player);
    callfunc_push_int(_:item);
    callfunc_push_int(reason);
    callfunc_push_int(time);
    callfunc_push_int(extra);
    return bool:callfunc_end();
}

stock APS_PlMenu_GetPluginID() {
    static pluginID = -1;
    if (pluginID == -1) {
        new plugin = get_plugin(-1);
     
        for(new i, n = get_pluginsnum(), status[2], func; i < n; i++) {
            if (plugin == i) {
                continue;
            }
         
            get_plugin(i, .status = status, .len5 = charsmax(status));

            //status debug || status running
            if (status[0] != 'd' && status[0] != 'r') {
                continue;
            }
     
            func = get_func_id("APS_PlMenu_Main", i);

            if (func != -1) {
                pluginID = i;
                break;
            }
        }
    }
 
    return pluginID;
}
Код:
#if defined _aps_chat_included
    #endinput
#endif

#define _aps_chat_included

enum (<<=1) {
    APS_Chat_Voice = 1,
    APS_Chat_Text,
}

native APS_ChatGetBlockedType(const player);
native bool:APS_ChatGetBlockedText(const player);
native bool:APS_ChatGetBlockedVoice(const player);
Код:
#if defined _aps_chat_stocks_included
    #endinput
#endif

#define _aps_chat_stocks_included

#include <celltrie>
#include <file>

stock Trie:APS_TextIgnoreList = Invalid_Trie;

stock APS_TextIgnoreListInit() {
    APS_TextIgnoreList = TrieCreate();
}

stock APS_TextIgnoreListDestroy() {
    if (APS_TextIgnoreList != Invalid_Trie) {
        TrieDestroy(APS_TextIgnoreList);
    }
}

stock bool:APS_TextIgnoreListPush(const message[]) {
    if (APS_TextIgnoreList == Invalid_Trie) {
        log_error(AMX_ERR_NONE, "Text ignore list not inited");
        return false;
    }
    TrieSetCell(APS_TextIgnoreList, message, 1);
    return true;
}

stock bool:APS_TextIgnoreListCheck(const message[]) {
    if (APS_TextIgnoreList == Invalid_Trie) {
        log_error(AMX_ERR_NONE, "Text ignore list not inited");
        return false;
    }
    return TrieKeyExists(APS_TextIgnoreList, message);
}

stock bool:APS_TextIgnoreListLoad(const path[]) {
    if (APS_TextIgnoreList == Invalid_Trie) {
        log_error(AMX_ERR_NONE, "Text ignore list not inited");
        return false;
    }

    new file = fopen(path, "rt");
    if (!file) {
        log_error(AMX_ERR_NONE, "Can't open file %s", path);
        return false;
    }

    new line[128], semicolon;
    while (!feof(file)) {
        fgets(file, line, charsmax(line));
     
        semicolon = contain(line, ";");
        if (semicolon >= 0) {
            line[semicolon] = EOS;
        }
        trim(line);
        if (line[0] == EOS) {
            continue;
        }
     
        APS_TextIgnoreListPush(line);
    }
 
    fclose(file);
    return true;
}
Сверху Снизу