Base Scoreboard

Hi Facepunchers!

I want to somehow block garry’s scoreboard, so I get the base scoreboard, any ideas on how to? Or how to create your own scoreboard?

  • Oli

Hi The0liver!

I want to know if we’re talking about sandbox here, so I can help you better. You can create your own scoreboard by returning true in this hook.

If you want to use the base scoreboard in your gamemode, copy the cl_scoreboard.lua file from base and send it to clients serverside/include it clientside.

20 Smartness, doesnt work.

Overv, I want to use the scoreboard they use in the base gamemode, not in sandbox.

copy paste from base gamemode and do what overv said.

=) Now it doesnt show anything.

Ive started coding my own one, but why doesnt this work?

[lua]
function teamInfo(index)
tInfo = { [“teamColor”] = team.GetColor(index), [“teamName”] = team.GetName(index), [“teamScore”] = team.GetScore(index), [“teamFrags”] = team.TotalFrags(index)}
return tInfo
end

function drawScoreBoard()
local allTeams = { }
local scoreboardWidth = ScrW() / 1.4
local scoreboardHeight = ScrH() / 0.6

draw.RoundedBox( 6, ScrW() - scoreboardWidth / 2, ScrH() - scoreboardHeight / 2, scoreboardWidth, scoreboardHeight, Color( 255, 255, 255, 150 ) )

for k, v in pairs(team.GetAllTeams()) do
	allTeams[k] = teamInfo(k)
end

local teamPosY = 0
local teamPosX = 10
local teamBoxWidth = scoreboardWidth - 40
local teamBoxHeight = 20

for k, v in pairs(allTeams) do
	-- Something!
	draw.RoundedBox( 6, ScrW() - scoreboardWidth / 2 + teamPosX, ScrH() - scoreboardHeight / 2 + teamPosY, teamBoxWidth, teamBoxHeight, v["teamColor"] )
	
	local plyPosY = 0
	local plyPlosX = 20
	local plyBoxHeight = 20
	local plyBoxWidth = teamBoxWidth / 0.4
	
	for key, ply in pairs(team.GetPlayers(k)) do
		-- Something!
		-- Draw a player box with name, team color, frags etc..
		plyPosY = plyPosY + 5 + plyBoxHeight
	end
end

end

function GM:HUDDrawScoreBoard()
return false
end

function GM:ScoreboardShow()
drawScoreBoard()
return true
end
[/lua]

It if I remove the GM:ScoreboardShow, it always shows the scoreboard on the right side, but if I put it there, it wont even show the scoreboard.

Help anybody.

ScoreboardShow is only called once when you press the button. So you need a switch.

[lua]

local shoulddraw = false;

function teamInfo(index)
tInfo = { [“teamColor”] = team.GetColor(index), [“teamName”] = team.GetName(index), [“teamScore”] = team.GetScore(index), [“teamFrags”] = team.TotalFrags(index)}
return tInfo
end

local function drawScoreBoard()
if (!shoulddraw) then return end
local allTeams = { }
local scoreboardWidth = ScrW() / 1.4
local scoreboardHeight = ScrH() / 0.6

draw.RoundedBox( 6, ScrW() - scoreboardWidth / 2, ScrH() - scoreboardHeight / 2, scoreboardWidth, scoreboardHeight, Color( 255, 255, 255, 150 ) )

for k, v in pairs(team.GetAllTeams()) do
	allTeams[k] = teamInfo(k)
end

local teamPosY = 0
local teamPosX = 10
local teamBoxWidth = scoreboardWidth - 40
local teamBoxHeight = 20

for k, v in pairs(allTeams) do
	-- Something!
	draw.RoundedBox( 6, ScrW() - scoreboardWidth / 2 + teamPosX, ScrH() - scoreboardHeight / 2 + teamPosY, teamBoxWidth, teamBoxHeight, v["teamColor"] )
	
	local plyPosY = 0
	local plyPlosX = 20
	local plyBoxHeight = 20
	local plyBoxWidth = teamBoxWidth / 0.4
	
	for key, ply in pairs(team.GetPlayers(k)) do
		-- Something!
		-- Draw a player box with name, team color, frags etc..
		plyPosY = plyPosY + 5 + plyBoxHeight
	end
end

end
hook.Add(“HUDPaint”, “DrawScoreboard”, drawScoreBoard);

function GM:HUDDrawScoreBoard()
shoulddraw = false;
return false
end

function GM:ScoreboardShow()
shoulddraw = true;
return true
end
[/lua]

It kinda works, but now it shows up for like a second, and then it disappears.

Sorry, I read those hooks wrong.

Replace:
[lua]function GM:HUDDrawScoreBoard()
shoulddraw = false;
return false;
end[/lua]

with:
[lua]function GM:ScoreboardHide()
shoulddraw = false;
end[/lua]

Thanks, that worked!