Quick Scoreboard questions

I’m trying to edit a scoreboard that has been made by someone else, and I’m adding an icon16 for certain groups, and I have a few questions.
First question, is there another more effecient way to do this? (Setting the icons for each group): http://pastebin.com/e0mDKj7V
I tried using a table, but IsUserGroup() didn’t accept it.

Second question: When it draws, it draws behind one of the panels t has to be infront of, Im guessing because this panel is drawn after the icon is.
Is there any sort of way to change the depth of the icon, as I don’t think it’s possible for me to change the order the panel and icon are drawn.

Place all the ranks in one table and set them equal to the icon you want.

I did that, but IsUserGroup wouldnt accept the table, it gave an error.

Check if anything in the table has the value of the players usergroup (Player:GetUserGroup())

I dont get what you mean by this, not sure how I would use it for this.

You could do:

local icongroups = {
    ["admin"] = "icon16/shield.png",
    ["supporter"] = "icon16/heart.png",
    ["default"] = "icon16/user.png",

local function getUIcon(player)
    return icongroups[player:GetNWString("usergroup") or "user"] or icongroups["default"]

This is the general idea but this is off of my phone I might have made some small error
If you only want it for specific groups and like user can’t have an icon at all, run this function as a variable and check if it’s nil or not and remove the or icongroups[“default”]

Ok thanks, I’ll try this. Does anyone have an answer for the second question, about the depth?


Alternatively, just make sure that the panel is drawn before the icon. Can we see your current code?

It’s a paid gamemode, so I don’t really wanna give out the code here, but I’ll try SetZPos
Actually, I dont think SetZPos will work, since it’s for a derma panel, and Im using it for an icon on a scoreboard

[editline]8th April 2016[/editline]

Actually, I have another problem now, here’s the code I’ve written: http://pastebin.com/YC84amCJ
I realised that since my group is superadmin, the icon draws on everyone’s panel on my screen, but in a user’s game, the icon draws for noone.
I suppose this makes sense, but how can I draw the icon for every admin on everyone’s screens?


Ah, I see.
This is an issue because it gets the person viewing the scoreboard’s group, and displays an icon based on their group. Get the usergroup data for the player that is on the section of the scoreboard instead.

[editline]8th April 2016[/editline]

for k, v in pairs( player.GetAll() ) do
    getUICon( v )

Some shit like that should work

I dont really know how either of these would work, I’m only learning lua really.

for k, v in pairs(player.GetAll()) do

is a loop, it loops through all players on the server, running the code you wrote inside the loop for each player (use v as the player object, it means value.).

So then if the v is the value, what does the k mean?

What the loop does is go through al the all the values on a table, but all the values on a table need to be assigned to a key, wich can be a number, a string or almost every other type of variable.
The k in there is the key wich is assgined to that value(v, wich is the player).
In that case you dont need the k, beacouse its a number.