Например вот, надо чтобы тег [CHAT] был красным
Код:
#include <amxmodx>
#include <colorchat>
#define TAGS // Теги в чате Гл. Админ | Админ | VIP [ По умолчанию включен ]
#define GREEN_MSG // Зеленый цвет чата админов и випов [ По умолчанию выключен ]
#define AES // Поддержка системы армейских званий - AES ( https://c-s.net.ua/forum/topic56564.html ) [ По дефолту выключен ]
// #define DEF_RUS // Русский язык по умолчанию [ По умолчанию английский ]
#define GL_ADMIN ADMIN_RCON // Флаг доступа для тега "Гл. Админ" в чате
#define ADMIN ADMIN_BAN // Флаг доступа для тега "Админ" в чате || Просмотр всего чата
#define VIP ADMIN_LEVEL_H // Флаг доступа для тега "VIP" в чате
// #define LOG_MESSAGE // Логирование чата в HLDS логи
// #define FIX_CRASH // Костыль от падения сервера с ошибкой о превышении 192 байтов. Дак вот, включать ТОЛЬКО если сервер падает.
// у меня так и не получилось уронить свой без фикса...
#if defined AES
#include <aes_main>
#endif
#define get_bit(%1,%2) (%1 & (1 << (%2 & 31)))
#define set_bit(%1,%2) %1 |= (1 << (%2 & 31))
#define clr_bit(%1,%2) %1 &= ~(1 << (%2 & 31))
new iPlayerRus[33]
new iIgnorePlayer
new const eng[][] = { "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","{","}",":",'"',"<",">","~","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","[","]",";","'",",",".","`","?","/","@","$","^^","&" };
new const rus[][] = { "Ф","И","С","В","У","А","П","Р","Ш","О","Л","Д","Ь","Т","Щ","З","Й","К","Ы","Е","Г","М","Ц","Ч","Н","Я","Х","Ъ","ж","Э","Б","Ю","Ё","ф","и","с","в","у","а","п","р","ш","о","л","д","ь","т","щ","з","й","к","ы","е","г","м","ц","ч","н","я","х","ъ","ж","э","б","ю","ё",",",".","'",";", ":","?" };
public plugin_init()
{
#define VERSION "2.5.7b"
register_plugin("Lite Translit", VERSION, "neygomon")
register_cvar("lt_version", VERSION, FCVAR_SERVER | FCVAR_SPONLY)
register_clcmd("say /rus", "LangRus")
register_clcmd("say /eng", "LangEng")
register_clcmd("say", "Say_Handler")
register_clcmd("say_team", "SayTeam_Handler")
}
public client_putinserver(id)
{
if(is_user_hltv(id) || is_user_bot(id))
{
set_bit(iIgnorePlayer, id)
return
}
#if defined DEF_RUS
iPlayerRus[id] = true
#endif
}
public client_disconnect(id)
clr_bit(iIgnorePlayer, id)
public LangRus(id)
{
if(!iPlayerRus[id])
{
iPlayerRus[id] = true
ColorChat(id, RED, "[CHAT] РУССКИЙ ЧАТ ВКЛЮЧЕН ***")
}
else ColorChat(id, RED, "[CHAT] РУССКИЙ ЧАТ УЖЕ ВКЛЮЧЕН ***")
}
public LangEng(id)
{
if(iPlayerRus[id])
{
iPlayerRus[id] = false
ColorChat(id, RED, "[CHAT] АНГЛИЙСКИЙ ЧАТ ВКЛЮЧЕН ***")
}
else ColorChat(id, RED, "[CHAT] АНГЛИЙСКИЙ ЧАТ УЖЕ ВКЛЮЧЕН ***")
}
public Say_Handler(id)
return FormatMsg(id, false)
public SayTeam_Handler(id)
return FormatMsg(id, true)
public FormatMsg(id, bool:is_say_team)
{
if(get_bit(iIgnorePlayer, id)) return PLUGIN_CONTINUE
static szMessage[128]
read_args(szMessage, charsmax(szMessage))
remove_quotes(szMessage)
if(!szMessage[0] || szMessage[0] == '/') return PLUGIN_HANDLED_MAIN; // ⬮𐴱 桱즸 ࡷ᳥
if(iPlayerRus[id])
{
for(new i; i < sizeof eng; i++)
replace_all2(szMessage, charsmax(szMessage), eng[i], rus[i])
}
static iLen, szFormatTags[96], iAlive, iTeam; iAlive = is_user_alive(id), iTeam = get_user_team(id)
if(is_say_team)
{
switch(iTeam)
{
case 1: iLen = formatex(szFormatTags, charsmax(szFormatTags), "^1%s", iAlive ? "" : "")
case 2: iLen = formatex(szFormatTags, charsmax(szFormatTags), "^1%s", iAlive ? "" : "")
case 3: iLen = formatex(szFormatTags, charsmax(szFormatTags), "^1")
}
}
else
{
if(iTeam == 3) iLen = formatex(szFormatTags, charsmax(szFormatTags), "^1")
else iLen = formatex(szFormatTags, charsmax(szFormatTags), "%s", iAlive ? "^1" : "^1")
}
#if defined AES
static AESLvl[33][64], aStats[AES_ST_END]
aes_get_player_stats(id, aStats)
aes_get_level_name(aStats[AES_ST_LEVEL], AESLvl[id], 63, LANG_SERVER)
iLen += formatex(szFormatTags[iLen], charsmax(szFormatTags) - iLen, "^4[%s] ", AESLvl[id])
#endif
#if defined TAGS
static const szAdminPrefix[][] = { "", "^4[Вожак] ", "^4[Админ] ", "^4[V.I.P] " }
iLen += formatex(szFormatTags[iLen], charsmax(szFormatTags) - iLen, "%s", szAdminPrefix[CheckFlags(id)])
#endif
#if defined GREEN_MSG
if(CheckFlags(id)) iLen += formatex(szFormatTags[iLen], charsmax(szFormatTags) - iLen, "^3%%s1^1 : ^4")
else iLen += formatex(szFormatTags[iLen], charsmax(szFormatTags) - iLen, "^3%%s1^1 : ")
#else
iLen += formatex(szFormatTags[iLen], charsmax(szFormatTags) - iLen, "^3%%s1^1 : ")
#endif
#if defined FIX_CRASH
/* Костыль :D || "Fix" crash on 192 bytes */
if(strlen(szFormatTags) + strlen(szMessage) >= 190)
{
client_print(id, print_center, "*** АЙ-ЯЙ-ЯЙ! СООБЩЕНИЕ СЛИШКОМ ДЛИННОЕ ***");
return PLUGIN_HANDLED;
}
/* End fix */
#endif
static players[32], pcount; get_players(players, pcount, "c")
if(is_say_team)
{
for(new i; i < pcount; i++)
if(get_user_flags(id) & ADMIN || (iTeam == get_user_team(players[i]) && iAlive == is_user_alive(players[i])))
PrintChat(players[i], id, szFormatTags, szMessage)
}
else
{
for(new i; i < pcount; i++)
PrintChat(players[i], id, szFormatTags, szMessage)
}
#if defined LOG_MESSAGE
static authid[32], userteam[16], username[32]
get_user_name(id, username, 31)
get_user_authid(id, authid, 31)
get_user_team(id, userteam, 15)
log_message("^"%s<%d><%s><%s>^" %s ^"%s^"", username, get_user_userid(id), authid, userteam, is_say_team ? "say_team" : "say" , szMessage)
#endif
return PLUGIN_HANDLED
}
stock PrintChat(const iReceiver, const iSender, const szTags[], const szMessage[])
{
static StrSend[191]; formatex(StrSend, charsmax(StrSend), "%s %%s2", szTags)
message_begin(MSG_ONE_UNRELIABLE, 76, _, iReceiver)
write_byte(iSender)
write_string(StrSend)
write_string("")
write_string(szMessage)
message_end()
}
stock CheckFlags(id)
{
static iFlags
iFlags = get_user_flags(id)
if(iFlags & GL_ADMIN) return 1
else if(iFlags & ADMIN) return 2
else if(iFlags & VIP) return 3
return 0
}
stock replace_all2(string[], len, const what[], const with[])
{
new pos
if((pos = contain(string, what)) == -1) return 0
new total, with_len = strlen(with), diff = strlen(what) - with_len, total_len = strlen(string), temp_pos
while(total_len + with_len < len && replace(string[pos], len - pos, what, with) != 0)
{
total++
pos += with_len
total_len -= diff
if (pos >= total_len) break
temp_pos = contain(string[pos], what)
if (temp_pos == -1) break
pos += temp_pos
}
return total
}