Jump to content

How to color code?


Sex*

Recommended Posts

So i thought i start to make new toptimes from beginning today because the last one was was lagging the server with errors and was compiled because it was downloaded from internet. I made everything ready but then i saw that the color codes didnt work :o. How to make that it would be possible to make color codes to work?

Link to comment
So i thought i start to make new toptimes from beginning today because the last one was was lagging the server with errors and was compiled because it was downloaded from internet. I made everything ready but then i saw that the color codes didnt work :o. How to make that it would be possible to make color codes to work?

are you using dxCreateText or GUICreateLabel?

Link to comment
Guest Guest4401

Use guiCreateColorLabel instead of guiCreateLabel

This function is made by someone on the forum, I don't know who.

    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

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...