Trouble With KeyPress Hook

I’m trying to create a gamemode, and I’m trying to open up a menu with a derma panel once a person presses “Q,” or whatever key is bound to “+menu.” However, there’s no IN Enums for +menu or +menu_context, and when I tried using a regular Enum like “IN_USE” it didn’t work, and even trying both of the examples on the wiki didn’t work. Please help ;-;

There’s

GM:OnSpawnMenuOpen and

GM:OnSpawnMenuClose (don’t think it’s called if you override the menu) if you want to bind your menu to the +menu command.

if nothing else works, does gmod let clientside code read from the clientside config folder?

if it does, you can search through the files in there to determine the bound key and combine KeyPress with KeyRelease to perform your special action for that key

This is what you want to use. Yes, they will work if you “override the menu”

Ah, good to know. Wasn’t quite sure since the description of the closed hook implied it was called only when the actual spawn menu closes.

I’ve went ahead and revised the description in hopes to make it more clear the next time someone takes a look at it.

It seems to not work, and there aren’t any script errors in console. Any errors in my code?



hook.Add("OnSpawnMenuOpen","OpenWepMenu", function()

wm = vgui.Create("DFrame")
vm:SetSize(800,800)
vm:SetPos(ScrW()/2-800,ScrH()/2-800)
vm:SetTitle("")
vm:MakePopup(true)
vm.Paint = function()

draw.RoundedBox(2,0,50,800,750,Color(90,90,90,230))
draw.RoundedBox(2,0,0,800,50,Color(51,51,51,230))

end

end)

hook.Add("OnSpawnMenuClose","CloseWepMenu", function()

wm:Close()

end)



You seem to switch from “wm” to “vm” when you’re defining the DFrame. Also, it’d be best to localize the variable for the frame before the hook.

Make sure you’re running the code clientside.

Ok, nevermind, problem solved, I have cl_wepmenu as a separate script, and I forgot to include it in cl_init.