Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <cstrike>
#pragma semicolon 1
new g_mSayText;
public plugin_init() {
register_plugin("Admins Chat Prefix", "1.0", "sAiBoT");
register_clcmd( "say", "CmdSay" );
register_clcmd( "say_team", "CmdSay_Team" );
g_mSayText = get_user_msgid( "SayText" );
register_message( g_mSayText, "Hook_SayText" );
}
public Hook_SayText() {
return PLUGIN_HANDLED;
}
public CmdSay( id ) {
new flags = get_user_flags( id );
new typed[255];
read_argv( 1, typed, charsmax( typed ) );
remove_quotes( typed );
trim( typed );
if ( equal( typed, "" ) || ! is_user_connected( id ) )
return PLUGIN_HANDLED_MAIN;
if ( typed[0] == '@' || typed[0] == '/' || typed[0] == '!' )
return PLUGIN_CONTINUE;
new user_name[32];
get_user_name( id, user_name, 31 );
new msg[255], pre_prefix[32];
if ( cs_get_user_team( id ) == CS_TEAM_SPECTATOR )
copy( pre_prefix, 31, "*SPEC*" );
else {
if ( ! is_user_alive( id ) )
copy( pre_prefix, 31, "*DEAD*" );
}
new const the_format[] = "!n%s !g[%s] !t%s: !n%s";
if ( flags & ADMIN_RCON ) {
formatex( msg, 254, the_format, pre_prefix, "MASTER", user_name, typed );
client_print_color( 0, id, msg );
return PLUGIN_HANDLED_MAIN;
}
if ( flags & ADMIN_CVAR ) {
formatex( msg, 254, the_format, pre_prefix, "SENIOR", user_name, typed );
client_print_color( 0, id, msg );
return PLUGIN_HANDLED_MAIN;
}
if ( flags & ADMIN_BAN ) {
formatex( msg, 254, the_format, pre_prefix, "ADMIN", user_name, typed );
client_print_color( 0, id, msg );
return PLUGIN_HANDLED_MAIN;
}
formatex( msg, 254, "!n%s !t%s: !n%s", pre_prefix, user_name, typed );
client_print_color( 0, id, msg );
return PLUGIN_HANDLED_MAIN;
}
public CmdSay_Team( id ) {
new flags = get_user_flags( id );
new typed[255];
read_argv( 1, typed, charsmax( typed ) );
//remove_quotes( typed );
trim( typed );
if ( equal( typed, "" ) || ! is_user_connected( id ) )
return PLUGIN_HANDLED_MAIN;
if ( typed[0] == '@' || typed[0] == '/' || typed[0] == '!' )
return PLUGIN_CONTINUE;
new user_name[32];
get_user_name( id, user_name, 31 );
new msg[255], pre_prefix[32], prefix[32];
if ( ! is_user_alive( id ) )
copy( pre_prefix, 31, "*DEAD*" );
switch( cs_get_user_team( id ) ) {
case CS_TEAM_CT: copy( prefix, 31, "Counter-Terrorists" );
case CS_TEAM_T : copy( prefix, 31, "Terrorists" );
case CS_TEAM_SPECTATOR : copy( prefix, 31, "Spectator" );
}
new const the_format[] = "%s (%s) !g[%s] !t%s: !n%s";
if ( flags & ADMIN_RCON ) {
formatex( msg, 254, the_format, pre_prefix, "MASTER", prefix, user_name, typed );
client_print_color( 0, id, msg );
return PLUGIN_HANDLED_MAIN;
}
if ( flags & ADMIN_CVAR ) {
formatex( msg, 254, the_format, pre_prefix, "SENIOR", prefix, user_name, typed );
client_print_color( 0, id, msg );
return PLUGIN_HANDLED_MAIN;
}
if ( flags & ADMIN_BAN ) {
formatex( msg, 254, the_format, pre_prefix, "ADMIN", prefix, user_name, typed );
client_print_color( 0, id, msg );
return PLUGIN_HANDLED_MAIN;
}
formatex( msg, 254, "%s (%s) !t%s: !n%s", pre_prefix, prefix, user_name, typed );
new players[32], num, i;
for ( i = 0; i < num; i++ ) {
new ply = players[i];
if ( cs_get_user_team( ply ) == cs_get_user_team( id ) )
client_print_color( ply, id, msg );
}
return PLUGIN_HANDLED_MAIN;
}
stock client_print_color(id, sender, const text[], any:...) {
new g_iMsgidSayText;
g_iMsgidSayText = get_user_msgid("SayText");
new szMsg[191], iPlayers[32], iCount = 1;
vformat(szMsg, charsmax(szMsg), text, 3);
replace_all(szMsg, charsmax(szMsg), "!g","^x04");
replace_all(szMsg, charsmax(szMsg), "!n","^x01");
replace_all(szMsg, charsmax(szMsg), "!t","^x03");
if(id)
iPlayers[0] = id;
else
get_players(iPlayers, iCount, "ch");
for(new i = 0 ; i < iCount ; i++) {
if(!is_user_connected(iPlayers[i]))
continue;
message_begin(MSG_ONE_UNRELIABLE, g_iMsgidSayText, _, iPlayers[i]);
write_byte(sender);
write_string(szMsg);
message_end();
}
}