--TTT Rank Collumn Help--

My friend recently decided to make a TTT server and I have been helping with coding. I am pretty new to LUA and have been having a problem with the rank column in the scoreboard that I found. The problem is that I want the persons Steam Name to be the same color of their Rank Name, but I do not know how to do this. Please help.
This is the code I am using for sb_row:

---- Scoreboard player score row, based on sandbox version

include(“sb_info.lua”)

local GetTranslation = LANG.GetTranslation
local GetPTranslation = LANG.GetParamTranslation

SB_ROW_HEIGHT = 24

local PANEL = {}

function PANEL:Init()
– cannot create info card until player state is known
self.info = nil

self.open = false

self.cols = {}
self.cols[1] = vgui.Create(“DLabel”, self)
self.cols[1]:SetText(GetTranslation(“sb_ping”))

self.cols[2] = vgui.Create(“DLabel”, self)
self.cols[2]:SetText(GetTranslation(“sb_deaths”))

self.cols[3] = vgui.Create(“DLabel”, self)
self.cols[3]:SetText(GetTranslation(“sb_score”))

self.cols[5] = vgui.Create(“DLabel”, self)
self.cols[5]:SetText(“Rank”)

if KARMA.IsEnabled() then
self.cols[4] = vgui.Create(“DLabel”, self)
self.cols[4]:SetText(GetTranslation(“sb_karma”))
end

for _, c in ipairs(self.cols) do
c:SetMouseInputEnabled(false)
end

self.tag = vgui.Create(“DLabel”, self)
self.tag:SetText("")
self.tag:SetMouseInputEnabled(false)

self.sresult = vgui.Create(“DImage”, self)
self.sresult:SetSize(16,16)
self.sresult:SetMouseInputEnabled(false)

self.avatar = vgui.Create( “AvatarImage”, self )
self.avatar:SetSize(SB_ROW_HEIGHT, SB_ROW_HEIGHT)
self.avatar:SetMouseInputEnabled(false)

self.nick = vgui.Create(“DLabel”, self)
self.nick:SetMouseInputEnabled(false)

self.voice = vgui.Create(“DImageButton”, self)
self.voice:SetSize(16,16)

self:SetCursor( “hand” )
end

