Scoreboard Help

Hello Fellow FacePunch users. So today i was trying to add in a code i use to have, but when i did it, it just errored out. The code is this in sb_row:


 if ply:IsUserGroup("owner") then
	self.cols[5]:SetText("Owner")
	self.cols[5]:SetTextColor(Color(0, 0, 255, 255))
  end
  
  if ply:IsUserGroup("superadmin") then
	self.cols[5]:SetText("Vice Pres.")
	self.cols[5]:SetTextColor(Color(0, 255, 130, 255))
  end  
  
  if ply:IsUserGroup("manager") then
	self.cols[5]:SetText("Manager")
	self.cols[5]:SetTextColor(Color(0, 255, 255, 255))
  end
  
  if ply:IsUserGroup("ps_admin") or ply:IsUserGroup("ps_admin") then
	self.cols[5]:SetText("Admin")
	self.cols[5]:SetTextColor(Color(255, 100, 5, 255))
  end  
  
  if ply:IsUserGroup("moderator") or ply:IsUserGroup("ps_moderator") then
	self.cols[5]:SetText("Moderator")
	self.cols[5]:SetTextColor(Color(255, 160, 5, 255))
  end    
  
  if ply:IsUserGroup("operator") or ply:IsUserGroup("ps_operator") then
	self.cols[5]:SetText("Operator")
	self.cols[5]:SetTextColor(Color(255, 245, 5, 255))
  end   

  if ply:IsUserGroup("clan_member") then
	self.cols[5]:SetText("Member")
	self.cols[5]:SetTextColor(Color(255, 0, 0, 255))
  end    
  
  if ply:IsUserGroup("ps_member") then
	self.cols[5]:SetText("VIP Member")
	self.cols[5]:SetTextColor(Color(255, 0, 0, 255))
  end    
  
  if ply:IsUserGroup("vip") then
	self.cols[5]:SetText("VIP")
	self.cols[5]:SetTextColor(Color(30, 255, 5, 255))
  end    
  
  if ply:IsUserGroup("regular") then
	self.cols[5]:SetText("Regular")
	self.cols[5]:SetTextColor(Color(255, 255, 255, 255))
  end  
  
  if ply:IsUserGroup("user") then
	self.cols[5]:SetText("")
	self.cols[5]:SetTextColor(Color(255, 255, 255, 255))
  end    
  
  if ply:IsUserGroup("watchlist") then
	self.cols[5]:SetText("Watch List")
	self.cols[5]:SetTextColor(Color(255, 0, 255, 255))
  end

So then i looked through the code, and saw that the method i was using to put it on a column was obsolete. I saw it uses this now:


   self:AddColumn( GetTranslation("sb_score"), function(ply) return ply:Frags() end )

Can someone help me implement this into the new scoreboard code?

Thanks

Also please don’t link me to something similar or the same, I like the code the way I have it, I don’t want someone else’s code.

-bump-

You say not to link you to another players code, but this script may help you get a better understanding. https://github.com/rejax/TTT-EasyScoreboard

Although some important hooks to use are listed here.

If you’re wanting to use an unnecessary amount of lines you can do it your way by having a for loop and a table, but your way still works. Also you could use if/elseif/else instead a bunch of if statements that way it will ignore the rest of the options.

I quickly typed this up for an idea. Very straight forward.
[lua]
hook.Add( “TTTScoreboardColumns”, function( pnl )
local ugroup = string.lower(ply:GetUserGroup())
local title

if ugroup == "owner" then title = "Owner"
elseif ugroup == "superadmin" then title = "Vice Pres."
elseif ugroup == "manager" then title = "Manager"
elseif ugroup == "admin" or ugroup == "ps_admin" then title = "Admin"
elseif ugroup == "moderator" or ugroup == "ps_moderator" then title = "Moderator"
else title = "User" end

pnl:AddColumn("Rank", title)

end)[/lua]

You could just always use an old copy of sb_row and sb_main if you really wanted to keep using the old way.

Please do not do a lot of if/elseif statements, they’re ugly as all can be. Create a table and check if the players group is in that, then use the data from it.

He said he wanted to keep the code “his way” so I left the if statements for him. I suggested using a table and he can learn to write that himself if he wanted to.