Can't get scoreboard derma image to go away...

I’m trying to make a derma image panel appear when tab is held down. But when I let go of the key, the Dimage panel (with an X) is still there. Is there a way to get this to go away, or a work around? Is there like a kill dimage panel command that I can link to the press of another button?

EDIT: FYI an error in console appears

Warning: vgui.Create failed to create the VGUI component (quickreference)

[ERROR] gamemodes/mygamemode/gamemode/shared.lua:34: attempt to index field ‘scoreboard’ (a nil value)

  1. unknown - gamemodes/mygamemode/gamemode/shared.lua:34

Warning: vgui.Create failed to create the VGUI component (quickreference)

Post your code

Do you use the ScoreboardShow hook to show it? If yes, you need to use :Remove() inside the ScoreboardHide hook.

Sure thing:



				// command to start scoreboard quick reference
										if !DermaShown then
function GM:ScoreboardShow()
	if ( !IsValid(self.scoreboard) ) then
		self.scoreboard = vgui.Create("quickreference")
		Frame = vgui.Create( "DFrame" )
		Frame:SetSize( 2000, 2000 )
		Frame:Center()
		Frame:SetTitle( "Command Board" )	-- Title of window
		local score1 = vgui.Create( "DImage", Frame )	-- Add image to Frame
score1:SetPos( 10, 35 )	-- Move it into frame
score1:SetSize( 150, 150 )
	
	
-- Set material relative to "garrysmod/materials/"
score1:SetImage( "image1.jpg" )
	end

	self.scoreboard:Show("quickreference")
end
   DermaShown = true
end	


function GM:ScoreboardHide()
	if ( IsValid(self.scoreboard) ) then
		self.scoreboard:Hide()
	end
end

The image displays although I need to tweak the size a great deal.

Create the image outside of the hook, (inside a custom function) and create a hide function inside it, which removes it, and scoreboardshow uses main function, hide uses the hide function.

I need a little help with the hide function


self.scoreboard = vgui.Create("quickreference")
		Frame = vgui.Create( "DFrame" )
		Frame:SetSize( 2000, 2000 )
		Frame:Center()
		Frame:SetTitle( "Command Board" )	-- Title of window
		local score1 = vgui.Create( "DImage", Frame )	-- Add image to Frame
score1:SetPos( 10, 35 )	-- Move it into frame
score1:SetSize( 150, 150 )
	
	
-- Set material relative to "garrysmod/materials/"
score1:SetImage( "image1.jpg" )
	end



function GM:ScoreboardHide()
	if ( IsValid(self.scoreboard) ) then
		self.scoreboard:Hide()
	end
end


You can see the hide function is outside of the image function but if I put it in, what triggers it?

What is “self”, and are you sure theres such an panel called “quickreference”? - did you create it properly?

[editline]18th August 2015[/editline]

also, heres an skeleton code you could use, its the same one that Niandras sidemenu, and some of my scripts use:



local scoreimage = scoreimage or {}
function scoreimage:show()
	local frame = vgui.Create("DFrame")
	--setpos
	--setsize
	function scoreimage:hide()
		frame:SetVisible(false)
	end
end

hook.Add("ScoreboardShow", "yourstring", function()
	scoreimage:show()
end)

hook.Add("ScoreboardHide", "yourstring2", function()
	scoreimage:hide()
end)


[editline]18th August 2015[/editline]

basically, the Hide function will be available, as soon as the show function is ran, so it gives no errors.

[editline]18th August 2015[/editline]

Hello Niandra (/^-^)/

Trying to flesh out…what am I putting in yourstring… right now nothing happens even though I set the positions/size of the frame…here is what I have. I guess I need to learn more about the process


local scoreimage = scoreimage or {}
function scoreimage:show()
	local frame = vgui.Create("DFrame")
	--setpos
	DFrame:SetPos( 10, 30 )
	DFrame:SetSize( 200,200 )
	function scoreimage:hide()
		frame:SetVisible(false)
	end
end

hook.Add("ScoreboardShow", "yourstring", function()
	scoreimage:show()
end)

hook.Add("ScoreboardHide", "yourstring2", function()
	scoreimage:hide()
end)


No wonder why it aint working, please learn how to use GLua/VGUI before coding… its obvious you dont put “DFrame:SetPos” but “frame:SetPos” and same with SetSize, and it doesnt matter what you put as “yourstring” since its only an identifier - another reason why you should learn before doing.

Thanks, I wasn’t sure about DFrame or frame. I actually put “frame:SetPos” but another error masked this so I assumed I had done it wrong. Thank you for helping me learn.