----EDIT THESE TO ADD MORE COLOURS----
----Example: test = COLOR_BLUE----
—Make sure to put a comma after each line until the end (Last one doesn’t have one—

local namecolor = {
default = COLOR_WHITE,
admin = COLOR_WHITE,
dev = Color(100, 240, 105, 255),
test = COLOR_BLUE,
owner = Color(255, 0, 127, 255),
mod = Color(175, 0, 200, 255),
coowner = COLOR_GREEN,
sadmin = Color(225, 0, 0, 255),
smod = Color(50, 205, 50, 255),
sradmin = Color(178, 0, 0, 255),
svip = Color(255, 215, 0, 255),
donoradmin = Color(138, 19, 198, 255),
noob = Color(200, 200, 200, 255)
};

function GM:TTTScoreboardColorForPlayer(ply)
if not IsValid(ply) then return namecolor.default end

–ADD NAMECOLOURS HERE–
if ply:SteamID() == “STEAM_0:0:1963640” then
return namecolor.dev
elseif ply:IsAdmin() and GetGlobalBool(“ttt_highlight_admins”, true) then
return namecolor.admin
elseif ply:IsUserGroup(“superadmin”) then
return namecolor.sadmin
elseif ply:IsUserGroup(“Owner”) then
return namecolor.owner
elseif ply:IsUserGroup(“Co-Owner”) then
return namecolor.coowner
elseif ply:IsUserGroup(“Mod”) then
return namecolor.mod
elseif ply:IsUserGroup(“Regular”) then
return namecolor.default
elseif ply:IsUserGroup(“SuperAdmin”) then
return namecolor.sadmin
elseif ply:IsUserGroup(“Supermoderator”) then
return namecolor.smod
elseif ply:IsUserGroup(“senioradmin”) then
return namecolor.sradmin
elseif ply:IsUserGroup(“SuperVIP”) then
return namecolor.svip
elseif ply:IsUserGroup(“donoradmin”) then
return namecolor.donoradmin
elseif ply:IsUserGroup(“user”) then
return namecolor.noob
end
return namecolor.default
end

local function ColorForPlayer(ply)
if IsValid(ply) then
local c = hook.Call(“TTTScoreboardColorForPlayer”, GAMEMODE, ply)

  -- verify that we got a proper color
  if c and type(c) == "table" and c.r and c.b and c.g and c.a then
     return c
  else
     ErrorNoHalt("TTTScoreboardColorForPlayer hook returned something that isn't a color!

")
end
end
return namecolor.default
end

function PANEL:Paint()
if not IsValid(self.Player) then return end

if ( self.Player:GetFriendStatus() == “friend” ) then
color = Color( 236, 181, 113, 255 )
end

local ply = self.Player

if ply:IsTraitor() then
surface.SetDrawColor(255, 0, 0, 30)
surface.DrawRect(0, 0, self:GetWide(), SB_ROW_HEIGHT)
elseif ply:IsDetective() then
surface.SetDrawColor(0, 0, 255, 30)
surface.DrawRect(0, 0, self:GetWide(), SB_ROW_HEIGHT)
end

if ply == LocalPlayer() then
surface.SetDrawColor( 200, 200, 200, math.Clamp(math.sin(RealTime() * 2) * 50, 0, 100))
surface.DrawRect(0, 0, self:GetWide(), SB_ROW_HEIGHT )
end

return true
end

function PANEL:SetPlayer(ply)
self.Player = ply
self.avatar:SetPlayer(ply)

if not self.info then
local g = ScoreGroup(ply)
if g == GROUP_TERROR and ply != LocalPlayer() then
self.info = vgui.Create(“TTTScorePlayerInfoTags”, self)
self.info:SetPlayer(ply)

     self:InvalidateLayout()
  elseif g == GROUP_FOUND or g == GROUP_NOTFOUND then
     self.info = vgui.Create("TTTScorePlayerInfoSearch", self)
     self.info:SetPlayer(ply)
     self:InvalidateLayout()
  end

else
self.info:SetPlayer(ply)

  self:InvalidateLayout()

end

self.voice.DoClick = function()
if IsValid(ply) and ply != LocalPlayer() then
ply:SetMuted(not ply:IsMuted())
end
end

self:UpdatePlayerData()
end

function PANEL:GetPlayer() return self.Player end

function PANEL:UpdatePlayerData()
if not IsValid(self.Player) then return end

local ply = self.Player
self.cols[1]:SetText(ply:Ping())
self.cols[2]:SetText(ply:Deaths())
self.cols[3]:SetText(ply:Frags())

if self.cols[4] then
self.cols[4]:SetText(math.Round(ply:GetBaseKarma()))
end

self.nick:SetText(ply:Nick())
self.nick:SizeToContents()
self.nick:SetTextColor(ColorForPlayer(ply))

if ply:IsUserGroup("superadmin") then
	self.cols[5]:SetText("SuperAdmin")
	self.cols[5]:SetTextColor(namecolor.sadmin)
elseif ply:IsUserGroup("admin") then
	self.cols[5]:SetText("Admin")
	self.cols[5]:SetTextColor(Color(0, 0, 175, 255))
elseif ply:IsUserGroup("Owner") then
	self.cols[5]:SetText("Owner")
	self.cols[5]:SetTextColor(namecolor.owner)
elseif ply:IsUserGroup("Co-Owner") then
	self.cols[5]:SetText("Co Owner")
	self.cols[5]:SetTextColor(namecolor.coowner)
elseif ply:IsUserGroup("Mod") then
	self.cols[5]:SetText("Mod")
	self.cols[5]:SetTextColor(namecolor.mod)
elseif ply:IsUserGroup("Regular") then
	self.cols[5]:SetText("Regular")
	self.cols[5]:SetTextColor(namecolor.default)
elseif ply:IsUserGroup("Supermoderator") then
	self.cols[5]:SetText("SuperMod")
	self.cols[5]:SetTextColor(namecolor.smod)
elseif ply:IsUserGroup("S-Reg") then
	self.cols[5]:SetText("S.Regular")
	self.cols[5]:SetTextColor(namecolor.sreg)
elseif ply:IsUserGroup("senioradmin") then
	self.cols[5]:SetText("Sr.Admin")
	self.cols[5]:SetTextColor(namecolor.sradmin)
elseif ply:IsUserGroup("Clem") then
    self.cols[5]:SetText("ClemmyClue")
	self.cols[5]:SetTextColor(namecolor.clem)
elseif ply:IsUserGroup("SuperVIP") then
    self.cols[5]:SetText("SuperVIP")
	self.cols[5]:SetTextColor(namecolor.svip)
elseif ply:IsUserGroup("donoradmin") then
    self.cols[5]:SetText("DonorAdmin")
	self.cols[5]:SetTextColor(namecolor.donoradmin)
elseif ply:IsUserGroup("user") then
    self.cols[5]:SetText("Noob")
	self.cols[5]:SetTextColor(namecolor.noob)

– Delete the – and change the settings to your liking. DO NOT DELETE THE ‘end’
end

local ptag = ply.sb_tag
if ScoreGroup(ply) != GROUP_TERROR then
ptag = nil
end

self.tag:SetText(ptag and GetTranslation(ptag.txt) or “”)
self.tag:SetTextColor(ptag and ptag.color or COLOR_WHITE)

self.sresult:SetVisible(ply.search_result != nil)

– more blue if a detective searched them
if ply.search_result and (LocalPlayer():IsDetective() or (not ply.search_result.show)) then
self.sresult:SetImageColor(Color(200, 200, 255))
end

– cols are likely to need re-centering
self:LayoutColumns()

if self.info then
self.info:UpdatePlayerData()
end

if self.Player != LocalPlayer() then
local muted = self.Player:IsMuted()
self.voice:SetImage(muted and “icon16/sound_mute.png” or “icon16/sound.png”)
else
self.voice:Hide()
end
end

function PANEL:ApplySchemeSettings()
for k,v in pairs(self.cols) do
v:SetFont(“treb_small”)
v:SetTextColor(COLOR_WHITE)
end

self.nick:SetFont(“treb_small”)
self.nick:SetTextColor(ColorForPlayer(self.Player))

local ptag = self.Player and self.Player.sb_tag
self.tag:SetTextColor(ptag and ptag.color or COLOR_WHITE)
self.tag:SetFont(“treb_small”)

self.sresult:SetImage(“icon16/magnifier.png”)
self.sresult:SetImageColor(Color(170, 170, 170, 150))
end

function PANEL:LayoutColumns()
for k,v in ipairs(self.cols) do
v:SizeToContents()
v:SetPos(self:GetWide() - (50*k) - v:GetWide()/2, (SB_ROW_HEIGHT - v:GetTall()) / 2)
end

self.tag:SizeToContents()
self.tag:SetPos(self:GetWide() - (50 * 6) - self.tag:GetWide()/2, (SB_ROW_HEIGHT - self.tag:GetTall()) / 2)

self.sresult:SetPos(self:GetWide() - (50*6) - 8, (SB_ROW_HEIGHT - 16) / 2)
end

function PANEL:PerformLayout()
self.avatar:SetPos(0,0)
self.avatar:SetSize(SB_ROW_HEIGHT,SB_ROW_HEIGHT)

if not self.open then
self:SetSize(self:GetWide(), SB_ROW_HEIGHT)

  if self.info then self.info:SetVisible(false) end

elseif self.info then
self:SetSize(self:GetWide(), 100 + SB_ROW_HEIGHT)

  self.info:SetVisible(true)
  self.info:SetPos(5, SB_ROW_HEIGHT + 5)
  self.info:SetSize(self:GetWide(), 100)
  self.info:PerformLayout()

  self:SetSize(self:GetWide(), SB_ROW_HEIGHT + self.info:GetTall())

end

self.nick:SizeToContents()

self.nick:SetPos(SB_ROW_HEIGHT + 10, (SB_ROW_HEIGHT - self.nick:GetTall()) / 2)

self:LayoutColumns()

self.voice:SetVisible(not self.open)
self.voice:SetSize(16, 16)
self.voice:DockMargin(4, 4, 4, 4)
self.voice:Dock(RIGHT)
end

function PANEL:DoClick(x, y)
self:SetOpen(not self.open)
end

function PANEL:SetOpen(o)
if self.open then
surface.PlaySound(“ui/buttonclickrelease.wav”)
else
surface.PlaySound(“ui/buttonclick.wav”)
end

self.open = o

self:PerformLayout()
self:GetParent():PerformLayout()
sboard_panel:PerformLayout()
end

function PANEL:DoRightClick()
local ply = self.Player

	if LocalPlayer():IsAdmin() or LocalPlayer():IsSuperAdmin() then	
	surface.PlaySound("buttons/button9.wav")
		local options = DermaMenu()
		options:AddOption("Copy Name", function() SetClipboardText(ply:Nick()) surface.PlaySound("buttons/button9.wav") end):SetImage("icon16/user_edit.png")
		options:AddOption("Copy SteamID", function() SetClipboardText(ply:SteamID()) surface.PlaySound("buttons/button9.wav") end):SetImage("icon16/tag_blue.png")
		options:AddSpacer()
		options:AddOption("Open Profile", function() ply:ShowProfile() surface.PlaySound("buttons/button9.wav") end):SetImage("icon16/world.png")
		options:AddSpacer()

		if IsValid(ply) then
			local adminop,subimg = options:AddSubMenu("Admin")
				subimg:SetImage("icon16/lorry.png")
				adminop:AddOption("Slay Next Round", function() RunConsoleCommand("ulx","slaynr",ply:Nick()) surface.PlaySound("buttons/button9.wav") end):SetImage("icon16/cross.png")
				adminop:AddOption("Slay Now", function() RunConsoleCommand("ulx","slay",ply:Nick()) surface.PlaySound("buttons/button9.wav") end):SetImage("icon16/cut_red.png")
				adminop:AddOption("Kick", function() RunConsoleCommand("ulx","kick",ply:Nick(),"You were kicked") surface.PlaySound("buttons/button9.wav") end):SetImage("icon16/door_out.png")
				adminop:AddOption("Ban", function() RunConsoleCommand("ulx","ban",ply:Nick(),120,"You were banned") surface.PlaySound("buttons/button9.wav") end):SetImage("icon16/delete.png")
				adminop:AddSpacer()
				adminop:AddOption("Mute", function() RunConsoleCommand("ulx","mute",ply:Nick()) surface.PlaySound("buttons/button9.wav") end):SetImage("icon16/asterisk_yellow.png")
				adminop:AddOption("Gag", function() RunConsoleCommand("ulx","gag",ply:Nick()) surface.PlaySound("buttons/button9.wav") end):SetImage("icon16/asterisk_orange.png")
				adminop:AddSpacer()
				adminop:AddOption("Spectate", function() RunConsoleCommand("ulx","spectate",ply:Nick()) surface.PlaySound("buttons/button9.wav") end):SetImage("icon16/zoom.png")
				adminop:AddSpacer()
			options:Open()
			end
		end
	end

vgui.Register( “TTTScorePlayerRow”, PANEL, “Button” )

Any help would be greatly appreciated.

http://forum.facepunch.com/showthread.php?t=1377583&p=44292867&viewfull=1#post44292867

Don’t bother messing with the core files. Ttt recently got added new hooks to do this. I already gave the code on how to to do this exact thing In the link provided.

I checked in lua/autorun/client and there was no cl_scoreboardtags.lua to modify. (The complete path that I went to was GMod_Server/garrysmod/lua/autorun/client)

Make it yourself then. It doesn’t have to be cl_scoreboardtags it can be poopoo.lua if you wanted.

Also before you say it doesn’t work and there are no errors, please make sure you’re on the latest version of TTT.

I made the lua file and added the coding into it and I get these errors:
[ERROR] lua/autorun/client/cl_scoreboardtags.lua:3: attempt to index global ‘tttRankcolours’ (a nil value)

  1. fn - lua/autorun/client/cl_scoreboardtags.lua:3
  2. Call - addons/ulib/lua/ulib/shared/hook.lua:183
    3. ColorForPlayer - gamemodes/terrortown/gamemode/vgui/sb_row.lua:120
    4. UpdatePlayerData - gamemodes/terrortown/gamemode/vgui/sb_row.lua:205
    5. SetPlayer - gamemodes/terrortown/gamemode/vgui/sb_row.lua:186
    6. AddPlayerRow - addons/ttt spectator deathmatch/lua/cl_spectator_deathmatch.lua:151
    7. old_UpdateScoreboard - gamemodes/terrortown/gamemode/vgui/sb_main.lua:270
    8. UpdateScoreboard - addons/ttt spectator deathmatch/lua/cl_spectator_deathmatch.lua:145
    9. old_Init - gamemodes/terrortown/gamemode/vgui/sb_main.lua:140
    10. Init - addons/ttt spectator deathmatch/lua/cl_spectator_deathmatch.lua:130
    11. Create - lua/includes/extensions/client/panel/scriptedpanels.lua:153
    12. ScoreboardCreate - gamemodes/terrortown/gamemode/cl_scoreboard.lua:27
    13. unknown - gamemodes/terrortown/gamemode/cl_scoreboard.lua:34

[ERROR] lua/autorun/client/cl_scoreboardtags.lua:3: attempt to index global ‘tttRankcolours’ (a nil value)

  1. fn - lua/autorun/client/cl_scoreboardtags.lua:3
  2. Call - addons/ulib/lua/ulib/shared/hook.lua:183
    3. ColorForPlayer - gamemodes/terrortown/gamemode/vgui/sb_row.lua:120
    4. unknown - gamemodes/terrortown/gamemode/vgui/sb_row.lua:287

[ERROR] lua/autorun/client/cl_scoreboardtags.lua:3: attempt to index global ‘tttRankcolours’ (a nil value)

  1. fn - lua/autorun/client/cl_scoreboardtags.lua:3
  2. Call - addons/ulib/lua/ulib/shared/hook.lua:183
    3. ColorForPlayer - gamemodes/terrortown/gamemode/vgui/sb_row.lua:120
    4. unknown - gamemodes/terrortown/gamemode/vgui/sb_row

You either didn’t copy the entire code (looks like you missed the table at the top) or you haven’t added your specific user group to the table. Make sure you copied all of the code, then make sure you’ve added your user groups & colours like the donator example also in the post.

I have added all of the coding and, I know this is going to sound like a broken record to you, but the names of the people do not match the color of their rank. (And yes, I did check if it was up to date)

Add the code at the bottom of the post I directed you to in the first place, where I said something along the lines “as an extension…”.

If you mean the colours don’t match I.e they’re different from each other as in name is green and rank is yellow, post a screenshot and the code you have in your file.

I did add the code at the bottom of the post but the names of the people were still all white. Thanks for trying to help, but I figured out a code that works.