#include <amxmodx>
#if AMXX_VERSION_NUM < 183
#include <colorchat>
new g_iMaxPlayers;
#else
#define DontChange print_team_default
#define Blue print_team_blue
#define Red print_team_red
#define Grey print_team_grey
#define ColorChat client_print_color
#define g_iMaxPlayers MaxClients
#endif
new const g_sChannel[][] =
{
"^1(Counter-Terrorist) ",
"^1(Terrorist) ",
"^1*DEAD*(Counter-Terrorist) ",
"^1*DEAD*(Terrorist) ",
"^1(Spectator) ",
"^1",
"^1*DEAD* ",
"^1*SPEC* "
};
enum _:PrefData
{
g_iFlags,
g_sPrefix[32]
};
static const g_sPrefFlags[][PrefData] = { { ADMIN_RESERVATION, "^1[^4ADMIN^1] " }, { ADMIN_LEVEL_H, "^1[^4VIP^1] " } };
public plugin_init()
{
register_plugin("[FG] AllChat", "1.0", "maeStro");
register_clcmd("say", "say_chat");
register_clcmd("say_team", "say_team_chat");
#if AMXX_VERSION_NUM < 183
g_iMaxPlayers = get_maxplayers();
#endif
}
public say_chat(id)
return to_chat(id, 0);
public say_team_chat(id)
return to_chat(id, 1);
public to_chat(id, teamchat)
{
new sMessage[192];
read_args(sMessage, charsmax(sMessage));
remove_quotes(sMessage);
replace_all(sMessage, charsmax(sMessage), "", "");
replace_all(sMessage, charsmax(sMessage), "", "");
replace_all(sMessage, charsmax(sMessage), "%", "");
replace_all(sMessage, charsmax(sMessage), "#", "");
trim(sMessage);
if(!sMessage[0] || sMessage[0] == '/') return 1;
new sChannel[64];
new sName[32]; get_user_name(id, sName, charsmax(sName));
new bool:bAlive = bool:is_user_alive(id);
new iTeam = get_user_team(id);
new iFlags = get_user_flags(id);
if(~iFlags & ADMIN_USER)
{
for(new i; i < sizeof(g_sPrefFlags); i++)
{
if(iFlags & g_sPrefFlags[i][g_iFlags])
{
add(sChannel, charsmax(sChannel), g_sPrefFlags[i][g_sPrefix]);
break;
}
}
}
switch(teamchat)
{
case 1:
{
switch(iTeam)
{
case 1: add(sChannel, charsmax(sChannel), g_sChannel[bAlive ? 1 : 3]);
case 2: add(sChannel, charsmax(sChannel), g_sChannel[bAlive ? 0 : 2]);
default: add(sChannel, charsmax(sChannel), g_sChannel[4]);
}
}
default: add(sChannel, charsmax(sChannel), g_sChannel[bAlive ? 5 : iTeam != 3 ? 6 : 7]);
}
for(new i = 1; i <= g_iMaxPlayers; i++)
{
if(!is_user_connected(i)) continue;
if(/*(!bAlive && !is_user_alive(i) || bAlive) && */ (!teamchat || teamchat && iTeam == get_user_team(i)))
{
client_print(i, print_notify, "%s : %s", sName, sMessage);
ColorChat(i, id, "^1%s^3%s ^1: %s", sChannel, sName, sMessage);
}
}
new sAuthId[35]; get_user_authid(id, sAuthId, charsmax(sAuthId));
log_message("^"%s<%d><%s><%s>^" say%s ^"%s^"%s", sName, get_user_userid(id), sAuthId, iTeam == 1 ? "TERRORIST" : iTeam == 2 ? "CT" : "SPECTATOR", teamchat ? "_team" : "", sMessage, bAlive ? "" : " (dead)");
return 1;
}