Поиск Чат префикс + дополнить армс рангом

Статус
В этой теме нельзя размещать новые ответы.
Сообщения
6
Реакции
0
Неверный раздел форума
Помогите пожалуйста , добавить ранги в скрипт (плагин перефексов) плагин Army Ranks Ultimate от скальпеля.

Чтобы типо было #!gрядовой ! r[Админ] !players

Код:
#include <amxmodx>
#include <fakemeta>

#pragma semicolon 1

#define MAX_PLAYERS 32
#define MsgId_SayText 76
#define MsgId_TeamInfo 86

enum _:DATA
{
    TYPE[2],
    AUTH[32],
    PREFIX[64]
};
new Array:g_aData, g_aDataSize, g_szPrefix[MAX_PLAYERS + 1][64];
new Array:g_aDataBlockMess, g_aDataBlockMessSize;

new g_iMaxPlayers, Float:g_iUserTimeMes[MAX_PLAYERS + 1], Float:g_iTimeFlood[MAX_PLAYERS + 1];

public plugin_init()
{
    register_plugin("[FS] Chat", "1.1", "Docaner");
  
    register_clcmd("say", "Chat_Say");
    register_clcmd("say_team", "Chat_SayTeam");
  
    g_iMaxPlayers = get_maxplayers();
}

public client_disconnected(id)
{
    g_iUserTimeMes[id] = 0.0;
    g_iTimeFlood[id] = 0.0;
    g_szPrefix[id] = "";
}

public plugin_cfg()
{
    new szCfgDir[64], szCfgFile[128];
    get_localinfo("amxx_configsdir", szCfgDir, charsmax(szCfgDir));
    formatex(szCfgFile, charsmax(szCfgFile), "%s/ap_chat.ini", szCfgDir);
    if(file_exists(szCfgFile))
    {
        new aData[DATA], aDataBlocked[190], szBuffer[128],
        iLine, iLen, section;
        g_aData = ArrayCreate(DATA);
        g_aDataBlockMess = ArrayCreate(190, 1);
        while(read_file(szCfgFile, iLine++, szBuffer, charsmax(szBuffer), iLen))
        {
            if(!iLen || szBuffer[0] == ';') continue;
            if(szBuffer[0] == '[')
            {
                section++;
                continue;
            }
            switch(section)
            {
                case 1:
                {
                    parse(szBuffer, aData[TYPE], charsmax(aData[TYPE]), aData[AUTH], charsmax(aData[AUTH]), aData[PREFIX], charsmax(aData[PREFIX]));
                    ArrayPushArray(g_aData, aData);
                }
                case 2:
                {
                    formatex(aDataBlocked, charsmax(aDataBlocked), szBuffer);
                    ArrayPushString(g_aDataBlockMess, aDataBlocked);
                }
            }
        }
        g_aDataSize = ArraySize(g_aData);
        g_aDataBlockMessSize = ArraySize(g_aDataBlockMess);
    }
}

public Chat_Say(id) return Chat_Think(id, 0);
public Chat_SayTeam(id) return Chat_Think(id, 1);

Chat_Think(id, iTeam)
{
    new iBuffer[190], iMessage[190], iName[33], iNameColor[35], szTeam[10], IdTeam, iConvertMessage[charsmax(iMessage) * 2 + 1], iMessageControl[190], iPrefix[65];
    read_args(iMessage, charsmax(iMessage));
    remove_quotes(iMessage);
    if(equal(iMessage, "") || iMessage[0] == ' ' || iMessage[0] == '#') return PLUGIN_HANDLED;
    if(iMessage[0] == '@' || iMessage[0] == '/') return PLUGIN_HANDLED_MAIN;
    if(g_iUserTimeMes[id] + 1.0 > get_gametime() || g_iTimeFlood[id] > get_gametime())
    {
        UTIL_SayText(id, "!g|FS CHAT| !yПрекратите флудить в чат!");
        g_iTimeFlood[id] = get_gametime() + 2.0;
        return PLUGIN_HANDLED;
    }
    if(!is_user_alive(id)) add(iBuffer, charsmax(iBuffer), "!y~Мертв~");
    IdTeam = get_user_team(id, szTeam, charsmax(szTeam));
    if(iTeam)
    {
        switch(IdTeam)
        {
            case 1: add(iBuffer, charsmax(iBuffer), equal(iBuffer, "") ? "!y(TT)" : " !y(TT)");
            case 2: add(iBuffer, charsmax(iBuffer), equal(iBuffer, "") ? "!y(CT)" : " !y(CT)");
            default: add(iBuffer, charsmax(iBuffer), equal(iBuffer, "") ? "!y(SPECT)": " !y(SPECT)");
        }
    }
    SAY_GetPrefix(id);
    if(!equal(g_szPrefix[id], ""))
    {
        formatex(iPrefix, charsmax(iPrefix), equal(iBuffer, "") ? "%s" : " %s", g_szPrefix[id]);
        add(iBuffer, charsmax(iBuffer), iPrefix);
    }
    get_user_name(id, iName, charsmax(iName));
    formatex(iNameColor, charsmax(iNameColor), equal(iBuffer, "") ? "!t%s" : " !t%s" , iName);
    add(iBuffer, charsmax(iBuffer), iNameColor);
    add(iBuffer, charsmax(iBuffer), get_user_flags(id) & ADMIN_BAN ? " !y: !g" : " !y: ");
    iConvertMessage = iMessage;
    for(new i; i < g_aDataBlockMessSize; i++)
    {
        ArrayGetString(g_aDataBlockMess, i, iMessageControl, charsmax(iMessageControl));
        if(containi(iConvertMessage, iMessageControl) == -1) continue;
        UTIL_SayText(id, "!g|FS CHAT| !yОбнаружена !gспам атака!y/!gреклама");
        g_iTimeFlood[id] = get_gametime() + 2.0;
        return PLUGIN_HANDLED;
    }
    if(iTeam)
    {
        new iTeami;
        for(new i = 1; i <= g_iMaxPlayers; i++)
        {
            iTeami = get_user_team(i, szTeam, charsmax(szTeam));
            if(IdTeam != iTeami) continue;
            SAY_ChatPrint(i, iBuffer, iConvertMessage, szTeam);
        }
    }
    else SAY_ChatPrint(0, iBuffer, iConvertMessage, szTeam);
    g_iUserTimeMes[id] = get_gametime();
    log_message("%s <%s> %s : %s", is_user_alive(id) ? "" : "<Мертв>", iName, iTeam ? "say_team" : "say", iConvertMessage);
    return PLUGIN_HANDLED_MAIN;
}

