Just use below code as example:
Code:
#include <amxmodx>
new g_iMsgSayText
public plugin_init()
{
register_clcmd("say /test", "test_color")
register_clcmd("say_team /test", "test_color")
g_iMsgSayText = get_user_msgid("SayText")
}
public test_color(id)
{
print_colored(id, "!g[ZP] !yThis is testing !tcolor!")
}
stock print_colored(const index, const input [ ], const any:...)
{
new message[191]
vformat(message, 190, input, 3)
replace_all(message, 190, "!y", "^1")
replace_all(message, 190, "!t", "^3")
replace_all(message, 190, "!g", "^4")
if(index)
{
// Print to single person
message_begin(MSG_ONE, g_iMsgSayText, _, index)
write_byte(index)
write_string(message)
message_end()
}
else
{
// Print to all players
new players[32], count, i, id
get_players(players, count, "ch")
for( i = 0; i < count; i ++ )
{
id = players[i]
if(!is_user_connected(id)) continue;
message_begin(MSG_ONE_UNRELIABLE, g_iMsgSayText, _, id)
write_byte(id)
write_string(message)
message_end()
}
}
}
!g = Green color.
!y = Yellow color.
!t = Team color.