• Scoreboard
    4 replies, posted
So I have been working on a simple scoreboard and trying to learn how to create one. I looked at another scoreboard for reference and now at this point I'm stumped. The issue I am having is that my scoreboard glitches out where the panel that's supposed to show the information of someone creates a completely separate box with the players information. Here's the full code. I also forgot to mention that I'm not receiving any errors in console either. if !CLIENT then return end local Starcross = nil StarcrossBoardBase = StarcrossBoardBase or {} surface.CreateFont( "SCTitle", { font = "Helvetica", size = 32, weight = 800, antialias = true, bold = true } ) surface.CreateFont( "SCTags", { font = "Helvetica", size = 24, weight = 800, antialias = true, bold = true } ) function StarcrossBoardBase:show() gui.EnableScreenClicker(false) local StarcrossBoardFrame = vgui.Create( 'DFrame' ) StarcrossBoardFrame:SetSize( 1000, 700 ) StarcrossBoardFrame:SetTitle( '' ) StarcrossBoardFrame:SetPos( ScrW() / 2 - 500, 100) StarcrossBoardFrame:SetDraggable( false ) StarcrossBoardFrame:SetVisible( true ) StarcrossBoardFrame:ShowCloseButton ( false ) StarcrossBoardFrame:Center() function StarcrossBoardFrame:Paint(w, h) draw.RoundedBox(5, 0, 0, w, h, Color(0, 0, 0, 255)) draw.RoundedBox(5, 5, 5, w - 10, h - 10, Color( 45, 45, 45, 255)) draw.SimpleText( "Starcross Gaming", "SCTitle", w / 2, 15, Color(255, 255, 255), TEXT_ALIGN_CENTER) draw.RoundedBox(0, 5, 50, w - 10, 25, Color(100, 100, 100, 255)) local curX = 7 draw.SimpleText( "Name", "SCTags", curX , 50, Color(255, 255, 255), TEXT_ALIGN_LEFT ) curX = curX + 390 draw.SimpleText( "Rank", "SCTags", curX, 50, Color(255, 255, 255), TEXT_ALIGN_LEFT ) curX = curX + 200 draw.SimpleText( "Kills", "SCTags", curX, 50, Color(255, 255, 255), TEXT_ALIGN_LEFT ) curX = curX + 150 draw.SimpleText( "Deaths", "SCTags", curX, 50, Color(255, 255, 255), TEXT_ALIGN_LEFT ) curX = curX + 150 draw.SimpleText( "Job", "SCTags", curX, 50, Color(255, 255, 255), TEXT_ALIGN_LEFT ) curX = curX + 120 draw.SimpleText( "Ping", "SCTags", curX, 50, Color(255, 255, 255), TEXT_ALIGN_LEFT ) curX = curX + 100 end local player_list = vgui.Create( 'DListView', frame) player_list:SetSize( 990, 630 ) player_list:SetPos(5, 115) player_list:SetMultiSelect( false ) player_list:SetDataHeight( 35 ) player_list:SetHideHeaders( true ) player_list:AddColumn( "Name" ):SetFixedWidth( 390 ) player_list:AddColumn( "Rank" ):SetFixedWidth(200 ) player_list:AddColumn( "Kills" ):SetFixedWidth( 150 ) player_list:AddColumn( "Deaths" ):SetFixedWidth( 150 ) player_list:AddColumn( "Job" ):SetFixedWidth( 120 ) player_list:AddColumn( "Ping" ):SetFixedWidth( 100 ) function player_list:Paint(w, h) draw.RoundedBox(0, 0, 0, w, h, Color( 45, 45, 45, 255)) end for k,v in pairs (player.GetAll()) do player_list:AddLine(v:Nick(), v:GetUserGroup(), v:GetNWInt("SC_KILLS"), v:Deaths(), v:Ping(), v:getDarkRPVar("job")) end timer.Create("Starcross_Scoreboard_Update", 1, 0, function() if player_list then player_list:Clear() for k,v in pairs(player.GetAll()) do player_list:AddLine(v:Nick(), v:GetUserGroup(), v:GetNWInt("SC_KILLS"), v:Deaths(), v:Ping(), v:getDarkRPVar("job")) end for k,v in pairs(player_list.Lines) do function v:Paint(w,h) draw.RoundedBox(0, 0, 0, w, h, Color( 50, 50, 50, 255)) draw.RoundedBox(0, 3.5, 3, w - 7, h - 3, Color( 90, 90, 90, 255)) end for id,pnl in pairs(v["Columns"]) do pnl:SetFont("SCTags") end end end end ) for k,v in pairs(player_list.Lines) do function v:Paint(w,h) draw.RoundedBox(0, 0, 0, w, h, Color( 50, 50, 50, 255)) draw.RoundedBox(0, 3.5, 3, w - 7, h - 3, Color( 90, 90, 90, 255)) end for id,pnl in pairs(v["Columns"]) do pnl:SetFont("SCTags") end end function StarcrossBoardBase:hide() StarcrossBoardFrame:Remove() timer.Destroy("Starcross_Scoreboard_Update") gui.EnableScreenClicker( false ) end end function SCBoardHide() StarcrossBoardFrame:SetVisible( false ) gui.EnableScreenClicker( false ) end hook.Add ( 'ScoreboardShow', 'StarcrossCreateBoard', function() StarcrossBoardBase:show() return true end) hook.Add ( 'ScoreboardHide', 'StarcrossRemoveBoard', function()  StarcrossBoardBase:hide() /*if IsValid( StarcrossBoard ) then SCBoardHide() end*/ /*return true*/ end)
Could you also provide a screenshot of the scoreboards behavior in-game?
https://files.facepunch.com/forum/upload/238876/be965b99-42e0-4b92-8a32-8a706c2f9ef5/Capture.JPG This is what's happening. Also, the box on the top left doesn't disappear but the one in the middle does.
The problem is simple local player_list = vgui.Create( 'DListView', frame) What is frame? You definitely meant StarcrossBoardFrame
Ahh okay I didn't notice that. Thanks that fixed it!
Sorry, you need to Log In to post a reply to this thread.