I'm trying to make a menu open when a Player Press F4 but can't figure it out anybody could explain me?
[CODE]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 )
[/CODE]
On serverside use this hook
[URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexb26f.html"]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexb26f.html[/URL]
Inside the serverside function start a [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexa301.html"]usermessage[/URL]
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?
[CODE]function SchoolShow( ply )
umsg.Start( "my message", ply )
umsg.String( "some text" )
umsg.End()
end
hook.Add("ShowSpare2", "School", SchoolShow)
[/CODE]
And then how to receive the umsg at the client?
Sorry that I'm not getting it :(
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:
[url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexc026.html[/url]
[QUOTE=Gaming_Unlim;40755818]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][/QUOTE]
Yes that should work perfectly.
Sorry, you need to Log In to post a reply to this thread.