General > Developers Corner
Scoreboard Help
Decicus:
So I tested it, and got this giant error (it's an image, because the error didn't print to logs...):
Line 246 is the last line on the "code box" on the bottom of this post. I will attach all files that are included in the errors ("gamemode" folder files).
Now, I looked on the util.lua, line 33.
It looks to me that it's conflicting with something that is "GMod default". Not really sure what this does, it's something with colors, of course.
--- Code: -----[[---------------------------------------------------------
To easily create a colour table
-----------------------------------------------------------]]
function Color( r, g, b, a )
a = a or 255
return { r = math.min( tonumber(r), 255 ), g = math.min( tonumber(g), 255 ), b = math.min( tonumber(b), 255 ), a = math.min( tonumber(a), 255 ) }
end
--- End code ---
And lastly, my code, the code that I used. It's not the whole function.
--- Code: ---local Custom = {
["STEAM_0:1:18726919"] = {rank = "Custom", color = {r, g, b = 255, 0, 0}}, --Test.
}
local cust = Custom[ply:SteamID()]
elseif cust then
self.cols[5]:SetText(cust.rank)
self.cols[5]:SetTextColor(Color(cust.color.r, cust.color.g, cust.color.b, 255))
--- End code ---
If you wish to take a look at all the files mentioned in the giant lua error (.zip file, more than 4 files :P), they're attached to this post (beware, some of them might have messy, unnecessary code).
JamminR:
Few extreme quick things to try (Not sure I have more time to dig deeper or look at the files).
First, though it MIGHT be bit different now, I had trouble years ago setting comments -in- a table.
Set your --test after the last } table bracket.
Second -
Wiki.garrysmod.com says settextcolor should be before the text. Try moving the settextcolor line before your rank set line.
Third, and this is just something I'd do while tinkering in such a unfamiliar-to-me Gmod gui section.
Though settextcolor says it can be a Color object, it states it can be 'or r'.
Try removing the object, and using SetTextColor(cust.color.r, cust.color.g, cust.color.b, 255)
There's something about "using a color object is not recommended to be created prodecural. " too at that page.
I'm not 'trained' coder enough to know what a procedural creation is, so recommend trying just the number values with no Color().
May also try, just for testing purposes, setting the numbers static, not using the table look up.
SetTextColor(Color(255, 0, 0, 255)) or like I said in three, SetTextColor(255, 0, 0, 255)
An Error Has Occurred!
array_keys(): Argument #1 ($array) must be of type array, null given
[0] Board index
Go to full version