I'm having problems with my avatars on a scoreboard.
What happens is that when the scoreboard opens, all the avatars show normally, but when the scoreboard closes, all the avatars stick on the screen except the last one.
[lua]function GM:ScoreboardShow()
GAMEMODE.ShowScoreboard = true
gui.EnableScreenClicker( true )
Avatar()
end
function GM:ScoreboardHide()
GAMEMODE.ShowScoreboard = false
gui.EnableScreenClicker( false )
Avatar1:Remove()
end
function Avatar()
local w = 600
local h = 180 + (32 * #player.GetAll())
local x = ScrW() / 2 - w / 2
local y = ScrH() / 2 - h / 2
for k , v in pairs( player.GetAll() ) do
local tx = x + 35
local ty = y + 167 + (32 * (k - 1) )
Avatar1 = vgui.Create("AvatarImage")
Avatar1:SetPos(tx-34,ty-3)
Avatar1:SetSize(32, 32)
Avatar1:SetPlayer( v, 32 )
end
end
[/lua]
Help!
You didn't parent them to the scoreboard.
Wait, how do I parent it, because my scoreboard isn't a panel.
make your scoreboard a panel, override the Paint function and draw your scoreboard there, then parent all the avatars to the panel
heres an old scoreboard script i wrote, expect it to suck ass
[lua]surface.CreateFont("Trebuchet24", 32, 700, true, false, "scoreboardFont", true, false)
local scoreGuardTex = surface.GetTextureID("HUD/derma/scoreboard/scoreguard")
local scorePrisonerTex = surface.GetTextureID("HUD/derma/scoreboard/scoreprisoner")
local scoreboard = vgui.Create("JFrame")
scoreboard:SetSize(620, 660)
scoreboard:SetPos(ScrW() / 2 - 310, ScrH() / 2 - 330)
scoreboard:SetTitle(" ")
scoreboard:ShowCloseButton(false)
scoreboard:SetDraggable(false)
scoreboard:SetSizable(false)
scoreboard:SetVisible(false)
scoreboard.Paint = function()
draw.RoundedBox(4, 0, 0, 620, 45, Color(0, 0, 0, 200))
draw.DrawText(GetHostName(), "scoreboardFont", 310, 5, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER)
end
local panels = {}
/*========================================
Called to open the scoreboard
========================================*/
function GM:ScoreboardShow()
local line = 0
for k,v in pairs(team.GetPlayers(TEAM_GUARD)) do
if !ValidEntity(v) then return end
local panel = vgui.Create("DPanel", scoreboard)
panel:SetPos(10, 60 + 37*line)
panel:SetSize(295, 32)
panel.Paint = function()
if !ValidEntity(v) then
gamemode.Call("ScoreboardHide")
gamemode.Call("ScoreboardShow")
return
end
surface.SetTexture(scoreGuardTex)
surface.SetDrawColor(255, 255, 255, 255)
surface.DrawTexturedRect(0, 0, 295, 32)
draw.DrawText(v:Name(), "roundFont", 42, 7, Color(255, 255, 255, 255), TEXT_ALIGN_LEFT)
if !v:Alive() then
draw.RoundedBox(0, 0, 0, 295, 32, Color(0, 0, 0, 125))
end
end
table.insert(panels, panel)
local ava = vgui.Create("AvatarImage", panel)
ava:SetPos(0, 0)
ava:SetSize(32, 32)
ava:SetPlayer(v)
line = line + 1
end
local line2 = 0
for k,v in pairs(team.GetPlayers(TEAM_PRISONER)) do
if !ValidEntity(v) then return end
local panel = vgui.Create("DPanel", scoreboard)
panel:SetPos(315, 60 + 37*line2)
panel:SetSize(295, 32)
panel.Paint = function()
if !ValidEntity(v) then
gamemode.Call("ScoreboardHide")
gamemode.Call("ScoreboardShow")
return
end
surface.SetTexture(scorePrisonerTex)
surface.SetDrawColor(255, 255, 255, 255)
surface.DrawTexturedRect(0, 0, 295, 32)
draw.DrawText(v:Name(), "roundFont", 42, 7, Color(255, 255, 255, 255), TEXT_ALIGN_LEFT)
if !v:Alive() then
draw.RoundedBox(0, 0, 0, 295, 32, Color(0, 0, 0, 125))
end
end
table.insert(panels, panel)
local ava = vgui.Create("AvatarImage", panel)
ava:SetPos(0, 0)
ava:SetSize(32, 32)
ava:SetPlayer(v)
line2 = line2 + 1
end
scoreboard:SetVisible(true)
return true
end
/*========================================
Called to close the scoreboard
========================================*/
function GM:ScoreboardHide()
scoreboard:SetVisible(false)
for k,v in pairs(panels) do
v:Remove()
end
table.Empty(panels)
end[/lua]
[sp]AZN S3NS4T10N[/sp]
Sorry, you need to Log In to post a reply to this thread.