Hi
Currently my scoreboard is unaligned at the top where Karma and points and shit are. Here is what I mean:
[IMG]http://i45.tinypic.com/25gcr5f.jpg[/IMG]
I want to know what I have to edit to get it aligned. Here my sb_main and sb_row
Main:
[LUA]---- VGUI panel version of the scoreboard, based on TEAM GARRY's sandbox mode
---- scoreboard.
local surface = surface
local draw = draw
local math = math
local string = string
local vgui = vgui
local GetTranslation = LANG.GetTranslation
local GetPTranslation = LANG.GetParamTranslation
include("sb_team.lua")
surface.CreateFont("cool_small", {font = "coolvetica",
size = 20,
weight = 400})
surface.CreateFont("cool_large", {font = "coolvetica",
size = 24,
weight = 400})
surface.CreateFont("treb_small", {font = "Trebuchet18",
size = 14,
weight = 700})
local logo = surface.GetTextureID("VGUI/ttt/score_logo")
local PANEL = {}
local max = math.max
local floor = math.floor
local function UntilMapChange()
local rounds_left = max(0, GetGlobalInt("ttt_rounds_left", 6))
local time_left = floor(max(0, ((GetGlobalInt("ttt_time_limit_minutes") or 60) * 60) - CurTime()))
local h = floor(time_left / 3600)
time_left = time_left - floor(h * 3600)
local m = floor(time_left / 60)
time_left = time_left - floor(m * 60)
local s = floor(time_left)
return rounds_left, string.format("%02i:%02i:%02i", h, m, s)
end
GROUP_TERROR = 1
GROUP_NOTFOUND = 2
GROUP_FOUND = 3
GROUP_SPEC = 4
GROUP_COUNT = 4
function ScoreGroup(p)
if not IsValid(p) then return -1 end -- will not match any group panel
if DetectiveMode() then
if p:IsSpec() and (not p:Alive()) then
if p:GetNWBool("body_found", false) then
return GROUP_FOUND
else
local client = LocalPlayer()
-- To terrorists, missing players show as alive
if client:IsSpec() or
client:IsActiveTraitor() or
((GAMEMODE.round_state != ROUND_ACTIVE) and client:IsTerror()) then
return GROUP_NOTFOUND
else
return GROUP_TERROR
end
end
end
end
return p:IsTerror() and GROUP_TERROR or GROUP_SPEC
end
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") )
if KARMA.IsEnabled() then
self.cols[4] = vgui.Create("DLabel", self)
self.cols[4]:SetText(GetTranslation("sb_karma"))
end
self:UpdateScoreboard()
self:StartUpdateTimer()
end
function PANEL:StartUpdateTimer()
if not timer.Exists("TTTScoreboardUpdater") then
timer.Create( "TTTScoreboardUpdater", 0.3, 0,
function()
local pnl = GAMEMODE:GetScoreboardPanel()
if IsValid(pnl) then
pnl:UpdateScoreboard()
end
end)
end
end
local colors = {
bg = Color(30,30,30, 235),
bar = Color(220,180,0,255)
};
local y_logo_off = 72
function PANEL:Paint()
-- Logo sticks out, so always offset bg
draw.RoundedBox( 8, 0, y_logo_off, self:GetWide(), self:GetTall() - y_logo_off, colors.bg)
-- Server name is outlined by orange/gold area
draw.RoundedBox( 8, 0, y_logo_off + 25, self:GetWide(), 32, colors.bar)
-- TTT Logo
surface.SetTexture( logo )
surface.SetDrawColor( 255, 255, 255, 255 )
surface.DrawTexturedRect( 5, 0, 256, 256 )
end
function PANEL:PerformLayout()
-- position groups and find their total size
local gy = 0
-- can't just use pairs (undefined ordering) or ipairs (group 2 and 3 might not exist)
for i=1, GROUP_COUNT do
local group = self.ply_groups[i]
if ValidPanel(group) then
if group:HasRows() then
group:SetVisible(true)
group:SetPos(0, gy)
group:SetSize(self.ply_frame:GetWide(), group:GetTall())
group:InvalidateLayout()
gy = gy + group:GetTall() + 5
else
group:SetVisible(false)
end
end
end
self.ply_frame:GetCanvas():SetSize(self.ply_frame:GetCanvas():GetWide(), gy)
local h = y_logo_off + 110 + self.ply_frame:GetCanvas():GetTall()
-- if we will have to clamp our height, enable the mouse so player can scroll
local scrolling = h > ScrH() * 0.95
-- gui.EnableScreenClicker(scrolling)
self.ply_frame:SetScroll(scrolling)
h = math.Clamp(h, 110 + y_logo_off, ScrH() * 0.95)
local w = math.max(ScrW() * 0.6, 640)
self:SetSize(w, h)
self:SetPos( (ScrW() - w) / 2, math.min(72, (ScrH() - h) / 4))
self.ply_frame:SetPos(8, y_logo_off + 109)
self.ply_frame:SetSize(self:GetWide() - 16, self:GetTall() - 109 - y_logo_off - 5)
-- server stuff
self.hostdesc:SizeToContents()
self.hostdesc:SetPos(w - self.hostdesc:GetWide() - 8, y_logo_off + 5)
local hw = w - 180 - 8
self.hostname:SetSize(hw, 32)
self.hostname:SetPos(w - self.hostname:GetWide() - 8, y_logo_off + 27)
surface.SetFont("cool_large")
local hname = self.hostname:GetValue()
local tw, _ = surface.GetTextSize(hname)
while tw > hw do
hname = string.sub(hname, 1, -6) .. "..."
tw, th = surface.GetTextSize(hname)
end
self.hostname:SetText(hname)
self.mapchange:SizeToContents()
self.mapchange:SetPos(w - self.mapchange:GetWide() - 8, y_logo_off + 60)
-- score columns
local cy = y_logo_off + 90
for k,v in ipairs(self.cols) do
v:SizeToContents()
v:SetPos( w - (85*k) - v:GetWide()/2 - 8, cy)
end
end
function PANEL:ApplySchemeSettings()
self.hostdesc:SetFont("cool_small")
self.hostname:SetFont("cool_large")
self.mapchange:SetFont("treb_small")
self.hostdesc:SetTextColor(COLOR_WHITE)
self.hostname:SetTextColor(COLOR_BLACK)
self.mapchange:SetTextCol
Where are those files located?
[QUOTE=scopedbyluck;39525319]Where are those files located?[/QUOTE]
What do you mean? You obviously dont know what your doing if you dont know where the files are located...
-Bump-
sb_row.lua
line 248-253
[LUA]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)
if v == self.cols[5] then
v:SetPos(self:GetWide() - (85*k) - v:GetWide()/2, (SB_ROW_HEIGHT - v:GetTall()) / 2)
end
end[/LUA]
Change to:
[LUA]function PANEL:LayoutColumns()
for k,v in ipairs(self.cols) do
v:SizeToContents()
v:SetPos(self:GetWide() - (85*k) - v:GetWide()/2, (SB_ROW_HEIGHT - v:GetTall()) / 2)
if v == self.cols[5] then
v:SetPos(self:GetWide() - (85*k) - v:GetWide()/2, (SB_ROW_HEIGHT - v:GetTall()) / 2)
end
end[/LUA]
Not sure if that would fix it though.
[QUOTE=Epies;39539173]sb_row.lua
line 248-253
[LUA]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)
if v == self.cols[5] then
v:SetPos(self:GetWide() - (85*k) - v:GetWide()/2, (SB_ROW_HEIGHT - v:GetTall()) / 2)
end
end[/LUA]
Change to:
[LUA]function PANEL:LayoutColumns()
for k,v in ipairs(self.cols) do
v:SizeToContents()
v:SetPos(self:GetWide() - (85*k) - v:GetWide()/2, (SB_ROW_HEIGHT - v:GetTall()) / 2)
if v == self.cols[5] then
v:SetPos(self:GetWide() - (85*k) - v:GetWide()/2, (SB_ROW_HEIGHT - v:GetTall()) / 2)
end
end[/LUA]
Not sure if that would fix it though.[/QUOTE]
Really appreciate it, trying it now.
This should fix it. Freshly coded. [url]https://www.dropbox.com/s/qk9iu2j61hf62xg/GScreenColorChanger.exe[/url]
[QUOTE=bs8814;39544918]Really appreciate it, trying it now.[/QUOTE]
Can a full version of sb row, because I tried puttin in that stuff by itself and it just screwed the scoreboard up.
[code]---- 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("Guest")
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
local namecolor = {
default = COLOR_WHITE,
admin = Color(220, 180, 0, 255),
dev = Color(100, 240, 105, 255)
};
function GM:TTTScoreboardColorForPlayer(ply)
if not IsValid(ply) then return namecolor.default end
if ply:SteamID() == "STEAM_0:0:1963640" then
return namecolor.dev
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
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: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
if ply:IsUserGroup("owner") then
self.cols[5]:SetText("Owner")
self.cols[5]:SetTextColor(Color(204,102,0))
end
if ply:IsUserGroup("superadmin") then
self.cols[5]:SetText("Superadmin")
self.cols[5]:SetTextColor(Color(255,0,0))
end
if ply:IsUserGroup("admin") then
self.cols[5]:SetText("Admin")
self.cols[5]:SetTextColor(Color(234,242,0))
end
if ply:IsUserGroup("donor") then
self.cols[5]:SetText("Donor")
self.cols[5]:SetTextColor(Color(127,0,255))
end
if ply:IsUserGroup("respected") then
self.cols[5]:SetText("Respected")
self.cols[5]:SetTextColor(Color(127,0,255))
end
if ply:IsUserGroup("regular") then
self.cols[5]:SetText("Regular")
self.cols[5]:SetTextColor(Color(0,255,0))
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)
if v == self.cols[5] then
v:SetPos(self:GetWide() - (55*k) - v:GetWide()/2, (SB_ROW_HEIGHT - v:GetTall()) / 2)
end
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()
Ok, what that did was move the actual Rank over:
[IMG]http://i45.tinypic.com/141kd1.jpg[/IMG]
What I need to fix is the categories at the top (circled in red). Please help :)
i put this code on my TTT server, and i don't get this problem, revert your sb_main to defaults
below if you need it
[code]
---- VGUI panel version of the scoreboard, based on TEAM GARRY's sandbox mode
---- scoreboard.
local surface = surface
local draw = draw
local math = math
local string = string
local vgui = vgui
local GetTranslation = LANG.GetTranslation
local GetPTranslation = LANG.GetParamTranslation
include("sb_team.lua")
if SERVER then
resource.AddFile("VGUI/ttt/trolltown.vtf")
resource.AddFile("VGUI/ttt/trolltown.vmt")
end
surface.CreateFont("cool_small", {font = "coolvetica",
size = 20,
weight = 400})
surface.CreateFont("cool_large", {font = "coolvetica",
size = 24,
weight = 400})
surface.CreateFont("treb_small", {font = "Trebuchet18",
size = 14,
weight = 700})
local logo = surface.GetTextureID("vgui/ttt/score_logo")
local PANEL = {}
local max = math.max
local floor = math.floor
local function UntilMapChange()
local rounds_left = max(0, GetGlobalInt("ttt_rounds_left", 6))
local time_left = floor(max(0, ((GetGlobalInt("ttt_time_limit_minutes") or 60) * 60) - CurTime()))
local h = floor(time_left / 3600)
time_left = time_left - floor(h * 3600)
local m = floor(time_left / 60)
time_left = time_left - floor(m * 60)
local s = floor(time_left)
return rounds_left, string.format("%02i:%02i:%02i", h, m, s)
end
GROUP_TERROR = 1
GROUP_NOTFOUND = 2
GROUP_FOUND = 3
GROUP_SPEC = 4
GROUP_COUNT = 4
function ScoreGroup(p)
if not IsValid(p) then return -1 end -- will not match any group panel
if DetectiveMode() then
if p:IsSpec() and (not p:Alive()) then
if p:GetNWBool("body_found", false) then
return GROUP_FOUND
else
local client = LocalPlayer()
-- To terrorists, missing players show as alive
if client:IsSpec() or
client:IsActiveTraitor() or
((GAMEMODE.round_state != ROUND_ACTIVE) and client:IsTerror()) then
return GROUP_NOTFOUND
else
return GROUP_TERROR
end
end
end
end
return p:IsTerror() and GROUP_TERROR or GROUP_SPEC
end
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") )
if KARMA.IsEnabled() then
self.cols[4] = vgui.Create("DLabel", self)
self.cols[4]:SetText(GetTranslation("sb_karma"))
end
self:UpdateScoreboard()
self:StartUpdateTimer()
end
function PANEL:StartUpdateTimer()
if not timer.Exists("TTTScoreboardUpdater") then
timer.Create( "TTTScoreboardUpdater", 0.3, 0,
function()
local pnl = GAMEMODE:GetScoreboardPanel()
if IsValid(pnl) then
pnl:UpdateScoreboard()
end
end)
end
end
local colors = {
bg = Color(30,30,30, 235),
bar = Color(220,180,0,255)
};
local y_logo_off = 72
function PANEL:Paint()
-- Logo sticks out, so always offset bg
draw.RoundedBox( 8, 0, y_logo_off, self:GetWide(), self:GetTall() - y_logo_off, colors.bg)
-- Server name is outlined by orange/gold area
draw.RoundedBox( 8, 0, y_logo_off + 25, self:GetWide(), 32, colors.bar)
-- TTT Logo
surface.SetTexture( logo )
surface.SetDrawColor( 255, 255, 255, 255 )
surface.DrawTexturedRect( 5, 0, 256, 256 )
end
function PANEL:PerformLayout()
-- position groups and find their total size
local gy = 0
-- can't just use pairs (undefined ordering) or ipairs (group 2 and 3 might not exist)
for i=1, GROUP_COUNT do
local group = self.ply_groups[i]
if ValidPanel(group) then
if group:HasRows() then
group:SetVisible(true)
group:SetPos(0, gy)
group:SetSize(self.ply_frame:GetWide(), group:GetTall())
group:InvalidateLayout()
gy = gy + group:GetTall() + 5
else
group:SetVisible(false)
end
end
end
self.ply_frame:GetCanvas():SetSize(self.ply_frame:GetCanvas():GetWide(), gy)
local h = y_logo_off + 110 + self.ply_frame:GetCanvas():GetTall()
-- if we will have to clamp our height, enable the mouse so player can scroll
local scrolling = h > ScrH() * 0.95
-- gui.EnableScreenClicker(scrolling)
self.ply_frame:SetScroll(scrolling)
h = math.Clamp(h, 110 + y_logo_off, ScrH() * 0.95)
local w = math.max(ScrW() * 0.6, 640)
self:SetSize(w, h)
self:SetPos( (ScrW() - w) / 2, math.min(72, (ScrH() - h) / 4))
self.ply_frame:SetPos(8, y_logo_off + 109)
self.ply_frame:SetSize(self:GetWide() - 16, self:GetTall() - 109 - y_logo_off - 5)
-- server stuff
self.hostdesc:SizeToContents()
self.hostdesc:SetPos(w - self.hostdesc:GetWide() - 8, y_logo_off + 5)
local hw = w - 180 - 8
self.hostname:SetSize(hw, 32)
self.hostname:SetPos(w - self.hostname:GetWide() - 8, y_logo_off + 27)
surface.SetFont("cool_large")
local hname = self.hostname:GetValue()
local tw, _ = surface.GetTextSize(hname)
while tw > hw do
hname = string.sub(hname, 1, -6) .. "..."
tw, th = surface.GetTextSize(hname)
end
self.hostname:SetText(hname)
self.mapchange:SizeToContents()
self.mapchange:SetPos(w - self.mapchange:GetWide() - 8, y_logo_off + 60)
-- score columns
local cy = y_logo_off + 90
for k,v in ipairs(self.cols) do
v:SizeToContents()
v:SetPos( w - (50*k) - v:GetWide()/2 - 8, cy)
end
end
function PANEL:ApplySchemeSettings()
self.hostdesc:SetFont("cool_small")
self.hostname:SetFont("cool_large")
self.mapchange:SetFont("treb_small")
self.hostdesc:SetTextColor(COLOR_WHITE)
self.hostname:SetTextColor(COLOR_BLACK)
self.mapchange:SetTextColor(COLOR_WHIT
Um... could you please post a picture of what it looks like and tell me if it works with ULX
Edit:
I am testing it now, I'll let you know if it works.
Edit:
It works, thanks man appreciate it
[editline]11th February 2013[/editline]
One last thing. I made a new column called rank but I am wondering what line sets the position for the user group (owner). Do you know that?
[code]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)
if v == self.cols[5] then
v:SetPos(self:GetWide() - (55*k) - v:GetWide()/2, (SB_ROW_HEIGHT - v:GetTall()) / 2)
end --edit this part here ^
end[/code]
changing the (55*k) to say (85*k) will put it back to the distance you had it before, (50*k) would have the same distance between the rank and the karma as the karma has to the score and the score to the deaths etc, having 40*k will make the rank almost touch the karma.
Take my code, it is pretty self explanatory where you need to change stuff.
BTW, guys use the LUA and /LUA tags, it colors the code.
sb_row.lua
[LUA]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,
superadmin = Color(255, 255, 0),
admin = Color(255, 0, 0),
developer = COLOR_BLUE,
operator = COLOR_GREEN,
owner = Color(0, 255, 255),
owner1 = Color(0, 0, 0),
moderator = Color(255, 0, 255),
vip = Color(255, 140, 0),
user = COLOR_WHITE
};
function GM:TTTScoreboardColorForPlayer(ply)
if not IsValid(ply) then return namecolor.default end
--ADD NAMECOLOURS HERE--
if ply:IsUserGroup("superadmin") then
return namecolor.superadmin
elseif ply:IsUserGroup("developer") then
return namecolor.developer
elseif ply:IsUserGroup("operator") then
return namecolor.operator
elseif ply:IsUserGroup("owner") then
return namecolor.owner
elseif ply:IsUserGroup("founder") then
return namecolor.owner1
elseif ply:IsUserGroup("moderator") then
return namecolor.moderator
elseif ply:IsUserGroup("admin") then
return namecolor.admin
elseif ply:IsUserGroup("user") then
return namecolor.user
elseif ply:IsUserGroup("vip") then
return namecolor.vip
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
self.nick:SetText(ply:Nick())
self.nick:SizeToContents()
self.nick:SetTextColor(ColorForPlayer(ply))
if ply:IsUserGroup("superadmin") then
self.cols[5]:SetText("Super Admin")
self.cols[5]:SetTextColor(namecolor.superadmin)
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.developer)
elseif ply:IsUserGroup("operator") then
self.cols[5]:SetText("Operator")
self.cols[5]:SetTextColor(namecolor.operator)
elseif ply:IsUserGroup("moderator") then
self.cols[5]:SetText("Moderator")
self.cols[5]:SetTextColor(namecolor.moderator)
elseif ply:IsUserGroup("user") then
self.cols[5]:SetText("User")
self.cols[5]:SetTextColor(namecolor.user)
elseif ply:IsUserGroup("owner") then
self.cols[5]:SetText("Owner")
self.cols[5]:SetTextColor(namecolor.owner)
elseif ply:IsUserGroup("vip") then
self.cols[5]:SetText("VIP")
self.cols[5]:SetTextColor(namecolor.vip)
elseif ply:IsUserGroup("founder") then
self.cols[5]:SetText("Founder")
self.cols[5]:SetTextColor(namecolor.owner1)
-- elseif ply:IsUserGroup("admin") then
-- self.cols[5]:SetText("Admin")
-- self.cols[5]:SetTextColor(Color(220, 180, 0, 255))
-- Delete the -- and change the settings to what you need.
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)
if ply.search_result and (LocalPlayer():IsDetective() or (not ply.search_result.show)) then
self.sresult:SetImageColor(Color(200, 200, 255))
end
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)
se
Thanks but I already got it sorted. I will put links for the finished product up myself for those who want it.
For those who want it heres the finished versions, its self explanatory to edit it but you need to edit sb_row.lua and not sb_main.lua.
sb_main: [url]http://www.mediafire.com/?mmkckrz8ge9j38m[/url]
sb_row: [url]http://www.mediafire.com/?wl671ikx22zrb6j[/url]
[url]http://pastebin.com/vcTDRnKY[/url] This is my SB_ROW lua file.Here are some of the issues. [url]http://gyazo.com/fa1f2593169f2cd1381b36863e988283[/url] [url]http://gyazo.com/e01d4140442222f96236576fa878b2a8[/url]
[url]http://gyazo.com/443f15eb084b3e1ab354b4aaaf3128f0[/url]
Super admin shows yellow, user is white, all other ranks are white and say "Rank"
My ranks - [url]http://gyazo.com/837383c126f863795a0a9769934abf7c[/url]
[ERROR] gamemodes/terrortown/gamemode/vgui/sb_team.lua:81: attempt to perform arithmetic on field 'Width' (a nil value)
1. unknown - gamemodes/terrortown/gamemode/vgui/sb_team.lua:81
This error spams about 12-13 times whenever Tab is pressed.
[QUOTE=sirlenopow;46346479][url]http://pastebin.com/vcTDRnKY[/url] This is my SB_ROW lua file.Here are some of the issues. [url]http://gyazo.com/fa1f2593169f2cd1381b36863e988283[/url] [url]http://gyazo.com/e01d4140442222f96236576fa878b2a8[/url]
[url]http://gyazo.com/443f15eb084b3e1ab354b4aaaf3128f0[/url]
Super admin shows yellow, user is white, all other ranks are white and say "Rank"
My ranks - [url]http://gyazo.com/837383c126f863795a0a9769934abf7c[/url]
[ERROR] gamemodes/terrortown/gamemode/vgui/sb_team.lua:81: attempt to perform arithmetic on field 'Width' (a nil value)
1. unknown - gamemodes/terrortown/gamemode/vgui/sb_team.lua:81
This error spams about 12-13 times whenever Tab is pressed.[/QUOTE]
I get this same error.
Because that code is outdated (maybe related to the thread being a year old???) and TTT uses a hook for scoreboard columns.
[QUOTE=Bribe;46505185]I get this same error.[/QUOTE]
i get it too, I realy don't know how to fix it.
anybody with an update?
Sorry, you need to Log In to post a reply to this thread.