I removed everything from on PlayerChat function as other would never understand.
I Would like to set the players name to be the color of his/her/gender-neutral team color
Therefore I would like to know if there is a better way then the option I choose?
function onPlayerChat( player, text )
{
local White = "[#ffffff]", pTeam = TeamColour( player.Team )
Message( "[" + player.ID + "] " + pTeam + player + ": " + White + text );
}
function TeamColour( id )
{
switch(id)
{
case 0: return "[#c0c0c0]";
case 1: return "[#ff8000]";
case 2: return "[#fb00fb]";
case 3: return "[#00d7d7]";
case 4: return "[#ffff00]";
case 5: return "[#ff4c4c]";
case 6: return "[#aaadf1]";
case 7: return "[#ff2e97]";
case 8: return "[#ffbfa0]";
case 9: return "[#ffc4e2]";
case 10: return "[#ac7a38]";
case 11: return "[#ffffce]";
case 12: return "[#06a4ba]";
case 13: return "[#8cff8c]";
case 14: return "[#94a969]";
case 15: return "[#00008c]";
case 16: return "[#ffffff]";
default: return "[#d]";
}
}
What comes to mind is player.Colour and format.
Untested:
function onPlayerChat( player, text )
{
local White = "[#ffffff]", pColour = player.Colour, pTeam = format("[#%02X%02X%02X]", pColour.r, pColour.g, pColour.b);
Message( "[" + player.ID + "] " + pTeam + player + ": " + White + text );
}
There is rgb to hex function as on the forum as i know.
I more like to use Team class with rgb, hex and annonce colors for each team.
Okay I ran many test. And It appears that the issue is the fact on server side player.Colour is not set. I could be wrong...??
Always returns white, I guess its due to player.Colour is a instance when not set?
http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions/AddClass
With server side scripting the class can be set with colors.
Works like magic, Thanks
@Thijn