View Single Post
Shooting King
RAAASENGAN
Join Date: Mar 2012
Location: India
Old 07-09-2013 , 04:37   Re: Approved Admin Chat Plugin
Reply With Quote #20

Admin Color Say
PHP Code:
/************************************************************************************

            Admin Color Say
                    - Shooitng King
                    - ConnorMcLeod ( Stock )
    Cvars:
        Color Nums :
                1 - Normal
                2 - Green
                3 - Red
                4 - Blue
                5 - White
                6 - Team Color        

        1. acs_ncolor <num> Default: 3
        2. acs_mcolor <num> Default: 2

    NOTE:
        - Color 3, 4, 5 can be used for either of the cvars not for BOTH.
        - If you keep both the cvars to 3, 4, 5 then the Message will be uniformly
          coloured according to acs_ncolor cvar.
                
************************************************************************************/     

#include <amxmodx>

#define PLUGIN        "Admin Color Say"
#define VERSION        "1.7"
#define AUTHOR        "Shooting King"

new pcvar_NameColorpcvar_MsgColor;
new 
gizLTeam;
new 
gSayTextgTeamInfo;

new 
gszTeams[][] = {

    
"",
    
"TERRORIST",
    
"CT",
    
"SPECTATOR"
}

public 
plugin_init()
{
    
register_pluginPLUGINVERSIONAUTHOR );
    
    
register_clcmd"say""cmdSay" );
    
register_clcmd"say_team""cmdTSay" );
    
pcvar_NameColor register_cvar"acs_ncolor""3" );
    
pcvar_MsgColor register_cvar"acs_mcolor""2" );
    
    
gSayText get_user_msgid("SayText");
    
gTeamInfo get_user_msgid("TeamInfo");
}

public 
cmdSay(id)
{
    static 
szMsg[192]
    
read_args(szMsg191);

    if((
get_user_flags(id) & ADMIN_CHAT) && (strlen(szMsg) > 0))
    {
        
PostSay(id0szMsg);
        return 
PLUGIN_HANDLED_MAIN;
    }
    return 
PLUGIN_CONTINUE;
}

public 
cmdTSay(id)
{
    static 
szMsg[192]
    
read_args(szMsg191);

    if((
get_user_flags(id) & ADMIN_CHAT) && (strlen(szMsg) > 0))
    {
        
PostSay(id1szMsg);
        return 
PLUGIN_HANDLED_MAIN;
    }
    return 
PLUGIN_CONTINUE;
}

public 
PostSay(idisTeamMsgszMessage[])
{
    static 
szPostMessage[192], szName[32], szTeam[32], szStatus[8], iTeamg_NColorg_MColor;//, iPos, szPostName[128];
    
static szNColor[8], szMColor[8];    
    
g_NColor get_pcvar_num(pcvar_NameColor);
    
g_MColor get_pcvar_num(pcvar_MsgColor);

    
get_user_nameidszName31);
    
remove_quotes(szMessage);
    
iTeam get_user_team(id);
    
    if( !
iTeam )
    {
        
iTeam 3;
    }    
    
szTeam[0] = '^0';
    
szStatus[0] = '^0';
    
    switch (
g_NColor)
    {
        case 
1szNColor "^x01";
        case 
2:    szNColor "^x04";
        default:
szNColor "^x03";
    }
    switch (
g_MColor)
    {    
        case 
1szMColor "^x01";
        case 
2:    szMColor "^x04";
        default:
szMColor "^x03";        
    }

    if( 
isTeamMsg )
    {
        
addszTeamcharsmax(szTeam), "(" );
        if(
iTeam == 2)
        {
            
addszTeamcharsmax(szTeam), "Counter-Terrorist" );
        }
        else
        {
            
addszTeamcharsmax(szTeam), gszTeams[iTeam]);
            
strtolower(szTeam);
            
szTeam[1] -= 32;            
        }
        
addszTeamcharsmax(szTeam), ") " );
    }
    
    if(!
is_user_alive(id) && iTeam != 3)
    {
        
szStatus "*DEAD*";
    }
    else if(!
is_user_alive(id) && iTeam == 3)
    {
        
szStatus "*SPEC*";
    }

    
formatexszPostMessagecharsmax(szPostMessage), "^x01%s%s%s%s : %s%s"szStatusszTeamszNColorszNameszMColorszMessage );
    
    if( !
isTeamMsg )
    {
        
iTeam 0;
    }
    
    if( 
<= g_NColor <= )
    {
        
Client_Print_All((g_NColor-2), iTeam"%s"szPostMessage);
    }
    else if( 
<= g_MColor <= )
    {
        
Client_Print_All((g_MColor-2), iTeam"%s"szPostMessage);
    }
    else
    {
        
Client_Print_All0iTeam"%s"szPostMessage);
    }
    return 
PLUGIN_HANDLED;
}

stock Client_Print_All( const Color, const isTeamMsg, const input[], any:...)
{
    static 
szPlayers[32], iCountitemp
    static 
szMsg[192];
    
vformat(szMsg191input4);
    
    if(
isTeamMsg)
    {
        
get_players(szPlayersiCount"ceh"gszTeams[isTeamMsg]);
    }
    else
    {
        
get_players(szPlayersiCount"ch");
    }

    for( 
i=0iCounti++ )
    {
        
temp szPlayers[i];
        if(
is_user_connected(temp))
        {
            if( 
Color && Color != get_user_team(temp) )
            {
                
gizLTeam get_user_team(temp);
                
ChangeTeamInfo(tempColor);
            }
    
            
message_begin(MSG_ONE_UNRELIABLEgSayText_temp);
            
write_byte(temp);
            
write_string(szMsg);
            
message_end();

            if( 
gizLTeam )
            {
                
ChangeTeamInfo(tempgizLTeam);
                
gizLTeam 0;
            }            
        }
    }
}

stock ChangeTeamInfo(iPlayeriTeam)
{
    
message_begin(MSG_ONE_UNRELIABLEgTeamInfo_iPlayer);    
    
write_byte(iPlayer);                
    
write_string(gszTeams[iTeam]);                
    
message_end();    

Cvars :

Color Numbers :
  • 1 - Normal
  • 2 - Green
  • 3 - Red
  • 4 - Blue
  • 5 - White
  • 6 - Team Color

- acs_ncolor <num> Default: 3
- acs_mcolor <num> Default: 2

NOTE :

- Color 3, 4, 5 can be used for either of the cvars not for BOTH.
- If you keep both the cvars to 3, 4, 5 then the Message will be uniformly
coloured according to acs_ncolor cvar.

Credits :
ConnorMcLeod - Stock [Modified to meet the needs of this plugin]

Changes :

1. Added Dead and Spec Tags.
2. Added Team Chat.
3. Some Code cleanings.
4. Fixed bug as reported by medow (Thanks).
Attached Files
File Type: sma Get Plugin or Get Source (admin_color_say.sma - 525 views - 4.1 KB)
File Type: sma Get Plugin or Get Source (admin_color_say1.6.sma - 508 views - 4.1 KB)
File Type: sma Get Plugin or Get Source (admin_color_say1.7.sma - 443 views - 4.3 KB)
__________________
As every time said, don't ever UNDERESTIMATE me.

Donate - Here

Last edited by Shooting King; 04-05-2014 at 13:58.
Shooting King is offline