Author Topic: Colored Scoreboard Names?  (Read 1687 times)

0 Members and 1 Guest are viewing this topic.

Offline bubblecon11

  • Newbie
  • *
  • Posts: 14
  • Karma: -1
Colored Scoreboard Names?
« on: March 25, 2013, 07:23:28 PM »
So, is there any way to make colored scoreboard names instead of the regular yellow ones?

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Colored Scoreboard Names?
« Reply #1 on: March 25, 2013, 07:53:06 PM »
Not through anything other than overriding the scoreboard. If you open the garrysmod content gcf file you can find where he has the scoreboard. Copy and paste that code into a clientside lua file and make any adjustments you want.

Below is mine. I have it show the player's group and color of group as well as some gamemode specific things. You can take a look and make adjustments as you need.

Code: [Select]
-------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------


surface.CreateFont( "ScoreboardDefault",
{
font = "Helvetica",
size = 22,
weight = 800
})

surface.CreateFont( "ScoreboardDefaultTitle",
{
font = "Helvetica",
size = 32,
weight = 800
})


--
-- This defines a new panel type for the player row. The player row is given a player
-- and then from that point on it pretty much looks after itself. It updates player info
-- in the think function, and removes itself when the player leaves the server.
--
local PLAYER_LINE =
{
Init = function( self )

self.AvatarButton = self:Add( "DButton" )
self.AvatarButton:Dock( LEFT )
self.AvatarButton:SetSize( 32, 32 )
self.AvatarButton.DoClick = function() self.Player:ShowProfile() end

self.Avatar = vgui.Create( "AvatarImage", self.AvatarButton )
self.Avatar:SetSize( 32, 32 )
self.Avatar:SetMouseInputEnabled( false )

self.Name = self:Add( "DLabel" )
self.Name:Dock( FILL )
self.Name:SetFont( "ScoreboardDefault" )
self.Name:DockMargin( 8, 0, 0, 0 )
self.Name:SetTextColor( Color( 0, 0, 0, 255 ) )

self.Mute = self:Add( "DImageButton" )
self.Mute:SetSize( 32, 32 )
self.Mute:Dock( RIGHT )
self.Mute:SetTextColor( Color( 0, 0, 0, 255 ) )

self.Ping = self:Add( "DLabel" )
self.Ping:Dock( RIGHT )
self.Ping:SetWidth( 100 )
self.Ping:SetFont( "ScoreboardDefault" )
self.Ping:SetContentAlignment( 5 )
self.Ping:SetTextColor( Color( 0, 0, 0, 255 ) )

self.slvl = self:Add( "DLabel" )
self.slvl:Dock( RIGHT )
self.slvl:SetWidth( 100 )
self.slvl:SetFont( "ScoreboardDefault" )
self.slvl:SetContentAlignment( 5 )
self.slvl:SetTextColor( Color( 0, 0, 0, 255 ) )

self.rank = self:Add( "DLabel" )
self.rank:Dock( RIGHT )
self.rank:SetWidth( 200 )
self.rank:SetFont( "ScoreboardDefault" )
self.rank:SetContentAlignment( 5 )
self.rank:SetTextColor( Color( 0, 0, 0, 255 ) )

self:Dock( TOP )
self:DockPadding( 3, 3, 3, 3 )
self:SetHeight( 32 + 3*2 )
self:DockMargin( 2, 0, 2, 2 )

end,

Setup = function( self, pl )

self.Player = pl

self.Avatar:SetPlayer( pl )
self.Name:SetText( pl:Nick() )

self:Think( self )

--local friend = self.Player:GetFriendStatus()
--MsgN( pl, " Friend: ", friend )

end,

Think = function( self )

if ( !IsValid( self.Player ) ) then
self:Remove()
return
end

if ( self.Player:GetNWString("survival") == nil ) then
self.surlvl = tostring("Level: 0")
self.slvl:SetText( self.surlvl )
else
self.surlvl = "Level: " .. self.Player:GetNWString("survival")
self.slvl:SetText( self.surlvl )
end

if ( self.NumPing == nil || self.NumPing != self.Player:Ping() ) then
self.NumPing = self.Player:Ping()
self.Ping:SetText( "Ping: " .. self.NumPing )
end

if ( self.ranktxt == nil || self.ranktxt != team.GetName( self.Player:Team() ) ) then
self.ranktxt = team.GetName( self.Player:Team() )
self.rank:SetText( self.ranktxt )
end
--
-- Change the icon of the mute button based on state
--
if ( self.Muted == nil || self.Muted != self.Player:IsMuted() ) then

self.Muted = self.Player:IsMuted()
if ( self.Muted ) then
self.Mute:SetImage( "icon32/muted.png" )
else
self.Mute:SetImage( "icon32/unmuted.png" )
end

self.Mute.DoClick = function() self.Player:SetMuted( !self.Muted ) end

end

--
-- Connecting players go at the very bottom
--
if ( self.Player:Team() == TEAM_CONNECTING ) then
self:SetZPos( 2000 )
end

--
-- This is what sorts the list. The panels are docked in the z order,
-- so if we set the z order according to kills they'll be ordered that way!
-- Careful though, it's a signed short internally, so needs to range between -32,768k and +32,767
--
--self:SetZPos( (self.NumKills * -50) + self.NumDeaths )

end,

Paint = function( self, w, h )

if ( !IsValid( self.Player ) ) then
return
end

--
-- We draw our background a different colour based on the status of the player
--

local c = team.GetColor(self.Player:Team())
draw.RoundedBox( 4, 0, 0, w, h, Color( c.r, c.g, c.b, 255 ) )

end,
}

