Member
|

11-26-2023
, 14:04
Re: How to print red on the chat?
|
#4
|
Quote:
Originally Posted by Alon2k2
Hi,
I have a problem, I can't print the red color and the color of the opponent against me, here is my code, what could be the problem?
Code:
stock Color(const id, const input[], any:... )
{
new count = 1, players[32];
static msg[191];
vformat(msg, 190, input, 3);
replace_all(msg, 190, "!g", "^4"); // Green Color
replace_all(msg, 190, "!d", "^1"); // Default Color
replace_all(msg, 190, "!t", "^3"); // Team Color
replace_all(msg, 190, "!t2", "^0");
if (id) players[0] = id; else get_players(players, count, "ch");
{
for (new i = 0; i < count; i++)
{
if (is_user_connected(players[i]))
{
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);
write_byte(players[i]);
write_string(msg);
message_end();
}
}
}
}
|
maybe, this can help u
Code:
// Stock: ZE Color Print
stock ze_color_p(index, const text[], any:...)
{
new const teams[][] = {"", "TERRORIST", "CT", "SPECTATOR"}
new msg[128], main_team, team[100]
vformat(msg, charsmax(msg), text, 3)
if (containi(msg, "!t") != -1)
team = "CT"
else if (containi(msg, "!y") != -1)
team = "TERRORIST"
else if (containi(msg, "!d") != -1)
team = "SPECTATOR"
replace_all(msg, charsmax(msg), "!g", "^x04")
replace_all(msg, charsmax(msg), "!n", "^x01")
replace_all(msg, charsmax(msg), "!t", "^x03")
replace_all(msg, charsmax(msg), "!y", "^x03")
replace_all(msg, charsmax(msg), "!d", "^x03")
if (index == 0)
{
for (new id = 1; id <= get_maxplayers(); id++)
{
if (!is_user_connected(id))
continue
main_team = get_user_team(id)
team_info(id, MSG_ONE, team)
show_color_message(id, MSG_ONE, msg)
team_info(id, MSG_ONE, teams[main_team])
}
}
else
{
main_team = get_user_team(index)
team_info(index, MSG_ONE, team)
show_color_message(index, MSG_ONE, msg)
team_info(index, MSG_ONE, teams[main_team])
}
}
// Stock: Show Color Message
stock show_color_message(id, type, message[])
{
new bool:saytext_used, get_user_msgid_saytext
if (!saytext_used)
{
get_user_msgid_saytext = get_user_msgid("SayText")
saytext_used = true
}
message_begin(type, get_user_msgid_saytext, _, id)
write_byte(id)
write_string(message)
message_end()
}
// Stock: Team Info
stock team_info(id, type, team[])
{
new bool:teaminfo_used, get_user_msgid_teaminfo
if (!teaminfo_used)
{
get_user_msgid_teaminfo = get_user_msgid("TeamInfo")
teaminfo_used = true
}
message_begin(type, get_user_msgid_teaminfo, _, id)
write_byte(id)
write_string(team)
message_end()
}
ze_color_p(id,"!tThis is blue message")
ze_color_p(id,"!yThis is red message")
ze_color_p(id,"!rThis is grey message")
ze_color_p(id,"!gThis is green message")
ze_color_p(id,"This is normal message")
|
|