(Yet Another) Scoreboard ranks not correctly shown.

I realize and understand there’s hundreds, if not thousands of threads about “scoreboard ranks” and how to do them. I have a basic understanding of them and have come up with this:


function serfboard(sb)
	print(sb)
	sb:AddColumn( "Rank", function(ply, label) 
		label:SetName( "Serfboard" )
		if ply:IsUserGroup("superadmin") then
			group = "Owner"
			color = Color(192, 57, 43)
			elseif ply:IsUserGroup("admin") then
				group = "Admin"
				color = Color(231, 76, 60)
			elseif ply:IsUserGroup("mod") then
				group = "Mod"
				color = Color(41, 128, 185)
			elseif ply:IsUserGroup("trialmod") then
				group = "T. Mod"
				color = Color(41, 128, 185)
			elseif ply:IsUserGroup("vip") then
				group = "VIP"
				color = Color(241, 196, 15)
			elseif ply:IsUserGroup("member") then
				group = "Member"
				color = Color(236, 240, 241)
			elseif ply:IsUserGroup("user") then
				group = "Guest"
				color = Color(189, 195, 199)
		end

		if ply:SteamID() == "STEAM_0:0:85188996" then 
			group = "Serf's GF"
			color = Color(247, 58, 244)
		end

		label:SetColor(color)

		return group 
	end, 70)

	sb:AddColumn("Level", function(ply, label) 
		local level = ply:GetNWInt("Level")

		return "Lvl "..level
	end, 60)
end
hook.Add( "TTTScoreboardColumns", "SerfBoard", serfboard)

Ignore the messiness and the silly ranks. The issue I’m running into is that players are not shown their correct rank at times, and will often show this:
http://puu.sh/cDftI/aa5a4f4aa9.jpg

However I am the only “Owner”. This happens for all other ranks and I have no idea what there is to do to fix this. Any help will be appreciated, even if it’s being pointed in the right direction. :slight_smile:

Instead of elseif for guest/user, set that as an else so there is a “default”. Also, you may have a backdoor in one of your addons / scripts causing other superadmins to be set.

No backdoors. It will randomly, and temporarily, set them to another rank. Set the else for the “default” and will see what happens. Feel as if it’ll show them as guest whenever they aren’t. Ranks are fixed once scoreboard updates, such as a player joining, dying, leaving, etc.

You may also be requesting the rank too frequently. It is an NWVar, and each time you call it, it makes a request to the server ( very laggy if you check every frame ).

Grab the rank once, then compare x times. Try also using string.lower( ) because some ranks may be upper and you may not be checking for it.


local _group = string.lower( ply:GetNWString( "UserGroup" ) );

_group == “superadmin”, _group == “guest”, etc…

Thanks! I’ll try it and see how it goes. :slight_smile:

Use a bloody table please!!!

Heh, I will. :wink: