1. Post #1
    Shifty50's Avatar
    January 2006
    36 Posts
    Straight to the point. How would i create a spawnmenu that comes up when i push Q. I have no idea how to start and have messed around with functions such as GM:OnSpawnMenuOpen() but still cannot figure out how it is done. Any help will be much appreciated.

    I did search for this but couldn't find a thread that was quite what i wanted.

  2. Post #2
    Gold Member
    Kalik 911's Avatar
    September 2006
    180 Posts
    Are you willing to have it derived from sandbox? (So you basically have the basic sandbox menu and some of it's features), but you could always change it.
    Reply With Quote Edit / Delete Reply United States Show Events Zing Zing x 1 (list)

  3. Post #3
    meka/sniper's Avatar
    July 2009
    102 Posts
    You would have to use derma to make the spawn list, then to get the derma to pop up on Q you would have to add the commands:
    concommand.Add( "+menu", <function name here> ) -- this will open the menu when we hit q.
    concommand.Add( "-menu", function()   <derma name here>:Close() end ) -- this will close the menu when we let go of q.
    

  4. Post #4
    Gold Member
    Robert64's Avatar
    November 2007
    1,326 Posts
    In my gamemode I have a custom Q menu. I think I used the hook you mentioned in the OP which I hooked client-side. Sadly I'm going away for a week from today so I can't check

  5. Post #5
    Shifty50's Avatar
    January 2006
    36 Posts
    You would have to use derma to make the spawn list, then to get the derma to pop up on Q you would have to add the commands:
    concommand.Add( "+menu", <function name here> ) -- this will open the menu when we hit q.
    concommand.Add( "-menu", function()   <derma name here>:Close() end ) -- this will close the menu when we let go of q.
    
    When you say function name, you mean say, function Spawnmenu, then the derma inside it? And the derma name is just something like: Name = vgui.Create( "DFrame" ), so the derma name is Name. I hope that made sense. Then i take it that, that code goes in init.lua and the function goes inside cl_init.lua , i know it's pretty nooby but this is newby questions right :)

    Edit.

    I put that code in my gamemode and I get: Unknown Command: '+menu' and Unknown Command: '-menu' which i don't understand because isn't that what concommand.Add( "+menu", does?. Help please

  6. Post #6
    SeveredSkull's Avatar
    October 2008
    1,316 Posts
    its giving you an error because you are creating a clientside command on the server.

    All the code goes into cl_init.lua because it is meant to be executed by the CLIENT and not the SERVER.
    Once you put the entire code that has to relate to the menu into the client, try testing it again and letting us know what the result is.

  7. Post #7
    Shifty50's Avatar
    January 2006
    36 Posts
    its giving you an error because you are creating a clientside command on the server.

    All the code goes into cl_init.lua because it is meant to be executed by the CLIENT and not the SERVER.
    Once you put the entire code that has to relate to the menu into the client, try testing it again and letting us know what the result is.
    I did put the code in cl_init.lua and that was the result. Maybe i should have said that. My bad.

    Edit.

    Will not having derived the gamemode from sandbox have anything to do with this? I want to try not to derive my gamemode from sandbox if possible.

  8. Post #8
    SeveredSkull's Avatar
    October 2008
    1,316 Posts
    no it should not. Whats the name of your function? I'm pretty sure it has to be "menu" for it to work.

  9. Post #9
    Shifty50's Avatar
    January 2006
    36 Posts
    I changed the function name to menu and it worked. Thanks for all the help. Sorry for not responding in a long time, i was on holiday :)