--
-- Convert it from a normal table into a Panel Table based on DPanel
--
PLAYER_LINE = vgui.RegisterTable( PLAYER_LINE, "DPanel" );

--
-- Here we define a new panel table for the scoreboard. It basically consists
-- of a header and a scrollpanel - into which the player lines are placed.
--
local SCORE_BOARD =
{
Init = function( self )

self.Header = self:Add( "Panel" )
self.Header:Dock( TOP )
self.Header:SetHeight( 100 )

self.Name = self.Header:Add( "DLabel" )
self.Name:SetFont( "ScoreboardDefaultTitle" )
self.Name:SetTextColor( Color( 255, 255, 255, 255 ) )
self.Name:Dock( TOP )
self.Name:SetHeight( 40 )
self.Name:SetContentAlignment( 5 )
self.Name:SetExpensiveShadow( 2, Color( 0, 0, 0, 200 ) )

--self.NumPlayers = self.Header:Add( "DLabel" )
--self.NumPlayers:SetFont( "ScoreboardDefault" )
--self.NumPlayers:SetTextColor( Color( 255, 255, 255, 255 ) )
--self.NumPlayers:SetPos( 0, 100 - 30 )
--self.NumPlayers:SetSize( 300, 30 )
--self.NumPlayers:SetContentAlignment( 4 )

self.Scores = self:Add( "DScrollPanel" )
self.Scores:Dock( FILL )

end,

PerformLayout = function( self )

self:SetSize( 700, ScrH() - 200 )
self:SetPos( ScrW() / 2 - 350, 100 )

end,

Paint = function( self, w, h )

--draw.RoundedBox( 4, 0, 0, w, h, Color( 0, 0, 0, 200 ) )

end,

Think = function( self, w, h )

self.Name:SetText( GetHostName() )

--
-- Loop through each player, and if one doesn't have a score entry - create it.
--
local plyrs = player.GetAll()
for id, pl in pairs( plyrs ) do

if ( IsValid( pl.ScoreEntry ) ) then continue end

pl.ScoreEntry = vgui.CreateFromTable( PLAYER_LINE, pl.ScoreEntry )
pl.ScoreEntry:Setup( pl )

self.Scores:AddItem( pl.ScoreEntry )

end

end,
}

SCORE_BOARD = vgui.RegisterTable( SCORE_BOARD, "EditablePanel" );

--[[---------------------------------------------------------
   Name: gamemode:ScoreboardShow( )
   Desc: Sets the scoreboard to visible
-----------------------------------------------------------]]
function GM:ScoreboardShow()

if ( !IsValid( g_Scoreboard ) ) then
g_Scoreboard = vgui.CreateFromTable( SCORE_BOARD )
end

if ( IsValid( g_Scoreboard ) ) then
g_Scoreboard:Show()
g_Scoreboard:MakePopup()
g_Scoreboard:SetKeyboardInputEnabled( false )
end

end

--[[---------------------------------------------------------
   Name: gamemode:ScoreboardHide( )
   Desc: Hides the scoreboard
-----------------------------------------------------------]]
function GM:ScoreboardHide()

if ( IsValid( g_Scoreboard ) ) then
g_Scoreboard:Hide()
end

end


--[[---------------------------------------------------------
   Name: gamemode:HUDDrawScoreBoard( )
   Desc: If you prefer to draw your scoreboard the stupid way (without vgui)
-----------------------------------------------------------]]
function GM:HUDDrawScoreBoard()

end

matproxy.Add(
{
name = "PlayerToolColor",

init = function( self, mat, values )

self.ResultTo = values.resultvar

end,

bind = function( self, mat, ent )

if ( !IsValid( ent ) ) then return end

local owner = ent:GetOwner();
if ( !IsValid( owner ) ) then return end

local col = owner:GetWeaponColor();

mat:SetVector( self.ResultTo, col );

end
})
« Last Edit: March 25, 2013, 07:54:59 PM by MrPresident »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Colored Scoreboard Names?
« Reply #2 on: March 25, 2013, 08:02:58 PM »
Does our XGUI Uteam group/team color tie-in not affect the scoreboard anymore?
Shame.
I so hate the bright whiteness of everything Garry has done with the Gui in gm13.
I spend 20seconds with a magnifier reading what props/menu items I want to use.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming