• TTT Scoreboard Help!
    3 replies, posted
I tried to add colors for ULX user groups in the TTT scoreboard, and everything is fine except for an error that occurs within "cl_scoreboard.lua". The error says that on line 47 of cl_scoreboard the variable sboard_panels has a nil value. I searched for similar posts, but I tried their solutions to no avail. I would be very thankful if someone were to help. [B]sb_row[/B] [lua] ---- Scoreboard player score row, based on sandbox version include("sb_info.lua") local GetTranslation = LANG.GetTranslation local GetPTranslation = LANG.GetParamTranslation SB_ROW_HEIGHT = 24 --16 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, owner = Color(218, 165, 32, 255) admin = Color(220, 180, 255, 255), dev = Color(107, 30, 30, 255), smod = Color(124, 0, 255, 255), mod = Color(26, 0, 255, 255), tmod = Color(0, 247, 255, 255), dmod = Color(0, 218, 4, 255), vip = Color(181, 123, 0, 255) }; function GM:TTTScoreboardColorForPlayer(ply) if not IsValid(ply) then return namecolor.default end --ADD NAMECOLOURS HERE-- if ply:IsUserGroup( "superadmin" ) then return namecolor.owner elseif ply:IsUserGroup( "admin" ) then return namecolor.admin elseif ply:IsUserGroup( "Developer" ) then return namecolor.dev elseif ply:IsUserGroup( "mod" ) then return namecolor.mod elseif ply:IsUserGroup( "seniormod" ) then return namecolor.smod elseif ply:IsUserGroup("Dtrialmod") then return namecolor.dmod elseif ply:IsUserGroup("trialmod") then return namecolor.tmod elseif ply:IsUserGroup("vip") then return namecolor.vip elseif ply:IsUserGroup("regular") then 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!\n") 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( "Owner" ) self.cols[5]:SetTextColor(namecolor.owner) elseif ply:IsUserGroup( "admin" ) then self.cols[5]:SetText( "Admin" ) self.cols[5]:SetTextColor(namecolor.admin) elseif ply:IsUserGroup( "Developer" ) then self.cols[5]:SetText( "Developer" ) self.cols[5]:SetTextColor(namecolor.dev) elseif ply:IsUserGroup( "mod" ) then self.cols[5]:SetText( "Moderator" ) self.cols[5]:SetTextColor(namecolor.mod) elseif ply:IsUserGroup( "seniormod" ) then self.cols[5]:SetText( "Senior Mod" ) self.cols[5]:SetTextColor(namecolor.smod) elseif ply:IsUserGroup("Dtrialmod") then self.cols[5]:SetText("Donator Mod") self.cols[5]:SetTextColor(namecolor.dmod) elseif ply:IsUserGroup("trialmod") then self.cols[5]:SetText("Trial Mod") self.cols[5]:SetTextColor(namecolor.tmod) elseif ply:IsUserGroup("vip") then self.cols[5]:SetText("Donator") self.cols[5]:SetTextColor(namecolor.vip) elseif ply:IsUserGroup("regular") then self.cols[5]:SetText("Regular") self.cols[5]:SetTextColor(namecolor.default) 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 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
Restart the server when editing TTT files?
In my experiences setting up TTT servers, whenever I do something wrong while editing sb_row.lua or sb_main.lua, it always leads to sb_scoreboard. It's probably a little typo, missing quote, or something like that in sb_row. I could be wrong, but 9/10 times that I got an error in sb_scoreboard, I fixed the problem by resetting my sb_row.
On line 80 of sb_row your GM:TTTScoreboardColorForPlayer is missing an "end" to close the function. You also have an extra end at line 254.
Sorry, you need to Log In to post a reply to this thread.