Jump to content

Colorcodes


~Air

Recommended Posts

Hey guys,

I got one problem I made a text on my scoreboard but when I type a Status with colorcode it just shows it with the colorcode in the nametags but not in the scoreboard.

I hope you could help me.

That is just a part of my script, so that nobody can steal it.

dxDrawText(getElementData(element[2],"Status"), x+522, y-5 + (c - 1) * 20, x + 425+35, y + (c) * 20, tocolor(0,0,0, 255), 1, "default-bold", "center", "center") 
-- 
dxDrawText(getElementData(element[2],"Status"), x+522+2, y-5+2 + (c - 1) * 20, x + 425+35, y + (c) * 20, tocolor(255,255,255, 255), 1, "default-bold", "center", "center") 

Link to comment

Changed it to this:

dxDrawText(getElementData(element[2],"Status"), x+522, y-5 + (c - 1) * 20, x + 425+35, y + (c) * 20, tocolor(0,0,0, 255), 1, "default-bold", "center", "center", false, false, false, true) 
-- 
dxDrawText(getElementData(element[2],"Status"), x+522+2, y-5+2 + (c - 1) * 20, x + 425+35, y + (c) * 20, tocolor(255,255,255, 255), 1, "default-bold", "center", "center", false, false, false, true) 
  

But now I get an error:

Expected string at argument 1

Link to comment

Sorry for bump.

I tried something new:

dxDrawText(getPlayerStatus(player), x+522, y-5 + (c - 1) * 20, x + 425+35, y + (c) * 20, tocolor(0,0,0, 255), 1, "default-bold", "center", "center", false, false, true) 
-- 
dxDrawText(getPlayerStatus(player), x+522+2, y-5+2 + (c - 1) * 20, x + 425+35, y + (c) * 20, tocolor(255,255,255, 255), 1, "default-bold", "center", "center", false, false, true) 
  
function getPlayerStatus (player) 
local admin = getElementData(player,"Status") 
if admin then  
    return admin 
else 
    return "Guest" 
end 
end 
  
  

But this is my error:

(The line with getAccountData) expected element at argument 1

Edited by Guest
Link to comment

Are you sure player is returning a player element? getElementData returns false if it was unable to retrieve a value, false is a boolean - not a string.

Also, for optimizations, you should try to avoid doing 'hardcoded' calculations in drawings. You'd be better of doing the calculations once instead of 30-60 times a second, unless it's for some animation :)

Link to comment
function getPlayerStatus() -- * should be added before you call the function 
    local admin = getElementData(localPlayer, "Status") 
    if admin then 
        return admin 
    else 
        return "Guest" 
    end 
end 
  
dxDrawText(getPlayerStatus(), x+522, y-5 + (c - 1) * 20, x + 425+35, y + (c) * 20, tocolor(0,0,0, 255), 1, "default-bold", "center", "center", false, false, true) 
-- 
dxDrawText(getPlayerStatus(), x+522+2, y-5+2 + (c - 1) * 20, x + 425+35, y + (c) * 20, tocolor(255,255,255, 255), 1, "default-bold", "center", "center", false, false, true) 

Link to comment
@Dealman:

I posted the new error, it isn't the thing with the string anymore.

It's the one with expected element at argument 1.

BTW: I already tried source instead of player still same error!

You're misunderstanding the messages.

It said it expected an element, this implies it got something else; A string, a boolean, a float or integer value - something that is not an element.

Thus, the issue was that player was not defined and likely returning nil.

It fixxed the errors, but it still doesn't show the colorcoded Status.

The messages are not coloured? Is the hex colour-code removed from the status/name?

Link to comment
function getPlayerStatus() -- * should be added before you call the function 
    local admin = getElementData(localPlayer, "Status") 
    if admin then 
        return admin 
    else 
        return "Guest" 
    end 
end 
  
dxDrawText(getPlayerStatus(), x+522, y-5 + (c - 1) * 20, x + 425+35, y + (c) * 20, tocolor(0,0,0, 255), 1, "default-bold", "center", "center", false, false, false, true) 
-- 
dxDrawText(getPlayerStatus(), x+522+2, y-5+2 + (c - 1) * 20, x + 425+35, y + (c) * 20, tocolor(255,255,255, 255), 1, "default-bold", "center", "center", false, false, false, true) 

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