Jump to content

Help with race top times


*FuN

Recommended Posts

Posted

hi guys I have a issue ....

I have a hunter top times , but this script dont show the coloured name , someone know how to fix that?

Posted

GUI labels doesn't allow HEX colors.

You'll have to find the function: guiCreateColorLabel or something similar around the forums and implement it in the script.

Posted
GUI labels doesn't allow HEX colors.

You'll have to find the function: guiCreateColorLabel or something similar around the forums and implement it in the script.

public class ColorLabelField extends LabelField{     
     
    private int color = 0x000000; 
    private int bg; 
    
    public ColorLabelField(){ 
        super(); 
    } 
    public ColorLabelField(Object text){ 
        super(text); 
    } 
     
    public ColorLabelField(Object text, int offset, int length, long style){ 
        super(text, offset, length, style); 
    } 
     
    public ColorLabelField(Object text, long style){ 
        super(text, style); 
    } 
     
    public ColorLabelField(ResourceBundleFamily rb, int key){ 
        super(rb, key); 
    } 
  
     
    public void setColor(int newColor){ 
        color = newColor; 
    } 
    public void setBackgroundColor(int newBG){ 
        bg=newBG; 
         
    } 
   
    public void paint(Graphics graphics){ 
        graphics.setColor(color); 
        graphics.setBackgroundColor(bg); 
       
        super.paint(graphics); 
    } 
}  

this ?

Posted

I sometimes wonder if people is just stupid or blind.

I even leaved the highlighting to the function, you just had to scroll down the code.

function guiCreateColorLabel(ax, ay, bx, by,str, parent, bool) 
    local pat = "(.-)#(%x%x%x%x%x%x)" 
    local s, e, cap, col = str:find(pat, 1) 
    local last = 1 
    local labels = {} 
    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) 
            lbl = guiCreateLabel(ax, ay, ax + w, by,cap,parent, bool) 
            table.insert(labels, lbl) 
            if (r == nil) then r = 255 end 
            if (g == nil) then g = 255 end 
            if (b == nil) then b = 255 end 
            guiLabelSetColor(lbl,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 
        cap = str:sub(last) 
        local w = dxGetTextWidth(cap) 
        lbl2 = guiCreateLabel(ax, ay, ax + w, by,cap,parent, bool) 
        table.insert(labels, lbl2) 
        guiLabelSetColor(lbl2,r,g,b) 
    end 
    return labels 
end 

Posted

Ok , srry about that , and thankz :D

I have another problem :

-When i do /redo appears that - : 'Current map has been restarted by #000000FuN#FFFFFF*

And i want make to disapere the code of colour is possible ?

Posted
race has a function which removes HEX colors, they shouldn't appear.

thankz

Edit:

I sometimes wonder if people is just stupid or blind.

I even leaved the highlighting to the function, you just had to scroll down the code.

function guiCreateColorLabel(ax, ay, bx, by,str, parent, bool) 
    local pat = "(.-)#(%x%x%x%x%x%x)" 
    local s, e, cap, col = str:find(pat, 1) 
    local last = 1 
    local labels = {} 
    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) 
            lbl = guiCreateLabel(ax, ay, ax + w, by,cap,parent, bool) 
            table.insert(labels, lbl) 
            if (r == nil) then r = 255 end 
            if (g == nil) then g = 255 end 
            if (b == nil) then b = 255 end 
            guiLabelSetColor(lbl,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 
        cap = str:sub(last) 
        local w = dxGetTextWidth(cap) 
        lbl2 = guiCreateLabel(ax, ay, ax + w, by,cap,parent, bool) 
        table.insert(labels, lbl2) 
        guiLabelSetColor(lbl2,r,g,b) 
    end 
    return labels 
end 

When I do a hunter time dont show the coloured names ! :S

Posted

Oh, so you think by just copy and paste the function in your script it'll magically work?

Seriously, go back to the wiki and start learning from the basics.

Posted
Oh, so you think by just copy and paste the function in your script it'll magically work?

Seriously, go back to the wiki and start learning from the basics.

OMG , you cant tell me ??

Posted

You don't want me to tell you, you want me to make it for you.

Is not that easy, you'll have to change many things, because guiCreateColorLabel returns a table of gui-labels, not just one.

Posted

And you can stop being "noob" by learning, do you think I was born with my knowledge? no, I learned everything I know by myself, you can do the same.

We're not helping you when we give the working script.

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