WASSIm. Posted August 14, 2013 Share Posted August 14, 2013 hi guys. i have question! can't use hex color to label ?? Link to comment
tosfera Posted August 14, 2013 Share Posted August 14, 2013 Not that I know of. But why do you want to use HEX Color's? Just transfer it to rgba. You can to alot more with it. Link to comment
WASSIm. Posted August 14, 2013 Author Share Posted August 14, 2013 how ? if you can post exmple Link to comment
tosfera Posted August 14, 2013 Share Posted August 14, 2013 sure; local lblName = guiCreateLabel(0.5, 0.5, 0.2, 0.2, "I'M A RED LABEL! FULLY VISIBLE", true); local lblName2 = guiCreateLabel(0.5, 0.6, 0.2, 0.2, "I'M A GREEN LABEL! FULLY VISIBLE", true); local lblName3 = guiCreateLabel(0.5, 0.7, 0.2, 0.2, "I'M A BLUE LABEL! FULLY VISIBLE", true); guiLabelSetColor(lblName, 255, 0, 0, 250); guiLabelSetColor(lblName2, 0, 255, 0, 250); guiLabelSetColor(lblName3, 0, 0, 255, 250); Link to comment
denny199 Posted August 14, 2013 Share Posted August 14, 2013 @tosfera, He want's to use HEX colors, like a player can have 2 HEX colors in his name, it will be shown as #ff0000D#00ff00anny, that isn't very handy for labels, like a deathlist, so Danny would look better. I don't know who made this function, just found it on the forums. For HEX codes: function guiCreateColorLabel( ax, ay, bx, by,str, bool, parent ) local pat = "(.-)#(%x%x%x%x%x%x)" local s, e, cap, col = str:find( pat, 1 ) local last = 1 local r,g,b while s do if cap == "" and col then r,g,b = tonumber( "0x"..col:sub( 1, 2 ) ), tonumber( "0x"..col:sub( 3, 4 ) ), tonumber( "0x"..col:sub( 5, 6 ) ) end if s ~= 1 or cap ~= "" then local w = dxGetTextWidth( cap ) avc321 = guiCreateLabel( ax, ay, ax + w, by,cap,bool,parent ) if not r then r = 255 end if not g then g = 255 end if not b then b = 255 end guiLabelSetColor( avc321,r,g,b ) ax = ax + w r,g,b = tonumber( "0x"..col:sub( 1, 2 ) ), tonumber( "0x"..col:sub( 3, 4 ) ), tonumber( "0x"..col:sub( 5, 6 ) ) end last = e + 1 s, e, cap, col = str:find( pat, last ) end if last <= #str then local cap = str:sub( last ) local w = dxGetTextWidth( cap ) local avc123 = guiCreateLabel( ax, ay, ax + w, by,cap,bool,parent ) guiLabelSetColor( avc123,r or 255,g or 255,b or 255 ) return avc123 end end Link to comment
tosfera Posted August 14, 2013 Share Posted August 14, 2013 @tosfera, He want's to use HEX colors, like a player can have 2 HEX colors in his name, it will be shown as #ff0000D#00ff00anny, that isn't very handy for labels, like a deathlist, so Danny would look better.I don't know who made this function, just found it on the forums. For HEX codes: function guiCreateColorLabel( ax, ay, bx, by,str, bool, parent ) local pat = "(.-)#(%x%x%x%x%x%x)" local s, e, cap, col = str:find( pat, 1 ) local last = 1 local r,g,b while s do if cap == "" and col then r,g,b = tonumber( "0x"..col:sub( 1, 2 ) ), tonumber( "0x"..col:sub( 3, 4 ) ), tonumber( "0x"..col:sub( 5, 6 ) ) end if s ~= 1 or cap ~= "" then local w = dxGetTextWidth( cap ) avc321 = guiCreateLabel( ax, ay, ax + w, by,cap,bool,parent ) if not r then r = 255 end if not g then g = 255 end if not b then b = 255 end guiLabelSetColor( avc321,r,g,b ) ax = ax + w r,g,b = tonumber( "0x"..col:sub( 1, 2 ) ), tonumber( "0x"..col:sub( 3, 4 ) ), tonumber( "0x"..col:sub( 5, 6 ) ) end last = e + 1 s, e, cap, col = str:find( pat, last ) end if last <= #str then local cap = str:sub( last ) local w = dxGetTextWidth( cap ) local avc123 = guiCreateLabel( ax, ay, ax + w, by,cap,bool,parent ) guiLabelSetColor( avc123,r or 255,g or 255,b or 255 ) return avc123 end end The standard Gui elements does not accept hex colors as a parameter, you can use the dxDrawText to draw the color's though. Link to comment
denny199 Posted August 14, 2013 Share Posted August 14, 2013 Like I was showing a costum HEX label color maker. Link to comment
tosfera Posted August 14, 2013 Share Posted August 14, 2013 replace your guiCreateLabel with this; guiCreateColorLabel(0.5, 0.5, 0.3, 0.3, "THIS IS A LABEL! ;3", true ); I think! never used this function, not sure how you give the color anyway... Maybe in the str ("THIS IS A LABEL"), try to add HEX colors to it. n_n Link to comment
WASSIm. Posted August 14, 2013 Author Share Posted August 14, 2013 i use guiSetText guiLabelSetHorizontalAlign Link to comment
Al3grab Posted August 14, 2013 Share Posted August 14, 2013 You can use this function .. https://forum.multitheftauto.com/viewtopic.php?f ... 00#p390365 Link to comment
WASSIm. Posted August 14, 2013 Author Share Posted August 14, 2013 can give me a exmple ? 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