Open Menu With Q

How can you make a custom menu when you hold down Q?

I got rid of deprive gamemode Sandbox.

bind q (concomand for opening your menu)

I thought there was a certain command for it.

Thats some nice lua
**[Gamemode.OnSpawnMenuOpen

http://wiki.garrysmod.com/favicon.ico](wiki.garrysmod.com/?title=Gamemode.OnSpawnMenuOpen)**
Use that

Thanks. Thats better.

[editline]09:43PM[/editline]

How do you make it stay open while your holding down q?

in the console its BindToggle

Or in your OnSpawnMenu function you can just alter between SetVisible(true) and SetVisible(false).

Or you can make a concommand called +menu.

If you mean you want it to only stay visible while Q is down simply show it with **[Gamemode.OnSpawnMenuOpen

http://wiki.garrysmod.com/favicon.ico](wiki.garrysmod.com/?title=Gamemode.OnSpawnMenuOpen)** and hide it with **[Gamemode.OnSpawnMenuClose

http://wiki.garrysmod.com/favicon.ico](wiki.garrysmod.com/?title=Gamemode.OnSpawnMenuClose)**.

Or you can make a concommand called +menu to open it and -menu to close it.

But then you have to tell your clients to bind a key to it.

But their q button is already bound to +menu.

Or am I missing something?

No, it’s probably me. Haven’t played Garry’s Mod in months. :smile:

It’s much better to just do what Quebec said.
You don’t need to do anything with key binds.

What yakahughes is saying is that Q by default is already bound to +menu.

Edit*Heres an example.



local toggle =0

  function togglespawn()
toggle=toggle+1
if toggle==2 then
toggle=-2
return false
end
else
toggle=1
end

  hook.Add("OnSpawnMenuClose", "togglespawn", togglespawn)
hook.Add("OnSpawnMenuOpen", "togglespawn2", togglespawn)


This might help

[lua]
function GM:OnSpawnMenuOpen()
your custom spawnmenu
end

function GM:OnSpawnMenuClose()
spawnmenu:SetVisible(false)
spawnmenu:SetVisible(true)
spawnmenu:SetVisible(false)
– we’re setting it to close and open like that to make sure all tooltips are removed
end
[/lua]