Jump to content

Colored TopTimes


Reflex#

Recommended Posts

Posted

Use my dx text library:

dx = { } 
dx.__index = dx 
local visible = { } 
local id = 0 
  
function dx:Create ( Text, X, Y, W, H, Color, Scale, Font, AlignX, AlignY, Clip, Wordbreak ) 
    if ( 
            type ( Text ) == "string" 
        and 
            type ( X ) == "number" 
        and 
            type ( Y ) == "number" 
        and 
            type ( W ) == "number" 
        and 
            type ( H ) == "number" 
        and 
            type ( Scale ) == "number" 
        ) 
    then 
        local text = 
            { 
                eText       = Text; 
                eX          = X; 
                eY          = Y; 
                eW          = W; 
                eH          = H; 
                eColor      = Color; 
                eScale      = Scale; 
                eFont       = Font; 
                eClip       = Clip; 
                eWordbreak  = WordBreak; 
                ePostGUI    = true 
            } 
        setmetatable ( text, { __index = dx } ) 
        id = id + 1 
        table.insert ( visible, id, text ); 
        return text 
    end 
end 
  
function dx:Color ( ) 
    return unpack ( self.eColor ) 
end 
  
function dxGetAlpha ( elem ) 
    local r, g, b, a = elem:Color ( ) 
    return a 
end 
  
function dx:SetColor ( r, g, b, a ) 
    self.eColor = { r, g, b, a } 
end 
  
function dx:Text ( text ) 
    self.eText = text 
end 
  
function dxSetTime ( elem, time ) 
    elem:Text ( time ) 
end 
  
function dxSetText ( elem, text ) 
    elem:Text ( text ) 
end 
  
function dx:GetPosition ( ) 
    return self.eX, self.eY 
end 
  
function dx:Position ( x, y ) 
    self.eX = x 
    self.eY = y 
end 
  
addEventHandler ( 'onClientRender', root, 
    function ( ) 
        for _, self in ipairs ( visible ) do 
            while not false do 
                draw ( self.eText, self.eX, self.eY, self.eW, self.eH, tocolor ( unpack ( self.eColor ) ), self.eScale, self.eFont, self.eAlignX, self.eAlignY, tostring ( self.eClip ), tostring ( self.eWordbreak ), true, self.eColor [ 4 ] ) 
                break 
            end 
        end 
    end 
) 
  
function draw(str, ax, ay, bx, by, color, scale, font, left, top, clip, wordbreak, postGUI,alpha) 
    local pat = "(.-)#(%x%x%x%x%x%x)" 
    local s, e, cap, col = str:find(pat, 1) 
    local last = 1 
    while s do 
        if cap == "" and col then color = tocolor( tonumber( "0x"..col:sub( 1, 2 ) ), tonumber( "0x"..col:sub( 3, 4 ) ), 
        tonumber( "0x"..col:sub( 5, 6 ) ), alpha ) end 
        if s ~= 1 or cap ~= "" then 
            local w = dxGetTextWidth(cap, scale, font) 
            dxDrawText( cap, ax, ay, ax + w, by, color, scale, font ) 
            ax = ax + w 
            color = tocolor( tonumber( "0x"..col:sub( 1, 2 ) ), tonumber( "0x"..col:sub( 3, 4 ) ), tonumber( "0x"..col:sub( 5, 6 ) ), alpha ) 
        end 
        last = e + 1 
        s, e, cap, col = str:find( pat, last ) 
    end 
    if last <= #str then 
        cap = str:sub( last ) 
        local w = dxGetTextWidth( cap, scale, font ) 
        dxDrawText( cap, ax, ay, ax + w, by, color, scale, font, left, top, clip, wordbreak, postGUI ) 
    end 
end 
  

Example:

myText = dx:Create ( "Test", 200, 100, 50, 50, { 255, 255, 255, 255 }, 1.0, 'bankgothic', 'center', 'center', false, false, true ) 

Just replace your top times labels with these things ( must edit ).

Posted

Better start learning to create your own, because DirectX Text don't have same positions of gui label.

And yes, you must change GUI and GUI Labels functions used.

Posted
I must change client side?

you can buy it :D

He can create his own too :D

Advantages: He can put his own ideas on it; He don't need lost money.

Desvantages: No desvantages.

:mrgreen:

Posted

you can find colored label code, and use it,

guiSetText 

will not work, btw you can use

destroyElement() 

, and make label again

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