I've looked around for code that puts a column in the scoreboard but all of the ones I have found either don't work or aren't for TTT.
Can anyone please show me or make a column for ranks in the ttt scoreboard?
This Fixed mine [url]http://coderhire.com/scripts/view/465[/url]
google:"site:facepunch.com how to add ranks to scoreboard"
1st: [url]http://www.facepunch.com/showthread.php?t=1229063[/url]
2nd: not related
3rd: [url]http://facepunch.com/showthread.php?t=1101202[/url]
4th: [url]http://facepunch.com/showthread.php?t=1241356[/url]
All of these have similar solutions. If you can't figure it out then you should hire someone OR ask for help with the code you have.
[QUOTE=Pandaman09;42274103]google:"site:facepunch.com how to add ranks to scoreboard"
1st: [url]http://www.facepunch.com/showthread.php?t=1229063[/url]
2nd: not related
3rd: [url]http://facepunch.com/showthread.php?t=1101202[/url]
4th: [url]http://facepunch.com/showthread.php?t=1241356[/url]
All of these have similar solutions. If you can't figure it out then you should hire someone OR ask for help with the code you have.[/QUOTE]
Yes I've tried all of those but they didn't work.
While the coderhire script will work it's a waste of money unless you want the ease of use. It's not difficult to add them yourself with a little amount of work.
[editline]22nd September 2013[/editline]
[QUOTE=GodzBro;42274111]Yes I've tried all of those but they didn't work.[/QUOTE]
Post what errors you have and I/someone else can help
[QUOTE=Pandaman09;42274131]While the coderhire script will work it's a waste of money unless you want the ease of use. It's not difficult to add them yourself with a little amount of work.
[editline]22nd September 2013[/editline]
Post what errors you have and I/someone else can help[/QUOTE]
This is my sb_row.lua:
[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
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 ply:IsUserGroup("Owner") then
set.cols[5]:SetText("Owner")
set.cols[5]:SetTextColor(Color(255,0,0))
elseif ply:IsUserGroup("Developer") then
set.cols[5]:SetText("Developer")
set.cols[5]:SetTextColor(Color(0,0,255))
elseif ply:IsUserGroup("admin") then
set.cols[5]:SetText("Admin")
set.cols[5]:SetTextColor(Color(255,255,0))
elseif ply:IsUserGroup("VIP") then
set.cols[5]:SetText("VIP")
set.cols[5]:SetTextColor(Color(0,255,0))
elseif ply:IsUserGroup("") then
set.cols[5]:SetText("")
set.cols[5]:SetTextColor(Color(0,0,255))
end
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
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
On line 153 you are trying to check if a player is rank owner
[code]if ply:IsUserGroup("Owner") then[/code]
but you are not saying what ply is.
If you move line 172-174:
[code] if not IsValid(self.Player) then return end
local ply = self.Player[/code]
to line 152, you are making it so that the code knows who you are talking about.
[QUOTE=Pandaman09;42274423]On line 153 you are trying to check if a player is rank owner
[code]if ply:IsUserGroup("Owner") then[/code]
but you are not saying what ply is.
If you move line 172-174:
[code] if not IsValid(self.Player) then return end
local ply = self.Player[/code]
to line 152, you are making it so that the code knows who you are talking about.[/QUOTE]
Thanks for the reply but now I'm getting more errors.
This is the updated code:
[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
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
if ply:IsUserGroup("Owner") then
set.cols[5]:SetText("Owner")
set.cols[5]:SetTextColor(Color(255,0,0))
elseif ply:IsUserGroup("Developer") then
set.cols[5]:SetText("Developer")
set.cols[5]:SetTextColor(Color(0,0,255))
elseif ply:IsUserGroup("admin") then
set.cols[5]:SetText("Admin")
set.cols[5]:SetTextColor(Color(255,255,0))
elseif ply:IsUserGroup("VIP") then
set.cols[5]:SetText("VIP")
set.cols[5]:SetTextColor(Color(0,255,0))
elseif ply:IsUserGroup("") then
set.cols[5]:SetText("")
set.cols[5]:SetTextColor(Color(0,0,255))
end
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
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)
add this:
[code]
self.cols[5] = vgui.Create("DLabel", self)
self.cols[5]:SetText("Rank")
[/code]
near line 34, you are trying to set a column that doesn't exist to something.
[QUOTE=Pandaman09;42274746]add this:
[code]
self.cols[5] = vgui.Create("DLabel", self)
self.cols[5]:SetText("Rank")
[/code]
near line 34, you are trying to set a column that doesn't exist to something.[/QUOTE]
I did that and the rank for everyone (even non-admins) is "rank". Here's a screenshot:
[IMG]http://cloud-2.steampowered.com/ugc/1099166903682501868/FF050177DBE84D7FDA42B6B80F9CD01F25B2EF1F/1024x575.resizedimage[/IMG]
It looks like everyone who joins is put in the top left corner and after the map change they spread out.
There's an error as well.
This is the code:
[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
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
if ply:IsUserGroup("Owner") then
set.cols[5]:SetText("Owner")
set.cols[5]:SetTextColor(Color(255,0,0))
elseif ply:IsUserGroup("Developer") then
set.cols[5]:SetText("Developer")
set.cols[5]:SetTextColor(Color(0,0,255))
elseif ply:IsUserGroup("admin") then
set.cols[5]:SetText("Admin")
set.cols[5]:SetTextColor(Color(255,255,0))
elseif ply:IsUserGroup("VIP") then
set.cols[5]:SetText("VIP")
set.cols[5]:SetTextColor(Color(0,255,0))
elseif ply:IsUserGroup("") then
set.cols[5]:SetText("")
set.cols[5]:SetTextColor(Color(0,0,255))
end
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
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
[QUOTE=kaos2100;38638634]Just do this
Go to your terrortown/gamemode/vgui/sb_row.lua
Add this below function PANEL:Init()
[lua] self.cols[5] = vgui.Create("DLabel", self)
self.cols[5]:SetText("Rank")[/lua]
Add this below function PANEL:UpdatePlayerData()
[lua]
if ply:IsUserGroup("superadmin") then
self.cols[5]:SetText("SUPERADMIN")
self.cols[5]:SetTextColor(Color(255,0,0,255))
end
[/lua]
Go to your terrortown/gamemode/vgui/sb_main.lua
Find under function PANEL:Init()
[lua] self.cols[3] = vgui.Create( "DLabel", self )
self.cols[3]:SetText( GetTranslation("sb_score") )[/lua]
Add this under that
[lua] self.cols[5] = vgui.Create( "DLabel", self )
self.cols[5]:SetText("Rank")[/lua]
All you really had to do is look at how the other ones were set and just follow how it's being created. :/.
Be sure to do this on the latest svn for terrortown that hasn't been edited.[/QUOTE]
also change the
[code] self.cols[5] = vgui.Create("DLabel", self)
self.cols[5]:SetText("Rank")[/code]
to[code] self.cols[5] = vgui.Create("DLabel", self)
self.cols[5]:SetText("")[/code]
[QUOTE=Pandaman09;42275681]also change the
[code] self.cols[5] = vgui.Create("DLabel", self)
self.cols[5]:SetText("Rank")[/code]
to[code] self.cols[5] = vgui.Create("DLabel", self)
self.cols[5]:SetText("")[/code][/QUOTE]
Thanks a lot for helping me out with this man. I did that but the scoreboard won't close once you hit tab and the ranks still aren't working.
Once again, this is the code in sb_row.lua:
[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("")
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
if ply:IsUserGroup("owner") then
set.cols[5]:SetText("Owner")
set.cols[5]:SetTextColor(Color(255,0,0))
elseif ply:IsUserGroup("developer") then
set.cols[5]:SetText("Developer")
set.cols[5]:SetTextColor(Color(0,0,255))
elseif ply:IsUserGroup("admin") then
set.cols[5]:SetText("Admin")
set.cols[5]:SetTextColor(Color(255,255,0))
elseif ply:IsUserGroup("vip") then
set.cols[5]:SetText("VIP")
set.cols[5]:SetTextColor(Color(0,255,0))
elseif ply:IsUserGroup("") then
set.cols[5]:SetText("")
set.cols[5]:SetTextColor(Color(0,0,255))
end
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
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.
wow derp... you have it set.cols instead of self.cols lol
[code]
if ply:IsUserGroup("Owner") then
set.cols[5]:SetText("Owner")
set.cols[5]:SetTextColor(Color(255,0,0))
elseif ply:IsUserGroup("Developer") then
set.cols[5]:SetText("Developer")
set.cols[5]:SetTextColor(Color(0,0,255))
elseif ply:IsUserGroup("admin") then
set.cols[5]:SetText("Admin")
set.cols[5]:SetTextColor(Color(255,255,0))
elseif ply:IsUserGroup("VIP") then
set.cols[5]:SetText("VIP")
set.cols[5]:SetTextColor(Color(0,255,0))
elseif ply:IsUserGroup("") then
set.cols[5]:SetText("")
set.cols[5]:SetTextColor(Color(0,0,255))
end
[/code]
should be
[code]
if ply:IsUserGroup("Owner") then
self.cols[5]:SetText("Owner")
self.cols[5]:SetTextColor(Color(255,0,0))
elseif ply:IsUserGroup("Developer") then
self.cols[5]:SetText("Developer")
self.cols[5]:SetTextColor(Color(0,0,255))
elseif ply:IsUserGroup("admin") then
self.cols[5]:SetText("Admin")
self.cols[5]:SetTextColor(Color(255,255,0))
elseif ply:IsUserGroup("VIP") then
self.cols[5]:SetText("VIP")
self.cols[5]:SetTextColor(Color(0,255,0))
elseif ply:IsUserGroup("") then
self.cols[5]:SetText("")
self.cols[5]:SetTextColor(Color(0,0,255))
end
[/code]
Don't know why I didn't realize this earlier...
Didn't know this was the spoon feeding section.
[QUOTE=Pandaman09;42276665]wow derp... you have it set.cols instead of self.cols lol
[code]
if ply:IsUserGroup("Owner") then
set.cols[5]:SetText("Owner")
set.cols[5]:SetTextColor(Color(255,0,0))
elseif ply:IsUserGroup("Developer") then
set.cols[5]:SetText("Developer")
set.cols[5]:SetTextColor(Color(0,0,255))
elseif ply:IsUserGroup("admin") then
set.cols[5]:SetText("Admin")
set.cols[5]:SetTextColor(Color(255,255,0))
elseif ply:IsUserGroup("VIP") then
set.cols[5]:SetText("VIP")
set.cols[5]:SetTextColor(Color(0,255,0))
elseif ply:IsUserGroup("") then
set.cols[5]:SetText("")
set.cols[5]:SetTextColor(Color(0,0,255))
end
[/code]
should be
[code]
if ply:IsUserGroup("Owner") then
self.cols[5]:SetText("Owner")
self.cols[5]:SetTextColor(Color(255,0,0))
elseif ply:IsUserGroup("Developer") then
self.cols[5]:SetText("Developer")
self.cols[5]:SetTextColor(Color(0,0,255))
elseif ply:IsUserGroup("admin") then
self.cols[5]:SetText("Admin")
self.cols[5]:SetTextColor(Color(255,255,0))
elseif ply:IsUserGroup("VIP") then
self.cols[5]:SetText("VIP")
self.cols[5]:SetTextColor(Color(0,255,0))
elseif ply:IsUserGroup("") then
self.cols[5]:SetText("")
self.cols[5]:SetTextColor(Color(0,0,255))
end
[/code]
Don't know why I didn't realize this earlier...[/QUOTE]
Thanks man that worked. Is there a way to move the tag one column to the left?
self.cols[6]
Sorry, you need to Log In to post a reply to this thread.