SkiZo Posted December 15, 2018 Posted December 15, 2018 Hello, i need some help.. i made some edit in players tags.. outputChatBox("|SWAT| ["..Rank.."] #00ff00" .. getPlayerName ( source ) .. " #0000FF:#ffFFff " .. text, getRootElement(), 000, 128, 192, true ) well it's work actually but i have about 3 ranks .. let's say Sinour and Juniour .. Sniour is Yellow and the other Orange .. how can i change the color of "rank" without putting a #hexcolor before it ( because it will give one color ) Thanks
Moderators IIYAMA Posted December 15, 2018 Moderators Posted December 15, 2018 outputChatBox("|SWAT| ["..Rank.."] #00ff00" .. getPlayerName ( source ) .. " #0000FF:#ffFFff " .. text, getRootElement(), 000, 128, 192, true ) First layer of paint RGB = RED, GREEN, BLUE Second layers of paint: #HEX Tool: http://www.javascripter.net/faq/rgbtohex.htm Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
DNL291 Posted December 15, 2018 Posted December 15, 2018 (edited) If I understood it correctly, you can use a table with the ranks as key and the rank color in their value: local ranksColor = { ["Sinour"] = "#f5dd42Sinour", ["Juniour"] = "#f59b42Juniour" } So, try this: local ranksColor = { ["Sinour"] = "#f5dd42Sinour", ["Juniour"] = "#f59b42Juniour" } -- to keep the the default text color you set local oTextColor = RGBToHex(0, 128, 192) or "#ffffff" outputChatBox("|SWAT| ["..(ranksColor[Rank] or "nil") .. oTextColor .."] #00ff00" .. getPlayerName ( source ) .. " #0000FF:#ffFFff " .. text, getRootElement(), 0, 128, 192, true ) -- wiki.multitheftauto.com/wiki/RGBToHex function RGBToHex(red, green, blue, alpha) -- Make sure RGB values passed to this function are correct 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 -- Alpha check 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 Edited December 15, 2018 by DNL291 1 Please do not PM me with scripting related question nor support, use the forums instead.
SkiZo Posted December 15, 2018 Author Posted December 15, 2018 5 hours ago, DNL291 said: If I understood it correctly, you can use a table with the ranks as key and the rank color in their value: local ranksColor = { ["Sinour"] = "#f5dd42Sinour", ["Juniour"] = "#f59b42Juniour" } So, try this: local ranksColor = { ["Sinour"] = "#f5dd42Sinour", ["Juniour"] = "#f59b42Juniour" } -- to keep the the default text color you set local oTextColor = RGBToHex(0, 128, 192) or "#ffffff" outputChatBox("|SWAT| ["..(ranksColor[Rank] or "nil") .. oTextColor .."] #00ff00" .. getPlayerName ( source ) .. " #0000FF:#ffFFff " .. text, getRootElement(), 0, 128, 192, true ) -- wiki.multitheftauto.com/wiki/RGBToHex function RGBToHex(red, green, blue, alpha) -- Make sure RGB values passed to this function are correct 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 -- Alpha check 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 Thank You That Worked
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