-.Paradox.- Posted March 24, 2014 Share Posted March 24, 2014 Hello guys, i tried to getPlayerNametagColor when player talk in team chat, but i get this error WARNING: Test\server:5: Bad Argument @ 'getPlayerNametagColor' Server: local function onplayerChat(message, messageType) if messageType == 2 then --Team (Clan) chat cancelEvent() local name = getPlayerName(source) local red, green, blue = getPlayerNametagColor(name) outputChatBox("#9AFE2E(CLAN)"..name..": #FFFFFF"..message, root, red, green, blue, true ) outputServerLog("(TEAM): "..getPlayerName(source)..": "..message)--NOTE: Beacuse we cancelled the onPlayerChat event, we need to log chat manually. end end addEventHandler("onPlayerChat", root, onplayerChat) Link to comment
WhoAmI Posted March 24, 2014 Share Posted March 24, 2014 getPlayerNametagColor ( source ) Link to comment
-.Paradox.- Posted March 24, 2014 Author Share Posted March 24, 2014 I did this first time, but it output no errors in debug and it don't output player nametag color in the clan chat, it output all the Text with green color.. Link to comment
WhoAmI Posted March 24, 2014 Share Posted March 24, 2014 Put lane and check if those colors are right outputChatBox ( red .. green .. blue ) Link to comment
WhoAmI Posted March 24, 2014 Share Posted March 24, 2014 But wait, how do you want to color this message when you did it already by using HEX codes? Link to comment
-.Paradox.- Posted March 24, 2014 Author Share Posted March 24, 2014 Oh yeah shit my bad, thanks anyway Link to comment
-.Paradox.- Posted March 29, 2014 Author Share Posted March 29, 2014 Now it's working, but i want to output a colored (CLAN) Text and after it the Player name tag color, any ideas? Link to comment
WhoAmI Posted March 29, 2014 Share Posted March 29, 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 local function onplayerChat(message, messageType) if messageType == 2 then --Team (Clan) chat cancelEvent() local name = getPlayerName(source) local red, green, blue = getPlayerNametagColor(name) local hex = RGBToHex ( red, green, blue ) outputChatBox("#9AFE2E(CLAN)" .. hex .. ..name.."#FFFFFF:"..message, root, 255, 255, 255, true ) outputServerLog("(TEAM): "..getPlayerName(source)..": "..message)--NOTE: Beacuse we cancelled the onPlayerChat event, we need to log chat manually. end end addEventHandler("onPlayerChat", root, onplayerChat) Link to comment
-.Paradox.- Posted March 29, 2014 Author Share Posted March 29, 2014 ERROR: Chat/basic_s.lua:2:attempt to compare boolean with number 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 local function onplayerChat(message, messageType) if messageType == 2 then --Team (Clan) chat cancelEvent() local name = getPlayerName(source) local red, green, blue = getPlayerNametagColor(name) local hex = RGBToHex ( red, green, blue ) outputChatBox("#9AFE2E(CLAN)" .. hex .." "..name.."#FFFFFF:"..message, root, 255, 255, 255, true ) outputServerLog("(TEAM): "..getPlayerName(source)..": "..message)--NOTE: Beacuse we cancelled the onPlayerChat event, we need to log chat manually. end end addEventHandler("onPlayerChat", root, onplayerChat) Link to comment
WhoAmI Posted March 29, 2014 Share Posted March 29, 2014 function RGBToHex(red, green, blue) if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255)) then return nil end return string.format("#%.2X%.2X%.2X", red, green, blue) end local function onplayerChat(message, messageType) if messageType == 2 then --Team (Clan) chat cancelEvent() local name = getPlayerName(source) local red, green, blue = getPlayerNametagColor(name) local hex = RGBToHex ( red, green, blue ) outputChatBox("#9AFE2E(CLAN)" .. hex .. ..name.."#FFFFFF:"..message, root, 255, 255, 255, true ) outputServerLog("(TEAM): "..getPlayerName(source)..": "..message)--NOTE: Beacuse we cancelled the onPlayerChat event, we need to log chat manually. end end addEventHandler("onPlayerChat", root, onplayerChat) Link to comment
-.Paradox.- Posted March 30, 2014 Author Share Posted March 30, 2014 Bad argument @'getPlayerNametagColor' line 11 Link to comment
WhoAmI Posted March 30, 2014 Share Posted March 30, 2014 function RGBToHex(red, green, blue) if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255)) then return nil end return string.format("#%.2X%.2X%.2X", red, green, blue) end local function onplayerChat ( message, messageType ) if ( messageType == 2 ) then --Team (Clan) chat cancelEvent ( ) local name = getPlayerName ( source ) local red, green, blue = getPlayerNametagColor ( source ) local hex = RGBToHex ( red, green, blue ) outputChatBox( "#9AFE2E(CLAN)" .. hex .. name .. "#FFFFFF:" .. message, root, 255, 255, 255, true ) outputServerLog( "(TEAM): " .. name .. ": " .. message )--NOTE: Beacuse we cancelled the onPlayerChat event, we need to log chat manually. end end addEventHandler ( "onPlayerChat", root, onplayerChat ) Link to comment
-.Paradox.- Posted March 30, 2014 Author Share Posted March 30, 2014 (edited) Thanks dude. (: /lock Edited March 30, 2014 by Guest 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