Fullton Posted April 2, 2016 Share Posted April 2, 2016 Hello, community! I was interested how to put team colour with nickname in messages. Look at this image. First part of name with tag of team is without colour: Here you can see my colour of team only in simple chat. I used this: outputChatBox("#ffffff"..getPlayerNametagText(source).." #ff0000has been muted for spam", getRootElement(), 255, 255, 0,true) The same thing is with dxDrawText: I will be very glad if you give me any help. Link to comment
Miika Posted April 2, 2016 Share Posted April 2, 2016 If you mean message color, you can use community created function rGBToHex Example: local r, g, b = getPlayerNametagColor(source) color = tocolor(r, g, b) outputChatBox("#ffffff"..getPlayerNametagText(source).. "" .. RGBToHex(r, g, b) .. " has been muted for spam", getRootElement(), 255, 255, 0,true) 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
Fullton Posted April 2, 2016 Author Share Posted April 2, 2016 If you mean message color, you can use community created function rGBToHexExample: local r, g, b = getPlayerNametagColor(source) color = tocolor(r, g, b) outputChatBox("#ffffff"..getPlayerNametagText(source).. "" .. RGBToHex(r, g, b) .. " has been muted for spam", getRootElement(), 255, 255, 0,true) 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 tocolor gets a nil value. I saw function that gets player's team color in script nametags(not standart) and downloaded from community but i lost this script and fuction. Link to comment
Miika Posted April 2, 2016 Share Posted April 2, 2016 tocolor gets a nil value.I saw function that gets player's team color in script nametags(not standart) and downloaded from community but i lost this script and fuction. So do you want team color to message or team color to name or both? Btw that tocolor was mistake, you can remove the line. And remove local front of r, g, b. Link to comment
Fullton Posted April 2, 2016 Author Share Posted April 2, 2016 So do you want team color to message or team color to name or both? Both. Team color and player name. getPlayerNametagText gets only colored name without team color. Link to comment
Miika Posted April 2, 2016 Share Posted April 2, 2016 Maybe this: add to start: addEventHandler("onPlayerJoin", root, function() local team = getPlayerTeam(source) local tr, tg, tb = getTeamColor(team) setPlayerNameTagColor(tr, tg, tb) end ) Mute message: local team = getPlayerTeam(source) local tr, tg, tb = getTeamColor(team) outputChatBox("#ffffff"..getPlayerNametagText(source).. "" .. RGBToHex(tr, tg, tb) .. " has been muted for spam", getRootElement(), 255, 255, 0,true) Then add this to somewhere to script: function playerChat(message, messageType) if messageType == 0 then cancelEvent() local r, g, b = getPlayerNametagColor(source) outputChatBox(RGBToHex(r, g, b) .. "" .. getPlayerNameTag(source)..": ".. message, root, r, g, b, true) end end addEventHandler("onPlayerChat", root, playerChat) And you need this function every script you use colored messages: 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
Fullton Posted April 2, 2016 Author Share Posted April 2, 2016 Maybe this:add to start: addEventHandler("onPlayerJoin", root, function() local team = getPlayerTeam(source) local tr, tg, tb = getTeamColor(team) setPlayerNameTagColor(tr, tg, tb) end ) Mute message: local team = getPlayerTeam(source) local tr, tg, tb = getTeamColor(team) outputChatBox("#ffffff"..getPlayerNametagText(source).. "" .. RGBToHex(tr, tg, tb) .. " has been muted for spam", getRootElement(), 255, 255, 0,true) Then add this to somewhere to script: function playerChat(message, messageType) if messageType == 0 then cancelEvent() local r, g, b = getPlayerNametagColor(source) outputChatBox(RGBToHex(r, g, b) .. "" .. getPlayerNameTag(source)..": ".. message, root, r, g, b, true) end end addEventHandler("onPlayerChat", root, playerChat) And you need this function every script you use colored messages: 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 oh. just coloured name and so hard. ty. 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