[color chat]
Posted: Sun Sep 13, 2026 6:37 am
Hi everyone, I just make another code can show color chat, I test it ,and work well, so I post it
color settings:
0 -- Don't change
1 -- Red color
2 -- Blue color
3 -- Grey color
Code: Select all
/*
*
* @param id -- set 0 to all player on server, else to one player who index equal id.
* @param cid -- get the color index, don't set it equal 0.
* @param color -- set the color (0 -- don't change; 1 -- Red color; 2 -- Blue color; 3 -- Grey color)
* @param message -- cons message.
*
*/
public print_color(id, cid, color, const message[], any:...)
{
new msg[192]
vformat(msg, charsmax(msg), message, 5)
/* //if you want to use ML, enable
replace_all(msg, charsmax(msg), "!g", "^x04")
replace_all(msg, charsmax(msg), "!n", "^x01")
replace_all(msg, charsmax(msg), "!t", "^x03")*/
new param
if (!cid) return
else param = cid
new team[32]
get_user_team(param, team, 31)
switch (color)
{
case 0: msg_teaminfo(param, team)
case 1: msg_teaminfo(param, "TERRORIST")
case 2: msg_teaminfo(param, "CT")
case 3: msg_teaminfo(param, "SPECTATOR")
}
if (id) msg_saytext(id, param, msg)
else msg_saytext(0, param, msg)
if (color != 0) msg_teaminfo(param, team)
}
msg_saytext(id, cid, msg[])
{
message_begin(id?MSG_ONE:MSG_ALL, get_user_msgid("SayText"), {0,0,0}, id)
write_byte(cid)
write_string(msg)
message_end()
}
msg_teaminfo(id, team[])
{
message_begin(MSG_ONE, get_user_msgid("TeamInfo"), {0,0,0}, id)
write_byte(id)
write_string(team)
message_end()
} 0 -- Don't change
1 -- Red color
2 -- Blue color
3 -- Grey color