justn Posted March 23, 2014 Share Posted March 23, 2014 So i have created admins tag script. i need help with one thing.. This is when the player outputs the chatbox outputChatBox ( "#FF0000* #999999[Owner] " .. getPlayerName ( source ) .. ":#FFFFFF " .. msg, getRootElement(), r, g, b, true ) so what i need help with is, i want the player's name to be the color of his team. Link to comment
iPrestege Posted March 23, 2014 Share Posted March 23, 2014 So i have created admins tag script. i need help with one thing..This is when the player outputs the chatbox outputChatBox ( "#FF0000* #999999[Owner] " .. getPlayerName ( source ) .. ":#FFFFFF " .. msg, getRootElement(), r, g, b, true ) so what i need help with is, i want the player's name to be the color of his team. getTeamColor getPlayerTeam https://wiki.multitheftauto.com/wiki/ToHex Link to comment
Weii. Posted March 23, 2014 Share Posted March 23, 2014 if (getPlayerTeam(source)) then r,g,b = getTeamColor(getPlayerTeam(source)) outputChatBox ( "#FF0000* [Owner] "..RGBToHex(r,g,b) .. getPlayerName ( source ) .. ":#FFFFFF " .. msg, getRootElement(), r, g, b, true ) end function RGBToHex(red, green, blue, alpha) if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255) or (alpha and (alpha < 0 or alpha > 255))) then return nil end if(alpha) then return string.format("#%.2X%.2X%.2X%.2X", red,green,blue,alpha) else return string.format("#%.2X%.2X%.2X", red,green,blue) end end Link to comment
cheez3d Posted March 23, 2014 Share Posted March 23, 2014 addEventHandler("onPlayerChat",root,function(message,_type) if _type == 0 then cancelEvent() local color = getPlayerTeam(source) and {getTeamColor(getPlayerTeam(source))} or {255,255,255} color = string.format("#%X%X%X",color[1],color[2],color[3]) outputChatBox("#FF0000* #999999[Owner] "..color..getPlayerName(source)..":#FFFFFF "..message,root,255,255,255,true) outputServerLog("CHAT - "..getPlayerName(source).." - "..message) end end) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now