Jump to content

How to color code?


Sex*

Recommended Posts

Posted

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?

Posted
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?

Posted

FACEPALM, this is how it looks right now:

01011673651e583.jpg

As you guys see, NO COLORS(only colorcodes). But i want it to be colored, so how to make it?

Guest Guest4401
Posted

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 

Posted
What the hell?...and where do i put it in client?

Yes, it's clientside. But the function have some bugs with color codes.

Posted
What the hell?...and where do i put it in client?

Yes, it's clientside. But the function have some bugs with color codes.

Yes, i know that the coloring function is in the clientside but i cant find a place where should i put it...

Guest Guest4401
Posted

Put it in the very first line, and replace guiCreateLabel with guiCreateColorLabel everywhere except in the function itself.

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