General > Developers Corner

Scoreboard Help

<< < (2/3) > >>

Decicus:
That seems to what I was thinking of.

Thanks a lot for your help JamminR, I'll test it out later.

JamminR:
Just realized in my 'maybe fixed' setcolor line I used rbga instead of the rgba. You can correct.

Bite That Apple:

--- Quote from: JamminR on August 16, 2013, 07:56:58 PM ---This isn't tested, but you'll get less errors and be more likely to figure it out.


--- Code: ---local donators = {
["STEAM_0:0:00000000"] = {rank = "Custom rank 1 here", color = "255, 255, 0, 255"},
["STEAM_0:0:00000000"] = {rank = "Custom rank 2 here", color = "255, 0, 255, 255"},
}
     
local special = donators[ply:SteamID()]
if special then
    self.cols[5]:SetTextColor(Color(special.color))
    self.cols[5]:SetText(special.rank)
end

--- End code ---

--- End quote ---


I'm quite happy now that I opened this thread by accident. This helped me with an issue, seeing as my table skills are lacking and I can't find a guide that work with garry's mod tables.. Anyways though, this should work for what you want it to do, as this table idea worked what what I need it to do.


--- Code: ---local donators = {
["STEAM_0:0:00000000"] = {rank = "Custom rank 1 here", color = "255, 255, 0, 255"},
["STEAM_0:0:00000000"] = {rank = "Custom rank 2 here", color = "255, 0, 255, 255"},
}
--- End code ---

Though if I recall from what I do know about tables, the comma at the end line 3 should not be there.

Decicus:
The line 3 comma doesn't really do anything if there isn't anything after it. Although it's required if I want to add another "entry" to the table.

JamminR:
Chaos, to my knowledge, lua tables are no different in gmod than in any other lua environment.
You just get to hold Source/Gmod specific information in them.
If you can find a good lua table tutorial anywhere, it would be good for any <app/gmod/whatever> that uses lua.
They can and become pretty complex.
Not so much because of the way they store information, but probably more so because they can be multi-layered.

Decicus, did you find that you couldn't use a string for the color object (ie, color = "255, 255, 0, 255" didn't work)?
I'm thinking the object can only hold integers in the variable (the color = { r,g,b,a = 255,255,0,255 } } line I suggested.)

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version