• Custom scoreboard.
    3 replies, posted
Can i please have some advice on how i would go about making a custom scoreboard and implementing it into my custom gamemode?
The way I made my scoreboard was by using garrys scoreboard code located [URL="https://github.com/garrynewman/garrysmod/blob/010ec97a994e6407fe04fdb0dea871ed2b211c5e/garrysmod/gamemodes/base/gamemode/cl_scoreboard.lua"]here[/URL] To implement it just create a new file called cl_scoreboard.lua (thats what I call it, you can name it whatever) then include it in init.lua, and cl_init.lua init.lua [code] AddCSLuaFile("cl_scoreboard.lua") [/code] cl_init.lua [code] include("cl_scoreboard.lua") [/code] If you want to create your own scoreboard, you can use the code below if you want, its just garrys code with some parts removed cl_scoreboard.lua [code] surface.CreateFont( "ScoreboardDefault", { font = "Helvetica", size = 22, weight = 800 }) surface.CreateFont( "ScoreboardDefaultTitle", { font = "Helvetica", size = 32, weight = 800 }) local PLAYER_LINE = { -- Code for the player rows, and the player functions } PLAYER_LINE = vgui.RegisterTable( PLAYER_LINE, "DPanel" ) local SCORE_BOARD = { -- Code for the actual scoreboard, you put things like the servers logo here, the background for the player rows, etc } SCORE_BOARD = vgui.RegisterTable( SCORE_BOARD, "EditablePanel" ) 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 function GM:ScoreboardHide() if ( IsValid( g_Scoreboard ) ) then g_Scoreboard:Hide() end end [/code]
[QUOTE=:0;45455098]The way I made my scoreboard was by using garrys scoreboard code located [URL="https://github.com/garrynewman/garrysmod/blob/010ec97a994e6407fe04fdb0dea871ed2b211c5e/garrysmod/gamemodes/base/gamemode/cl_scoreboard.lua"]here[/URL] To implement it just create a new file called cl_scoreboard.lua (thats what I call it, you can name it whatever) then include it in init.lua, and cl_init.lua init.lua [code] AddCSLuaFile("cl_scoreboard.lua") [/code] cl_init.lua [code] include("cl_scoreboard.lua") [/code] If you want to create your own scoreboard, you can use the code below if you want, its just garrys code with some parts removed cl_scoreboard.lua [code] surface.CreateFont( "ScoreboardDefault", { font = "Helvetica", size = 22, weight = 800 }) surface.CreateFont( "ScoreboardDefaultTitle", { font = "Helvetica", size = 32, weight = 800 }) local PLAYER_LINE = { -- Code for the player rows, and the player functions } PLAYER_LINE = vgui.RegisterTable( PLAYER_LINE, "DPanel" ) local SCORE_BOARD = { -- Code for the actual scoreboard, you put things like the servers logo here, the background for the player rows, etc } SCORE_BOARD = vgui.RegisterTable( SCORE_BOARD, "EditablePanel" ) 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 function GM:ScoreboardHide() if ( IsValid( g_Scoreboard ) ) then g_Scoreboard:Hide() end end [/code][/QUOTE] How do i add logos and backgrounds, i tried a few things but it just spat out an error [CODE] local SCORE_BOARD = { -- Line 19 -- Code for the actual scoreboard, you put things like the servers logo here, the background for the player rows, etc surface.SetDrawColor(231,76,60,255) surface.DrawRect( 500, 0, 500, 650 ) -- Line 22 }[/CODE] [ERROR] cl_scoreboard.lua:22: '}' expected (to close '{' at line 19) near 'surface' [CODE] local SCORE_BOARD = { -- Code for the actual scoreboard, you put things like the servers logo here, the background for the player rows, etc local Frame = vgui.Create( "DFrame" ) -- Line 21 Frame:SetPos(135,50 ) Frame:SetSize( 1000, 650 ) Frame:SetTitle( "" ) Frame:SetVisible( true ) Frame:SetDraggable( true ) Frame:ShowCloseButton( true ) Frame:MakePopup() Frame.Paint = function() surface.SetDrawColor(231,76,60,255) surface.DrawRect( 500, 0, 500, 650 ) surface.SetDrawColor(52,152,219,255) surface.DrawRect( 0, 0, 500, 650 ) end end }[/CODE] [ERROR] cl_scoreboard.lua:21: unexpected symbol near 'local'
[QUOTE=AGFlav;45461917]How do i add logos and backgrounds, i tried a few things but it just spat out an error [CODE] local SCORE_BOARD = { -- Line 19 -- Code for the actual scoreboard, you put things like the servers logo here, the background for the player rows, etc surface.SetDrawColor(231,76,60,255) surface.DrawRect( 500, 0, 500, 650 ) -- Line 22 }[/CODE] [ERROR] cl_scoreboard.lua:22: '}' expected (to close '{' at line 19) near 'surface' [CODE] local SCORE_BOARD = { -- Code for the actual scoreboard, you put things like the servers logo here, the background for the player rows, etc local Frame = vgui.Create( "DFrame" ) -- Line 21 Frame:SetPos(135,50 ) Frame:SetSize( 1000, 650 ) Frame:SetTitle( "" ) Frame:SetVisible( true ) Frame:SetDraggable( true ) Frame:ShowCloseButton( true ) Frame:MakePopup() Frame.Paint = function() surface.SetDrawColor(231,76,60,255) surface.DrawRect( 500, 0, 500, 650 ) surface.SetDrawColor(52,152,219,255) surface.DrawRect( 0, 0, 500, 650 ) end end }[/CODE] [ERROR] cl_scoreboard.lua:21: unexpected symbol near 'local'[/QUOTE] you haven't done the table correctly. To dd logos and pictures you can use this for an example. Or just [url]http://wiki.garrysmod.com/page/VGUI/Elements/DImage[/url] [CODE]NewImage = vgui.Create( "DImage", SOmethingToParent ) --Parent it to a panel or frame or whatever NewImage:SetPos( 50, 60 ) NewImage:SetImage( "image directory here" ) NewImage:SizeToContents() [/CODE]
Sorry, you need to Log In to post a reply to this thread.