Pairing with Steam ID's

I wanted to pair scoreboard titles and ranks with Steam ID’s rather than groups. To further elaborate, I currently have groups for certain individuals so they can have a custom title and rank for the scoreboard on TTT. I have groups made for this but it is getting rather messy now. I know there is a way to pair them up with their respective Steam ID instead. Below is only a portion of the code, but it should be enough to display what I’m talking about.

[lua]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

if ply:IsUserGroup(“owner”) then
self.cols[5]:SetText(“Owner”)
self.cols[5]:SetTextColor(Color(255,0,0,255))
end

if ply:IsUserGroup(“moderator”) then
self.cols[5]:SetText(“Mod”)
self.cols[5]:SetTextColor(Color(255,255,0,255))
end

if ply:SteamID() == “STEAM_0:1:61698892” then
self.cols[6]:SetText(“Cutie Patootie”)
self.cols[6]:SetTextColor(Color(255,255,0,255))
end[/lua]

Here it shows the person with the SteamID paired along with a ‘title’. However it doesn’t work in the server. It only screws it up. However, this method works fine with pairing their ID up with their rank where the [5] is shown.

I may be over looking a small detail and I just need another set of eyes with this I think. If there is another page/set of code that you need to see in order to assist me, then please say so.

I’m not quite sure what you are trying to do.

If you are trying to get “Cutie Patootie” to display in the same column as “Mod”, you need to change that 6 to a 5.



if ply:SteamID() == "STEAM_0:1:61698892" then
    self.cols[5]:SetText("Cutie Patootie")
    self.cols[5]:SetTextColor(Color(255,255,0,255))
end


If you are trying to create a new column for custom, steam-id based titles, make sure you are adding the column in /terrortown/gamemode/vgui/sb_main.lua:



self.cols[6] = vgui.Create("DLabel", self)
self.cols[6]:SetText("Personal Title")


I already have that done in the sb_main.lua, as you can see below:

[lua]
function PANEL:Init()

self.hostdesc = vgui.Create(“DLabel”, self)
self.hostdesc:SetText(GetTranslation(“sb_playing”))
self.hostdesc:SetContentAlignment(9)

self.hostname = vgui.Create( “DLabel”, self )
self.hostname:SetText( GetHostName() )
self.hostname:SetContentAlignment(6)

self.mapchange = vgui.Create(“DLabel”, self)
self.mapchange:SetText(“Map changes in 00 rounds or in 00:00:00”)
self.mapchange:SetContentAlignment(9)

self.mapchange.Think = function (sf)
local r, t = UntilMapChange()

                         sf:SetText(GetPTranslation("sb_mapchange",
                                                    {num = r, time = t}))
                         sf:SizeToContents()
                      end

self.ply_frame = vgui.Create( “TTTPlayerFrame”, self )

self.ply_groups = {}

local t = vgui.Create(“TTTScoreGroup”, self.ply_frame:GetCanvas())
t:SetGroupInfo(GetTranslation(“terrorists”), Color(0,200,0,100), GROUP_TERROR)
self.ply_groups[GROUP_TERROR] = t

t = vgui.Create(“TTTScoreGroup”, self.ply_frame:GetCanvas())
t:SetGroupInfo(GetTranslation(“spectators”), Color(200, 200, 0, 100), GROUP_SPEC)
self.ply_groups[GROUP_SPEC] = t

if DetectiveMode() then
t = vgui.Create(“TTTScoreGroup”, self.ply_frame:GetCanvas())
t:SetGroupInfo(GetTranslation(“sb_mia”), Color(130, 190, 130, 100), GROUP_NOTFOUND)
self.ply_groups[GROUP_NOTFOUND] = t

  t = vgui.Create("TTTScoreGroup", self.ply_frame:GetCanvas())
  t:SetGroupInfo(GetTranslation("sb_confirmed"), Color(130, 170, 10, 100), GROUP_FOUND)
  self.ply_groups[GROUP_FOUND] = t

end

– the various score column headers
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”)

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

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

self:UpdateScoreboard()
self:StartUpdateTimer()
end
[/lua]

The previous example I gave in the other post was just a snippit of code. Cutie Patootie was just for instance. You can pair username colors with SteamIDs like so:

[lua]
local namecolor = {
default = COLOR_WHITE,
admin = Color(255, 119, 0, 255),
dev = Color(255, 0, 0, 255),
liquid = Color(255, 255, 255, 255)
};

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

if ply:SteamID() == “STEAM_0:0:00000000” then
return namecolor.dev
elseif ply:IsAdmin() and GetGlobalBool(“ttt_highlight_admins”, true) then
return namecolor.admin
end
if ply:SteamID() == “STEAM_0:0:00000000” then
return namecolor.liquid
elseif ply:IsAdmin() and GetGlobalBool(“ttt_highlight_admins”, true) then
return namecolor.admin
end

return namecolor.default
end
[/lua]

Seen above shows a snippit of code from my sb_row.lua
Underneath “local namecolor - {” displays the names of groups within the ULX. Alongside of the group name has an RGB color. Further underneath that shows pairing those group names with SteamIDs.

This method works! However, I have difficult making it work with titles and ranks ( [5] & [6] )