.:HyPeX:. Posted July 29, 2013 Share Posted July 29, 2013 Hi all, it has been a long while since i last came over here, but i'm stuck with the HEX codes. I know i can get the Player name from the funcion getPlayerName ( Player ) But, outputing on the chatbox it will come out with the HEX code, For example: LxG//#0ac300~HyPeX~ .... Now, im probably too lazy to find on the wiki how to remove this, is there possible to remove the HEX Codes? (I'm trying to have the complete line with the same colour.) I want to remove them completly, since if i make them work, it wouldnt have the same colour all the line. For instance, i would end having LxG// In violet (assuming im using the 170 0 255 RGB) and the rest in green (0ac300 is green). The way i thought of removing HEX codes is to make the script ignore 6 characters after a # including the # itself, but i do not know how. As i've readed throught some Lua manuals, i can get the HEX recognized by the lua using the 0xHEX But i want to remove it at all. I've seen on some servers that if you type a HEX in in the chatbox its not show, so i wanted to know how. EDIT: Woops, i think it was wrong section althought i thought i was on scripting, can someone Move it? Link to comment
Renkon Posted July 29, 2013 Share Posted July 29, 2013 You must use string.gsub(string, pattern, replacement) string.gsub(getPlayerName(p), "#%x%x%x%x%x%x", "") I just don't remember if that's the correct pattern. If it's not, somebody fix it Link to comment
.:HyPeX:. Posted July 29, 2013 Author Share Posted July 29, 2013 You must use string.gsub(string, pattern, replacement) string.gsub(getPlayerName(p), "#%x%x%x%x%x%x", "") I just don't remember if that's the correct pattern. If it's not, somebody fix it Thanks for the help, now i'm getting: unexpected symbol near ".." Line: outputChatBox(string.gsub(getPlayerName(p), "#%x%x%x%x%x%x", ""))" TEXT " ..text.. "TEXT" ,source,0, 229, 255) EDIT: What i find strange is why this is happening when the line before is working properly (Since LUA is readed in order, why error was not found on the before line) textA = math.random(0,80) if (textA >= 70) then outputChatBox(string.gsub(getPlayerName(p), "#%x%x%x%x%x%x", "")"TEXT" ..textA .. "TEXT",source,255, 0, 0) elseif (textA > 60 and textA < 70) then outputChatBox(string.gsub(getPlayerName(p), "#%x%x%x%x%x%x", ""))"TEXT" ..textA.. "TEXT",source,0, 229, 255) and it continues, now the problem is why it fails at the second one. Link to comment
Renkon Posted July 29, 2013 Share Posted July 29, 2013 Cause you are missing .. between String.Gsub and "text". .. Works as the connector between strings, and you are using string.sub and then directly "TEXT". You should add the concatenator: .. string.gsub(getPlayerName(p), "#%x%x%x%x%x%x", "").."TEXT" Link to comment
.:HyPeX:. Posted July 29, 2013 Author Share Posted July 29, 2013 Cause you are missing .. between String.Gsub and "text"... Works as the connector between strings, and you are using string.sub and then directly "TEXT". You should add the concatenator: .. string.gsub(getPlayerName(p), "#%x%x%x%x%x%x", "").."TEXT" Worked. Thanks alot for the help. 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