搜索
查看: 2940|回复: 4

求一个管理员说话变色的插件

[复制链接]
发表于 2009-8-12 18:26:49 | 显示全部楼层 |阅读模式 来自 上海闵行区
以前有一个OP说话颜色是绿色的插件,哪位DX有的话能不能传上来,小弟急用..谢谢!
 楼主| 发表于 2009-8-13 15:46:36 | 显示全部楼层 来自 上海徐汇区
没人有么..
回复

使用道具 举报

发表于 2009-8-14 13:29:36 | 显示全部楼层 来自 山东临沂
本帖最后由 TCMBW 于 2009-8-14 13:58 编辑

// COLOR CHAT LEVELS
// --------------------------------------------------------------------------------------
#define ADMIN_NORMAL        ADMIN_LEVEL_A                // level for normal chat with green name only
#define ADMIN_RED        ADMIN_LEVEL_B                // level for red chat
#define ADMIN_BLUE        ADMIN_LEVEL_C                // level for blue chat
#define ADMIN_SILVER        ADMIN_LEVEL_D                // level for silver chat
// --------------------------------------------------------------------------------------


// ADMIN LISTEN LEVELS
// --------------------------------------------------------------------------------------
#define LISTEN_CHAT ADMIN_KICK                // level to see all chat (adminlisten style)
#define LISTEN_VOICE ADMIN_IMMUNITY        // level to hear all voices (adminlisten style)
// --------------------------------------------------------------------------------------




//   DO NOT EDIT BEYOND THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING
// --------------------------------------------------------------------------------------

#include <amxmodx>
#include <fakemeta>

#define SPEAK_NORMAL        (1<<0)
//#define SPEAK_MUTED        (1<<1)
#define SPEAK_ALL        (1<<2)
#define SPEAK_LISTENALL        (1<<3)


new pCvar_enabled;
new pCvar_voice;
new pCvar_chat;
new pCvar_alltalk;

new giMaxPlayers;
new giMsgSayText;
new giMsgTeamInfo;
new giSpeakFlags[33];
new const giColorLevels[] =
{
        ADMIN_ALL,
        ADMIN_NORMAL,
        ADMIN_RED,
        ADMIN_BLUE,
        ADMIN_SILVER
};

new const gszColorCode[][] =
{
        "",
        "^x01",
        "^x03",
        "^x03",
        "^x03"
};
new const gszColorTeams[][] =
{
        "",
        "",
        "TERRORIST",
        "CT",
        "SPECTATOR"
};
new const gszTeamNames[][] =
{
        "Spectator",
        "Terrorist",
        "Counter-Terrorist",
        "Spectator"
};

public plugin_init()
{
        register_plugin("Colored Admin Chat", "4.0", "Exolent");
        register_clcmd("say", "handle_say");
        register_clcmd("say_team", "handle_teamsay");
        register_forward(FM_Voice_SetClientListening, "fm_SetVoice");
       
        pCvar_enabled = register_cvar("amx_cac_enabled", "1");
        pCvar_voice = register_cvar("amx_adminlisten_voice", "1");
        pCvar_chat = register_cvar("amx_adminlisten_chat", "1");
        pCvar_alltalk = get_cvar_pointer("sv_alltalk");
       
        giMaxPlayers = get_maxplayers();
        giMsgSayText = get_user_msgid("SayText");
        giMsgTeamInfo = get_user_msgid("TeamInfo");
}

public handle_say(id)
{
        if(!get_pcvar_num(pCvar_enabled))
                return PLUGIN_CONTINUE;
       
        static szMessage[192];
        read_args(szMessage, 191);
        remove_quotes(szMessage);
       
        if(!is_valid_message(szMessage))
                return PLUGIN_CONTINUE;
       
        static bool:bAdmin;
        bAdmin = has_color_chat(id);
        static iChatColor, iAlive, i;
        iChatColor = get_chat_color(id);
        iAlive = is_user_alive(id);
        new Dami;
        Dami = iChatColor - 2;
        static szName[32], szTeam[32], szTeam2[32];
        get_user_name(id, szName, 31);
        get_user_team(id, szTeam, 31);
        format(szMessage, 191, "%s%s%s%s ^x01: %s %s",\
                iAlive ? "" : "^x01*闃典骸*",\
                bAdmin ? (Dami ? "^x03(缁挎槦缃戝惂)" : "^x03(绠$悊鍛?"): "^x01",\
                bAdmin ? "^x04" : "^x01",\
                szName,\
                bAdmin ? gszColorCode[iChatColor] : "",\
                szMessage);
       
        for(i = 1; i <= giMaxPlayers; i++)
        {
                if(!is_user_connected(i))
                        continue;
               
                if(iAlive == is_user_alive(i)
                || (get_pcvar_num(pCvar_chat)) && (get_user_flags(i) & LISTEN_CHAT))
                {
                        get_user_team(i, szTeam2, 31);
                        handle_message(i, szTeam, szTeam2, iChatColor, szMessage);
                }
        }
        return PLUGIN_HANDLED;
}

