Advertisement
Guest User

cl_scoreboard_frame_2

a guest
Oct 19th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.16 KB | None | 0 0
  1. --[[---------------------------------------------------------
  2.     Name: Variables
  3. -----------------------------------------------------------]]
  4. local PANEL = {}
  5.  
  6.  
  7. --[[---------------------------------------------------------
  8.     Name: Init
  9. -----------------------------------------------------------]]
  10. function PANEL:Init()
  11.  
  12.     --> Variables
  13.     local GroupModerator    = { "superadmin", "admin", "moderator" }
  14.  
  15.     --> Menu - Size
  16.     local MenuWidth     = ScrW() - 200
  17.     local MenuHeight    = ScrH() - 200
  18.  
  19.     if MenuWidth    > 950 then MenuWidth  = 950 end
  20.  
  21.     --> Menu - Create
  22.     self:SetSize( MenuWidth, MenuHeight )
  23.     self:SetPos( ScrW()/2 - self:GetWide()/2, ScrH() )
  24.     self:MoveTo( ScrW()/2 - self:GetWide()/2, ScrH()/2 - self:GetTall()/2, 0.2, 0 )
  25.  
  26.     --> Inside Box
  27.     self.InsideBox = vgui.Create( "DPanel", self )
  28.     self.InsideBox.Paint = function( pnl, w, h )
  29.  
  30.         --> Background
  31.         draw.RoundedBox( 0, 0, 0, w, h, Color( 240, 240, 240, 255 ) )
  32.  
  33.     end
  34.  
  35.     --> Players Box
  36.     self.Players = vgui.Create( "FG-DScrollPanel", self.InsideBox )
  37.     self.Players:Dock( FILL )
  38.  
  39.     --> Admin Box
  40.     self.Admins = vgui.Create( "DPanel", self.InsideBox )
  41.     self.Admins:Dock( BOTTOM )
  42.     self.Admins:SetHeight( 30 )
  43.     self.Admins:DockPadding( 4, 4, 4, 4 )
  44.     self.Admins.Paint = function( pnl, w, h )
  45.  
  46.         draw.RoundedBox( 0, 0, 0, w, h, Color( 230, 230, 230, 255 ) )
  47.         draw.RoundedBox( 0, 0, 0, w, 1, Color( 215, 215, 215, 255 ) )
  48.  
  49.         draw.DrawText( "Players: " .. #player.GetAll() .. "/" .. game.MaxPlayers() .. ".   Map: " .. game.GetMap(), "FG_JaapokkiRegular_22", 6, 7, Color( 100, 100, 100, 255 ), 0, 1 )
  50.  
  51.     end
  52.  
  53.     self.AdminP = vgui.Create( "FG-DButton", self.Admins )
  54.     self.AdminP:Dock( RIGHT )
  55.     self.AdminP:SetWidth( 120 )
  56.     self.AdminP:SetText( "Admin Actions" )
  57.     self.AdminP.Toffset = 2
  58.  
  59.     if table.HasValue( GroupModerator, LocalPlayer():GetNWString( "usergroup" ) ) then
  60.         self.AdminP.ButtonColor = Color( 52, 152, 219, 255 )
  61.     else
  62.         self.AdminP.ButtonColor = Color( 150, 150, 150, 255 )
  63.     end
  64.    
  65.     self.AdminP.DoClick = function()
  66.         if table.HasValue( GroupModerator, LocalPlayer():GetNWString( "usergroup" ) ) then
  67.  
  68.             AdminMenu = DermaMenu( self.AdminP )
  69.             AdminMenu.Think = function()
  70.                 if not AdminMenu:GetParent():IsVisible() then
  71.                     AdminMenu:Remove()
  72.                 end
  73.             end
  74.  
  75.             AdminMenu:AddOption( "Clear Decals", function() RunConsoleCommand( "_FAdmin", "ClearDecals" ) end ):SetIcon( "icon16/picture_delete.png" )
  76.             AdminMenu:AddOption( "Stop Sounds", function() RunConsoleCommand( "_FAdmin", "StopSounds" ) end ):SetIcon( "icon16/sound_delete.png" )
  77.            
  78.             AdminMenu:AddSpacer()
  79.  
  80.             AdminMenu:AddOption( "Disconnected Props", function() RunConsoleCommand( "FPP_Cleanup", "disconnected" ) end ):SetIcon( "icon16/box.png" )
  81.  
  82.             AdminMenu:Open()
  83.  
  84.         end
  85.     end
  86.  
  87.     --> Header
  88.     self.Header = vgui.Create( "Panel", self )
  89.     self.Header:Dock( TOP )
  90.     self.Header:SetHeight( 40 )
  91.  
  92.     --> Server Name
  93.     self.Name = self.Header:Add( "DLabel" )
  94.     self.Name:SetFont( "FG_JaapokkiRegular_32" )
  95.     self.Name:SetTextColor( Color( 255, 255, 255, 255 ) )
  96.     self.Name:Dock( TOP )
  97.     self.Name:SetHeight( 46 )
  98.     self.Name:SetContentAlignment( 5 )
  99.     self.Name:SetExpensiveShadow( 2, Color( 0, 0, 0, 200 ) )
  100.  
  101. end
  102.  
  103.  
  104. --[[---------------------------------------------------------
  105.     Name: Paint
  106. -----------------------------------------------------------]]
  107. function PANEL:Paint( w, h )
  108.  
  109.     --> Background
  110.     draw.RoundedBox( 0, 0, 0, w, h, Color( 240, 240, 240, 255 ) )
  111.  
  112.     --> Title
  113.     draw.RoundedBox( 0, 0, 0, w, 40, Color( 40, 40, 50, 255 ) )
  114.  
  115.     --> Inside Border
  116.     draw.RoundedBox( 0, 19, 40 + 19, w - 19 * 2, h - 40 - 19 * 2, Color( 215, 215, 215, 255 ) )
  117.  
  118.     --> Inside Box
  119.     self.InsideBox:SetSize( w - 20 * 2, h - 40 - 20 * 2 )
  120.     self.InsideBox:SetPos( 20, 40 + 20 )
  121.  
  122. end
  123.  
  124.  
  125. --[[---------------------------------------------------------
  126.     Name: Think
  127. -----------------------------------------------------------]]
  128. function PANEL:Think()
  129.  
  130.     --> Variables
  131.     self.PlayerList = {}
  132.  
  133.     --> Server Name
  134.     self.Name:SetText( GetHostName() )
  135.  
  136.     --> Team Info
  137.     if !ValidPanel( self.TeamInfo ) then
  138.        
  139.         --> Team Info
  140.         self.TeamInfo = self.Players:Add( "DPanel" )
  141.         self.TeamInfo:Dock( TOP )
  142.         self.TeamInfo:SetHeight( 30 )
  143.         self.TeamInfo:SetContentAlignment( 5 )
  144.         self.TeamInfo.Paint = function( pnl, w, h )
  145.  
  146.             draw.RoundedBox( 0, 0, 0, w, h, Color( 240, 240, 240, 255 ) )
  147.  
  148.             draw.RoundedBox( 0, 0, h-1, w, 1, Color( 200, 200, 200, 255 ) )
  149.  
  150.         end
  151.  
  152.         --> Information
  153.         local TeamAvatar = self.TeamInfo:Add( "DLabel" )
  154.         TeamAvatar:Dock( LEFT )
  155.         TeamAvatar:SetWidth( 42 )
  156.         TeamAvatar:SetFont( "FG_JaapokkiRegular_20" )
  157.         TeamAvatar:SetTextColor( Color( 100, 100, 100, 255 ) )
  158.         TeamAvatar:SetText( "-" )
  159.         TeamAvatar:SetContentAlignment( 5 )
  160.  
  161.         local TeamName = self.TeamInfo:Add( "DLabel" )
  162.         TeamName:Dock( LEFT )
  163.         TeamName:SetFont( "FG_JaapokkiRegular_20" )
  164.         TeamName:SetTextColor( Color( 100, 100, 100, 255 ) )
  165.         TeamName:SetText( "Name" )
  166.         TeamName:SetContentAlignment( 5 )
  167.  
  168.         local TeamPing = self.TeamInfo:Add( "DLabel" )
  169.         TeamPing:Dock( RIGHT )
  170.         TeamPing:SetWidth( 60 )
  171.         TeamPing:SetFont( "FG_JaapokkiRegular_20" )
  172.         TeamPing:SetTextColor( Color( 100, 100, 100, 255 ) )
  173.         TeamPing:SetText( "Ping" )
  174.         TeamPing:SetContentAlignment( 5 )
  175.  
  176.         local TeamDeaths = self.TeamInfo:Add( "DLabel" )
  177.         TeamDeaths:Dock( RIGHT )
  178.         TeamDeaths:SetWidth( 60 )
  179.         TeamDeaths:SetFont( "FG_JaapokkiRegular_20" )
  180.         TeamDeaths:SetTextColor( Color( 100, 100, 100, 255 ) )
  181.         TeamDeaths:SetText( "Deaths" )
  182.         TeamDeaths:SetContentAlignment( 5 )
  183.  
  184.         local TeamKills = self.TeamInfo:Add( "DLabel" )
  185.         TeamKills:Dock( RIGHT )
  186.         TeamKills:SetWidth( 60 )
  187.         TeamKills:SetFont( "FG_JaapokkiRegular_20" )
  188.         TeamKills:SetTextColor( Color( 100, 100, 100, 255 ) )
  189.         TeamKills:SetText( "Kills" )
  190.         TeamKills:SetContentAlignment( 5 )
  191.  
  192.     end
  193.  
  194.     --> Loop Players
  195.     for id, ply in pairs( player.GetAll() ) do
  196.  
  197.         --> Check Player
  198.         if not IsValid( ply ) or not ply:IsPlayer() then return end
  199.  
  200.         --> Check Entry
  201.         if IsValid( ply.ScoreEntry ) and ply.ScoreEntry.Team == ply:Team() then continue end
  202.  
  203.         --> Team
  204.         if not self.PlayerList[ ply:Team() ] then
  205.  
  206.             self.PlayerList[ ply:Team() ] = {}
  207.  
  208.         end
  209.            
  210.         --> Insert
  211.         table.insert( self.PlayerList[ ply:Team() ], ply )
  212.  
  213.     end
  214.  
  215.     --> Loop Teams
  216.     for id, job in pairs( self.PlayerList ) do
  217.  
  218.         --> Team Display
  219.         local TeamPanel = self.Players:Add( "DPanel" )
  220.         TeamPanel:Dock( TOP )
  221.         TeamPanel:SetHeight( 30 )
  222.         TeamPanel.Think = function()
  223.             if team.GetPlayers( id ) == 0 then
  224.                 TeamPanel:Remove()
  225.             end
  226.         end
  227.         TeamPanel.Paint = function( pnl, w, h )
  228.  
  229.             draw.RoundedBox( 0, 0, 0, w, h, team.GetColor( id ) )
  230.  
  231.             draw.DrawText( team.GetName( id ), "FG_JaapokkiRegular_22", 10, 6, Color( 255, 255, 255, 255 ) )
  232.  
  233.         end
  234.  
  235.         --> Players
  236.         for k,v in pairs( job ) do
  237.            
  238.             --> Create
  239.             v.ScoreEntry = vgui.Create( "FG-Scoreboard-Player" )
  240.             v.ScoreEntry:Setup( v )
  241.  
  242.             --> Add
  243.             self.Players:AddItem( v.ScoreEntry )
  244.  
  245.         end
  246.  
  247.     end
  248.  
  249. end
  250.  
  251.  
  252. --[[---------------------------------------------------------
  253.     Name: DefineControl
  254. -----------------------------------------------------------]]
  255. derma.DefineControl( "FG-Scoreboard", "FG-Scoreboard", PANEL, "EditablePanel" )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement