• TTT - Scoreboard - Titles getting in way
    0 replies, posted
I edited my TTT scoreboard on my server so I can display Ranks and custom titles for members. I also moved the Rank and Title column to the left of their original position so this way they aren't all bunched up with each other. They display perfectly fine for me, but other people stated that my title was overlapping my name, and others said it appeared underneath my name, while the other few said it was right next to my name. But on my screen it is closer to the middle of the screen; not at all close to my name. Here is the sb_row.lua Any idea what the issue could be? [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")) if KARMA.IsEnabled() then self.cols[4] = vgui.Create("DLabel", self) self.cols[4]:SetText(GetTranslation("sb_karma")) end self.cols[5] = vgui.Create("DLabel", self) self.cols[5]:SetText("Rank") self.cols[6] = vgui.Create("DLabel", self) self.cols[6]:SetText("Title") 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 local namecolor = { default = COLOR_WHITE, admin = Color(255, 0, 0, 255), dev = Color(102, 255, 102, 255) }; function GM:TTTScoreboardColorForPlayer(ply) if not IsValid(ply) then return namecolor.default end if ply:SteamID() == "STEAM_0:0:14117858" then return namecolor.admin elseif ply:IsAdmin() and GetGlobalBool("ttt_highlight_admins", true) then return namecolor.admin 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!\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 if ply:IsUserGroup("owner") then self.cols[5]:SetText("Owner") self.cols[5]:SetTextColor(Color(255,0,0,255)) end if ply:IsUserGroup("user") then self.cols[5]:SetText("") self.cols[5]:SetTextColor(Color(255,255,255,255)) end if ply:IsUserGroup("moderator") then self.cols[5]:SetText("Mod") self.cols[5]:SetTextColor(Color(255,255,0,255)) end if ply:IsUserGroup("admin") then self.cols[5]:SetText("Admin") self.cols[5]:SetTextColor(Color(255,119,0,255)) end if ply:IsUserGroup("mini-mod") then self.cols[5]:SetText("Mini-Mod") self.cols[5]:SetTextColor(Color(102,178,255,102)) end if ply:IsUserGroup("trusted") then self.cols[5]:SetText("Trusted") self.cols[5]:SetTextColor(Color(255,255,255,255)) end if ply:IsUserGroup("donator") then self.cols[5]:SetText("Donator") self.cols[5]:SetTextColor(Color(255,255,255,255)) end if ply:IsUserGroup("respected") then self.cols[5]:SetText("Respected") self.cols[5]:SetTextColor(Color(255,255,255,255)) end if ply:IsUserGroup("respected") then self.cols[6]:SetText("") self.cols[6]:SetTextColor(Color(255,255,255,255)) end if ply:IsUserGroup("donator") then self.cols[6]:SetText("") self.cols[6]:SetTextColor(Color(255,255,255,255)) end if ply:IsUserGroup("trusted") then self.cols[6]:SetText("") self.cols[6]:SetTextColor(Color(255,255,255,255)) end if ply:IsUserGroup("mini-mod") then self.cols[6]:SetText("") self.cols[6]:SetTextColor(Color(255,255,255,255)) end if ply:IsUserGroup("admin") then self.cols[6]:SetText("") self.cols[6]:SetTextColor(Color(255,255,255,255)) end if ply:IsUserGroup("moderator") then self.cols[6]:SetText("") self.cols[6]:SetTextColor(Color(255,255,255,255)) end if ply:IsUserGroup("superadmin") then self.cols[6]:SetText("") self.cols[6]:SetTextColor(Color(255,255,255,255)) end if ply:IsUserGroup("owner") then self.cols[6]:SetText("(╯°□°)╯︵ ┻━┻") self.cols[6]:SetTextColor(Color(255,153,255,255)) end if ply:IsUserGroup("user") then self.cols[6]:SetText("") self.cols[6]:SetTextColor(Color(255,255,255,255)) end self.nick:SetText(ply:Nick()) self.nick:SizeToContents() self.nick:SetTextColor(ColorForPlayer(ply)) 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:Upda
Sorry, you need to Log In to post a reply to this thread.