~Air Posted January 28, 2015 Posted January 28, 2015 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")
.:HyPeX:. Posted January 28, 2015 Posted January 28, 2015 Just read all the arguments of dxDrawText, check the colorcode argument.
Enargy, Posted January 29, 2015 Posted January 29, 2015 https://wiki.multitheftauto.com/wiki/DxDrawText
~Air Posted January 29, 2015 Author Posted January 29, 2015 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
~Air Posted January 29, 2015 Author Posted January 29, 2015 This has nothing to do with that TAPL, I just need help to get it to show colorcodes.
TAPL Posted January 29, 2015 Posted January 29, 2015 But now I get an error:Expected string at argument 1
~Air Posted January 29, 2015 Author Posted January 29, 2015 (edited) 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 January 30, 2015 by Guest
Dealman Posted January 30, 2015 Posted January 30, 2015 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
~Air Posted January 30, 2015 Author Posted January 30, 2015 @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!
TAPL Posted January 30, 2015 Posted January 30, 2015 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)
~Air Posted January 30, 2015 Author Posted January 30, 2015 It fixxed the errors, but it still doesn't show the colorcoded Status.
Dealman Posted January 30, 2015 Posted January 30, 2015 @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?
~Air Posted January 30, 2015 Author Posted January 30, 2015 Yes, it shows like this: #FF4500test instead of: test or #00FF00test instead of: test just for example.
TAPL Posted January 30, 2015 Posted January 30, 2015 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)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now