Overkillz Posted March 26, 2014 Share Posted March 26, 2014 What i need to create a Team Color Chat I hope you can help me Regards. Link to comment
WhoAmI Posted March 26, 2014 Share Posted March 26, 2014 You want to set player's nick colored his team's color on chat? If so 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 addEventHandler ( "onPlayerChat", root, function ( message, messageType ) if ( messageType == 0 ) then cancelEvent ( ) local team = getPlayerTeam ( source ) if ( team ) then local r, g, b = getTeamColor ( team ) local hexCode = RGBToHex ( r, g, b ) local name = getPlayerName ( source ) outputChatBox ( hexCode .. name .. "#FFFFFF: " .. message, root, 255, 255, 255, true ) end end ) Link to comment
Overkillz Posted March 27, 2014 Author Share Posted March 27, 2014 You want to set player's nick colored his team's color on chat? If so 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 addEventHandler ( "onPlayerChat", root, function ( message, messageType ) if ( messageType == 0 ) then cancelEvent ( ) local team = getPlayerTeam ( source ) if ( team ) then local r, g, b = getTeamColor ( team ) local hexCode = RGBToHex ( r, g, b ) local name = getPlayerName ( source ) outputChatBox ( hexCode .. name .. "#FFFFFF: " .. message, root, 255, 255, 255, true ) end end ) Doesn't work ;( http://puu.sh/7Ltkt.png Link to comment
Anubhav Posted March 27, 2014 Share Posted March 27, 2014 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 addEventHandler ( "onPlayerChat", root, function ( message, messageType ) if ( messageType == 2 ) then cancelEvent ( ) local team = getPlayerTeam ( source ) if ( team ) then local r, g, b = getTeamColor ( team ) local hexCode = RGBToHex ( r, g, b ) local name = getPlayerName ( source ) outputChatBox ( hexCode .. name .. "#FFFFFF: " .. message, root, 255, 255, 255, true ) end end ) Link to comment
Overkillz Posted March 27, 2014 Author Share Posted March 27, 2014 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 addEventHandler ( "onPlayerChat", root, function ( message, messageType ) if ( messageType == 2 ) then cancelEvent ( ) local team = getPlayerTeam ( source ) if ( team ) then local r, g, b = getTeamColor ( team ) local hexCode = RGBToHex ( r, g, b ) local name = getPlayerName ( source ) outputChatBox ( hexCode .. name .. "#FFFFFF: " .. message, root, 255, 255, 255, true ) end end ) Still unworking ;( Link to comment
Anubhav Posted March 27, 2014 Share Posted March 27, 2014 are you sure there are no errors? Link to comment
Overkillz Posted March 27, 2014 Author Share Posted March 27, 2014 are you sure there are no errors? Im sure it is not working, I still getting the same color of text, not "FFFFFF" Link to comment
WhoAmI Posted March 27, 2014 Share Posted March 27, 2014 addEventHandler ( "onPlayerChat", root, function ( message, messageType ) if ( messageType == 2 ) then cancelEvent ( ) local name = getPlayerName ( source ) local team = getPlayerTeam ( source ) for _, player in ipairs ( getElementsByType ( "player" ) ) do if ( getPlayerTeam ( player ) == team ) then outputChatBox ( name .. "#FFFFFF: " .. message, player, 255, 255, 255, true ) end end end end ) Check this out ( serverside script ). Link to comment
Overkillz Posted March 27, 2014 Author Share Posted March 27, 2014 addEventHandler ( "onPlayerChat", root, function ( message, messageType ) if ( messageType == 2 ) then cancelEvent ( ) local name = getPlayerName ( source ) local team = getPlayerTeam ( source ) for _, player in ipairs ( getElementsByType ( "player" ) ) do if ( getPlayerTeam ( player ) == team ) then outputChatBox ( name .. "#FFFFFF: " .. message, player, 255, 255, 255, true ) end end end end ) Check this out ( serverside script ). Thanks so much, this workfine ^^ Link to comment
WhoAmI Posted March 27, 2014 Share Posted March 27, 2014 Next time be more specific when you are creating the topic. I wasn't sure what are you talking about. Anyway, You're welcome. 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