• Trouble With KeyPress Hook
    7 replies, posted
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 ;-;
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
[QUOTE=Moat;51544770]There's [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/OnSpawnMenuOpen]GM:OnSpawnMenuOpen[/url] and [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/OnSpawnMenuClose]GM:OnSpawnMenuClose[/url] (don't think it's called if you override the menu) if you want to bind your menu to the +menu command.[/QUOTE] This is what you want to use. Yes, they will work if you "override the menu"
[QUOTE=Moat;51544770]There's [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/OnSpawnMenuOpen]GM:OnSpawnMenuOpen[/url] and [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/OnSpawnMenuClose]GM:OnSpawnMenuClose[/url] (don't think it's called if you override the menu) if you want to bind your menu to the +menu command.[/QUOTE] It seems to not work, and there aren't any script errors in console. Any errors in my code? [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) [/code]
Ok, nevermind, problem solved, I have cl_wepmenu as a separate script, and I forgot to include it in cl_init.
Sorry, you need to Log In to post a reply to this thread.