Quick Question About VGUI

Its a simple question but what would i use to close a HTML VGUI. I was using show close button but it didnt work. Should i set visible to two different buttons? or would that be harder?

if you have your html panel like

[lua]
local pnlHTML = vgui.Create(“HTML”)
[/lua]

you should just be able to use
[lua]
pnlHTML:Remove()
[/lua]

it will remove it completely which means that if you want to use it again you will need to make a new panel.

alternatively some panels come with :Show(), :Hide() and :Close() functions (not sure which ones exactly)

well if i wanted to bind it to lets say F1 would i need to use two different functions? as in using
[lua]
function frame_open()
pnlHTML:Show()
end
hook.Add(“ShowHelp”, “myhook”, frame_open)
[/lua]

ShowHelp is F1 :L but that aside, you cannot use VGUI on the server. UI (user interface) is strictly client side.

you will need to send a usermessage to the client telling them to display the panel

something like this:

[lua]

// Server File
function GM:ShowSpare2(ply)
umsg.Start(“ShowHTML”, ply)
umsg.End() // we dont need to send anything to the client besides the request!
end

// Client File
usermessage.Hook(“ShowHTML”, function(d)
// Create/Show panel here!
pnlHTML:Show()
end)
[/lua]

I think you missed a parentthesis after “ShowHTML”, function(d) or am I wrong?

no you don’t need one until you end the function

[editline]23rd July 2012[/editline]

Alright now it comes up but it shows [lua][addons\donatehtml\lua\autorun\cl_donatepage.lua:8] attempt to call method ‘Show’ (a nil value)[/lua] Am I doing something wrong? because it comes up but i cant close it.

Is your panel local?

yeah it is i can post the code if you want :stuck_out_tongue: its not very great very simple actually

it means that :Show() is NOT a method of HTML.

you need to find a way to hide it.

my advice to to create when the usermessage is called:

[lua]
// Client File
usermessage.Hook(“ShowHTML”, function(d)
// Create/Show panel here!
pnlHTML = vgui.Create(“HTML”)
pnlHTML:SetPos() // etc
end)
[/lua]

that way you will get no errors.

also while there is active UI up function keys (f1-12) [and f13 >:D] are blocked.

Let’s just say I was tired :v: