well this is based on x-olent's plugin on Admin Chat and i tried to tweak it.
i got far but hit a roadblock.
the problem is that, the Chat color is the same as the name.
i want the name to be the same color as the team and the chat color to be the color i want according to its admin level.
Code:
#define PLUGIN "Admin LeveL ChaT!"
#define VERSION "1.0"
#define AUTHOR "SlaMX"
#define ACCESS_MOD ADMIN_SLAY
#define ACCESS_SMOD ADMIN_BAN
#define ACCESS_ADMIN ADMIN_RESERVATION
#define ACCESS_OWNER ADMIN_IMMUNITY
#include <amxmodx>
#include <amxmisc>
new MaxPlayers;
new pCvar_enabled;
new MsgSayText;
new MsgTeamInfo;
new const ColorLevels[] =
{
ACCESS_OWNER,
ACCESS_ADMIN,
ACCESS_SMOD,
ACCESS_MOD,
ADMIN_ALL
};
new const ColorCode[][] =
{
"^x03", // grey
"^x04",
"^x03", // Red
"^x03", // Blue
""
};
new const Admintag[][] =
{
"^x04[O]^x03",
"^x04[A]^x03",
"^x04[S]^x03",
"^x04[M]^x03",
""
};
new const ColorTeams[][] =
{
"SPECTATOR",
"",
"TERRORIST",
"CT",
""
};
new const TeamNames[][] =
{
"Spectator",
"Terrorist",
"Counter-Terrorist",
"Spectator"
};
public plugin_init()
{
register_plugin("Admin Leveled Chat", "1.0", "SlamX");
register_clcmd("say", "handle_say");
register_clcmd("say_team", "handle_teamsay");
pCvar_enabled = register_cvar("amx_alc_enabled", "1");
MaxPlayers = get_maxplayers();
MsgSayText = get_user_msgid("SayText");
MsgTeamInfo = get_user_msgid("TeamInfo");
}
public handle_say(id)
{
if(!get_pcvar_num(pCvar_enabled))
return PLUGIN_CONTINUE;
static Message[192];
read_args(Message, 191);
remove_quotes(Message);
static bool:Admin;
Admin = has_color_chat(id);
static ChatColor, Alive, i;
ChatColor = get_chat_color(id);
Alive = is_user_alive(id);
static Name[32], Team[32], Team2[32];
get_user_name(id, Name, 31);
get_user_team(id, Team, 31);
format(Message, 191, "%s%s%s ^x01: %s %s",\
Alive ? "" : "^x01*DEAD*",\
Admin ? Admintag[ChatColor] : "^x03",\
Name,\
Admin ? ColorCode[ChatColor] : "",\
Message);
for(i = 1; i <= MaxPlayers; i++)
{
if(!is_user_connected(i))
continue;
if(Alive == is_user_alive(i)
|| (get_user_flags(i)))
{
get_user_team(i, Team2, 31);
handle_message(i, Team, Team2, ChatColor, Message);
}
}
return PLUGIN_HANDLED;
}
public handle_teamsay(id)
{
if(!get_pcvar_num(pCvar_enabled))
return PLUGIN_CONTINUE;
static Message[192];
read_args(Message, 191);
remove_quotes(Message);
static bool:Admin;
Admin = has_color_chat(id);
static ChatColor, Alive, iTeam, i;
ChatColor = get_chat_color(id);
Alive = is_user_alive(id);
iTeam = get_user_team(id);
static Name[32], Team[32], Team2[32];
get_user_name(id, Name, 31);
get_user_team(id, Team, 31);
format(Message, 191, "^x01%s(%s)%s %s^x01 : %s %s",\
Alive ? "" : "*DEAD*",\
TeamNames[iTeam],\
Admin ? Admintag[ChatColor] : "^x03",\
Name,\
Admin ? ColorCode[ChatColor] : "",\
Message);
for(i = 1; i <= MaxPlayers; i++)
{
if(!is_user_connected(i))
continue;
get_user_team(i, Team2, 31);
if(!equali(Team, Team2))
continue;
if(Alive == is_user_alive(i)
|| get_user_flags(i))
{
handle_message(id, Team, Team2, ChatColor, Message);
}
}
return PLUGIN_HANDLED;
}
bool:has_color_chat(const id)
{
static Flags, i;
Flags = get_user_flags(id);
for(i = 1; i < sizeof ColorLevels; i++)
{
if(Flags & ColorLevels[i])
return true;
}
return false;
}
get_chat_color(const id)
{
static Flags, i;
Flags = get_user_flags(id);
for(i = 1; i < sizeof ColorLevels; i++)
{
if(Flags & ColorLevels[i])
return i;
}
return 0;
}
handle_message(const id, const Team[], const Team2[], const ChatColor, const Message[])
{
if(equali(ColorCode[ChatColor], "^x03") && !equali(ColorTeams[ChatColor], Team2))
{
//show_TeamInfo_msg(id, ColorTeams[ChatColor]);
show_SayText_msg(id, Message);
//show_TeamInfo_msg(id, Team2);
}
else if(!equali(Team, Team2) && !ChatColor)
{
//show_TeamInfo_msg(id, Team);
show_SayText_msg(id, Message);
//show_TeamInfo_msg(id, Team2);
}
else
{
show_SayText_msg(id, Message);
}
return 1;
}
show_TeamInfo_msg(const id, const Team[])
{
message_begin(MSG_ONE, MsgTeamInfo, _, id);
write_byte(id);
write_string(Team);
message_end();
}
show_SayText_msg(const id, const Message[])
{
message_begin(MSG_ONE, MsgSayText, _, id);
write_byte(id);
write_string(Message);
message_end();
}
yea i know I'm new to this so don't flame.