Raised This Month: $12 Target: $400
 3% 

How to print red on the chat?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Alon2k2
Junior Member
Join Date: Apr 2010
Old 11-20-2023 , 14:07   How to print red on the chat?
Reply With Quote #1

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();
			}
		}
	}
}

Last edited by Alon2k2; 11-20-2023 at 15:05.
Alon2k2 is offline
bigdaddy424
Senior Member
Join Date: Oct 2021
Location: Jupiter
Old 11-20-2023 , 19:07   Re: How to print red on the chat?
Reply With Quote #2

https://www.amxmodx.org/api/amxmodx/client_print_color
__________________
bigdaddy424 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-20-2023 , 23:46   Re: How to print red on the chat?
Reply With Quote #3

IIRC, you can't have any two team colors in the same message.
__________________
fysiks is online now
Hakim Azizov
Member
Join Date: Mar 2023
Old 11-26-2023 , 13:04   Re: How to print red on the chat?
Reply With Quote #4

Quote:
Originally Posted by Alon2k2 View Post
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")
Hakim Azizov is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:06.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode