Jump to content

question


WASSIm.

Recommended Posts

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

@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, 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...