Show DermaPanel on KeyPressed.

I’m trying to make a menu open when a Player Press F4 but can’t figure it out anybody could explain me?


function KeyPressed (P, KEY_F4 )

	
	local DermaPanel = vgui.Create( "DFrame" ) -- Creates the frame itself
	DermaPanel:SetPos( 50,50 ) -- Position on the players screen
	DermaPanel:SetSize( 1000, 900 ) -- Size of the frame
	DermaPanel:SetTitle( "Testing Derma Stuff" ) -- Title of the frame
	DermaPanel:SetVisible( true )
	DermaPanel:SetDraggable( true ) -- Draggable by mouse?
	DermaPanel:ShowCloseButton( true ) -- Show the close button?
	DermaPanel:MakePopup() -- Show the frame

end
hook.Add( "KeyPress", "KeyPressedHook", KeyPressed )


On serverside use this hook
http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexb26f.html

Inside the serverside function start a usermessage

And then on the client receive the usermessage which will open your derma

So I should add the Schoolshow function in the init.lua (serversided) and put the Usermessage inside it?


function SchoolShow( ply )
		umsg.Start( "my message", ply )
    	umsg.String( "some text" )
		umsg.End()
end
hook.Add("ShowSpare2", "School", SchoolShow)


And then how to receive the umsg at the client?
Sorry that I’m not getting it :frowning:

usermessage.Hook(“OpenIt”,function name)

Here is what it should look like
[lua]
–CLIENSIDE
function DrawMenu()

local DermaPanel = vgui.Create( "DFrame" ) -- Creates the frame itself
DermaPanel:SetPos( 50,50 ) -- Position on the players screen
DermaPanel:SetSize( 1000, 900 ) -- Size of the frame
DermaPanel:SetTitle( "Testing Derma Stuff" ) -- Title of the frame
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( true ) -- Draggable by mouse?
DermaPanel:ShowCloseButton( true ) -- Show the close button?
DermaPanel:MakePopup() -- Show the frame

end
usermessage.Hook(“my_menu”, DrawMenu)

–SERVERSIDE
function SchoolShow( ply )
umsg.Start( “my_menu”, ply ) --(the message name in the hook, the person you are calling it on)
–There is no need to send a string to the client as you just want to run a function on it
umsg.End()
end
hook.Add(“ShowSpare2”, “School”, SchoolShow)
[/lua]

I think this should help you:

Yes that should work perfectly.