public handle_teamsay(id)
{
        if(!get_pcvar_num(pCvar_enabled))
                return PLUGIN_CONTINUE;
       
        static szMessage[192];
        read_args(szMessage, 191);
        remove_quotes(szMessage);
       
        if(!is_valid_message(szMessage))
                return PLUGIN_CONTINUE;
       
        static bool:bAdmin;
        bAdmin = has_color_chat(id);
       
        static iChatColor, iAlive, iTeam, i;
        iChatColor = get_chat_color(id);
        iAlive = is_user_alive(id);
        iTeam = get_user_team(id);
        new Dami2;
        Dami2 = iChatColor - 2;
        static szName[32], szTeam[32], szTeam2[32];
        get_user_name(id, szName, 31);
        get_user_team(id, szTeam, 31);
       
        format(szMessage, 191, "^x01%s(%s)%s%s %s^x01 : %s %s",\
                iAlive ? "" : "*DEAD*",\
                gszTeamNames[iTeam],\
                  bAdmin ? (Dami2 ? "^x03(缁挎槦缃戝惂)" : "^x03(绠$悊鍛?"): "^x01",\
                bAdmin ? "^x04" : "^x03",\
                szName,\
                bAdmin ? gszColorCode[iChatColor] : "",\
                szMessage);
       
        for(i = 1; i <= giMaxPlayers; i++)
        {
                if(!is_user_connected(i))
                        continue;
               
                get_user_team(i, szTeam2, 31);
                if(!equali(szTeam, szTeam2) && (get_pcvar_num(pCvar_chat) != 1))
                        continue;
               
                if(iAlive == is_user_alive(i)
                || get_user_flags(i) & LISTEN_CHAT)
                {
                        handle_message(id, szTeam, szTeam2, iChatColor, szMessage);
                }
        }
        return PLUGIN_HANDLED;
}

public fm_SetVoice(iReceiver, iSender, bool:bListen)
{
        reset_speak(iReceiver);
        reset_speak(iSender);
        if((giSpeakFlags[iSender] & SPEAK_ALL) != 0)
        {
                set_speak(iReceiver, iSender, true);
                return FMRES_SUPERCEDE;
        }
        if((giSpeakFlags[iReceiver] & SPEAK_LISTENALL) != 0)
        {
                set_speak(iReceiver, iSender, true);
                return FMRES_SUPERCEDE;
        }
        forward_return(FMV_CELL, bListen);
        return FMRES_IGNORED;
}

bool:is_valid_message(const szMessage[])
{
        if(szMessage[0] == '/'
        || szMessage[0] == '@'
        || !strlen(szMessage))
        {
                return false;
        }
        return true;
}

bool:has_color_chat(const id)
{
        static iFlags, i;
        iFlags = get_user_flags(id);
        for(i = 1; i < sizeof giColorLevels; i++)
        {
                if(iFlags & giColorLevels)
                        return true;
        }
        return false;
}

get_chat_color(const id)
{
        static iFlags, i;
        iFlags = get_user_flags(id);
        for(i = 1; i < sizeof giColorLevels; i++)
        {
                if(iFlags & giColorLevels)
                        return i;
        }
        return 0;
}

handle_message(const id, const szTeam[], const szTeam2[], const iChatColor, const szMessage[])
{
        if(equali(gszColorCode[iChatColor], "^x03") && !equali(gszColorTeams[iChatColor], szTeam2))
        {
                show_TeamInfo_msg(id, gszColorTeams[iChatColor]);
                show_SayText_msg(id, szMessage);
                show_TeamInfo_msg(id, szTeam2);
        }
        else if(!equali(szTeam, szTeam2) && !iChatColor)
        {
                show_TeamInfo_msg(id, szTeam);
                show_SayText_msg(id, szMessage);
                show_TeamInfo_msg(id, szTeam2);
        }
        else
        {
                show_SayText_msg(id, szMessage);
        }
        return 1;
}

show_TeamInfo_msg(const id, const szTeam[])
{
        message_begin(MSG_ONE, giMsgTeamInfo, _, id);
        write_byte(id);
        write_string(szTeam);
        message_end();
}

show_SayText_msg(const id, const szMessage[])
{
        message_begin(MSG_ONE, giMsgSayText, _, id);
        write_byte(id);
        write_string(szMessage);
        message_end();
}

reset_speak(const id)
{
        if(get_pcvar_num(pCvar_alltalk) == 1)
        {
                giSpeakFlags[id] = SPEAK_ALL;
        }
        else if((get_pcvar_num(pCvar_voice) == 1) && (get_user_flags(id) & LISTEN_VOICE))
        {
                giSpeakFlags[id] = SPEAK_LISTENALL;
        }
        else
        {
                giSpeakFlags[id] = SPEAK_NORMAL;
        }
}

set_speak(const iReceiver, const iSender, const bool:bListen)
{
        engfunc(EngFunc_SetClientListening, iReceiver, iSender, bListen)
        forward_return(FMV_CELL, bListen);
}
回复

使用道具 举报

发表于 2009-8-20 08:52:54 | 显示全部楼层 来自 广东深圳
我有~!~!~!
回复

使用道具 举报

发表于 2009-8-20 08:54:39 | 显示全部楼层 来自 广东深圳
http://cschina.home.sunbo.net/sh ... VCVD31&xpos=149
到这里去下吧,以前用过还不错
回复

使用道具 举报

游客
回复
您需要登录后才可以回帖 登录 | 注个册吧

快速回复 返回顶部 返回列表