stock SAY_GetPrefix(id)
{
    new aData[DATA];
    for(new i; i < g_aDataSize; i++)
    {
        ArrayGetArray(g_aData, i, aData);
        switch(aData[TYPE])
        {
            case 'e':
            {
                static sName[33]; get_user_name(id, sName, charsmax(sName));
                if(!strcmp(aData[AUTH], sName))
                    return copy(g_szPrefix[id], charsmax(g_szPrefix[]), aData[PREFIX]);
            }
            case 'f':
            {
                if(get_user_flags(id) & read_flags(aData[AUTH]))
                    return copy(g_szPrefix[id], charsmax(g_szPrefix[]), aData[PREFIX]);
            } 
            case 'i':
            {
                static sIP[16]; get_user_ip(id, sIP, charsmax(sIP), 1);
                if(!strcmp(aData[AUTH], sIP))
                    return copy(g_szPrefix[id], charsmax(g_szPrefix[]), aData[PREFIX]);
            }     
            case 's':
            {
                static sAuthid[25]; get_user_authid(id, sAuthid, charsmax(sAuthid));
                if(!strcmp(aData[AUTH], sAuthid))
                    return copy(g_szPrefix[id], charsmax(g_szPrefix[]), aData[PREFIX]);
            }     
        }
    }
    return g_szPrefix[id] = "";
}

stock SAY_ChatPrint(pPlayer, const szTags[], const szMessage[], const szTeamColor[])
{
    new szBuffer[190], iPlayerTeamColor[10];
    if(numargs() > 2) vformat(szBuffer, charsmax(szBuffer), szTags, 3);
    else copy(szBuffer, charsmax(szBuffer), szTags);
    while(replace(szBuffer, charsmax(szBuffer), "!y", "^1")) {}
    while(replace(szBuffer, charsmax(szBuffer), "!t", "^3")) {}
    while(replace(szBuffer, charsmax(szBuffer), "!g", "^4")) {}
    add(szBuffer, charsmax(szBuffer), szMessage);
    switch(pPlayer)
    {
        case 0:
        {
            for(new iPlayer = 1; iPlayer <= g_iMaxPlayers; iPlayer++)
            {
                if(!is_user_connected(iPlayer)) continue;
                get_user_team(iPlayer, iPlayerTeamColor, charsmax(iPlayerTeamColor));
                UTIL_MsgTeamInfo(iPlayer, szTeamColor);
                UTIL_MsgSayText(iPlayer, szBuffer, 1);
                UTIL_MsgTeamInfo(iPlayer, iPlayerTeamColor);
            }
        }
        default:
        {
            get_user_team(pPlayer, iPlayerTeamColor, charsmax(iPlayerTeamColor));
            UTIL_MsgTeamInfo(pPlayer, szTeamColor);
            UTIL_MsgSayText(pPlayer, szBuffer, 1);
            UTIL_MsgTeamInfo(pPlayer, iPlayerTeamColor);
        }
    }
}

stock UTIL_SayText(pPlayer, const szMessage[], any:...)
{
    new szBuffer[190];
    if(numargs() > 2) vformat(szBuffer, charsmax(szBuffer), szMessage, 3);
    else copy(szBuffer, charsmax(szBuffer), szMessage);
    while(replace(szBuffer, charsmax(szBuffer), "!y", "^1")) {}
    while(replace(szBuffer, charsmax(szBuffer), "!t", "^3")) {}
    while(replace(szBuffer, charsmax(szBuffer), "!g", "^4")) {}
    switch(pPlayer)
    {
        case 0:
        {
            for(new iPlayer = 1; iPlayer <= g_iMaxPlayers; iPlayer++)
            {
                if(!is_user_connected(iPlayer)) continue;
                UTIL_MsgSayText(iPlayer, szBuffer);
            }
        }
        default: UTIL_MsgSayText(pPlayer, szBuffer);
    }
}

stock UTIL_MsgSayText(iPlayer, const szMessage[], iReliable = 0)
{
    engfunc(EngFunc_MessageBegin, iReliable ? MSG_ONE : MSG_ONE_UNRELIABLE, MsgId_SayText, {0.0, 0.0, 0.0}, iPlayer);
    write_byte(iPlayer);
    write_string(szMessage);
    message_end();
}

stock UTIL_MsgTeamInfo(iPlayer, const iTeam[])
{
    engfunc(EngFunc_MessageBegin, MSG_ONE, MsgId_TeamInfo, {0.0, 0.0, 0.0}, iPlayer);
    write_byte(iPlayer);
    write_string(iTeam);
    message_end();
}
 
Последнее редактирование:
Статус
В этой теме нельзя размещать новые ответы.

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

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