Question about colours for messages

Started by Fjose, Nov 20, 2014, 02:52 PM

Previous topic - Next topic

Fjose


local prefix = "", col = GetTeamRGB( player.Team );
if ( p.Admin == 3 ) prefix = "[#49B3DE][Moderator] [#FFF]";
ClientMessageToAll( prefix + player.Name + ": [#FFFFFF]" + text, col.r, col.g, col.b );

In the onplayerchat function I was putting the colours for each skin to show it in this function. skin colours are in RGB, if the player is not an admin the message is shows as i want but when is admin the name changes to the prefix colour, I was trying stop the prefix colour but without good results :/

I want stop the prefix colour then the server will take the rgb colour for the message.

Thijn

You can convert those R, G, B values to an HTML color code using the format function:
local r = 0;
local g = 255;
local b = 0;

local hex = format("#%02X%02X%02X", r, g, b);
print( "R: " + r + ", G: " + g + ", B: " + b + ", HEX: " + hex );
Returns R: 0, G: 255, B: 0, HEX: #00FF00

So for your code, this should work:
local prefix = "", col = GetTeamRGB( player.Team ), colHex = format("#%02X%02X%02X", col.r, col.g, col.b);
if ( p.Admin == 3 ) prefix = "[#49B3DE][Moderator] [" + colHex + "]";
ClientMessageToAll( prefix + player.Name + ": [#FFFFFF]" + text, col.r, col.g, col.b );
Untested.

Fjose