Thread: [Solved] [REQ - TF2]Team name colored
View Single Post
Mayor Gamer
Senior Member
Join Date: Nov 2012
Location: GetLocationOfUser(me);
Old 08-19-2016 , 19:53   Re: [REQ - TF2]Team name colored
Reply With Quote #2

Hey there!

First, when you need to send code trough a forum post, wrap it around with the [CODE].

Code:
/** 
 * Returns the hexadecimal representation of a client's team color (will NOT initialize the trie, so if you use only this function from this include file, your plugin's memory usage will not increase) 
 * 
 * @param client        Client to get the team color for 
 * @return                Client's team color in hexadecimal, or green if unknown 
 * On error/Errors:        If the client index passed is invalid or not in game. 
 */ 
stock CGetTeamColor(client)
According to More Colors, this function returns the color in HEX code. So instead of COLOR_BLUE or COLOR_RED, it has to be TF2's team color's HEX codes, which are:

RED Team: FF4040
BLU Team: 99CCFF

So the code instead would be:

Code:
#include <sourcemod>
#include <morecolors>

public Plugin myinfo =
{
	name = "[TF2] Change Team Chat Colors",
	url = "https://forums.alliedmods.net/showthread.php?t=286558"
};

public OnPluginStart()
{
	AddCommandListener(ChatTriggers, "say");
	AddCommandListener(ChatTriggers, "say_team");
}

public Action ChatTriggers(int client, const String:command[], int argc)
{
	decl String:sMessage[255];
	decl String:sClientName[64];

	GetCmdArgString(sMessage, sizeof(sMessage));
	GetClientName(client, sClientName, sizeof(sClientName));
	StripQuotes(sMessage);

	if (CGetTeamColor(client) == 99CCFF)
	{
		CPrintToChatEx(client, client, "{steelblue}%s {default}: %s", sClientName, sMessage)
	}
	else if (CGetTeamColor(client) == FF4040)
	{
		CPrintToChatEx(client, client, "{brown}%s {default}: %s", sClientName, sMessage)
	}
}
No need to return Plugin_Handled since that would just not show the chat say (I think...)

Hope it helps! Didn't test this.
__________________
Mayor Gamer is offline