• How could i get my menu to work
    5 replies, posted
Hi facepunch. I made a menu and i added the command thing and a function but it didnt work so i took the fuction and command out, can you help me get my menu working [lua]function testmenu() local DermaPanel = vgui.Create( "DFrame" ) DermaPanel:SetPos( 50, 50 ) DermaPanel:SetSize( 350, 400 ) DermaPanel:SetTitle( "Testing Derma Stuff, Lol" ) DermaPanel:SetVisible( true ) DermaPanel:SetDraggable( false ) DermaPanel:ShowCloseButton( true ) DermaPanel:MakePopup() local PropertySheet = vgui.Create( "DPropertySheet" ) PropertySheet:SetParent( DermaPanel ) PropertySheet:SetPos( 5, 30 ) PropertySheet:SetSize( 340, 315 ) local Menu1 = vgui.Create( "DCheckBoxLabel" ) Menu1:SetText( "Noclip" ) Menu1:SetConVar( "sbox_noclip" ) Menu1:SetValue( 1 ) Menu1:SizeToContents() local Menu1 = vgui.Create( "DCheckBoxLabel" ) Menu1:SetText( "God Mode" ) Menu1:SetConVar( "sbox_godmode" ) Menu1:SetValue( 1 ) Menu1:SizeToContents() local Menu1 = vgui.Create( "DCheckBoxLabel" ) Menu1:SetText( "PvP Damage" ) Menu1:SetConVar( "sbox_pvpdamage" ) Menu1:SetValue( 1 ) Menu1:SizeToContents() --menu 2! local Menu2 = vgui.Create("DButton") Menu2:SetParent( DermaPanel ) Menu2:SetText( "Menu >" ) Menu2:SetPos(25, 50) Menu2:SetSize( 150, 175 ) Menu2.DoClick = function ( btn ) local Menu2 = DermaMenu() // Creates the menu Menu2:AddOption("This", function() Msg("Hello") end ) // Add options to the menu Menu2:AddOption("Is, function() Msg("How") end ) Menu2:AddOption("A, function() Msg("Are") end ) Menu2:AddOption("Testfunction() Msg("You") end ) Menu2:AddOption("Button", function() Msg("?") end ) Menu2:Open() // Open the menu AFTER adding your options end local Menu2 = vgui.Create( "DButton" ) Menu2:SetParent( DermaPanel ) // Set parent to our "DermaPanel" Menu2:SetText( "Kill yourself" ) Menu2:SetPos( 25, 50 ) Menu2:SetSize( 150, 50 ) Menu2.DoClick = function () RunConsoleCommand( "kill" ) // What happens when you press the button end PropertySheet:AddSheet( "Server Control Menu", Menu1, "gui/silkicons/user", false, false, "Control Server Client Here!" ) PropertySheet:AddSheet( "Test Menu", Menu2, "gui/silkicons/group", false, false, "I Test Stuff Here" ) end [/lua]
anyone? :confused:
Like you want a command or button to make it pop up>? [editline]11:36AM[/editline] [lua]function GM:ShowHelp(ply) if ply:isAdmin or ply:isSuperAdmin then umsg.Start("playermenu", ply) umsg.End() end end[/lua] [lua]function testmenu() local DermaPanel = vgui.Create( "DFrame" ) DermaPanel:SetPos( 50, 50 ) DermaPanel:SetSize( 350, 400 ) DermaPanel:SetTitle( "Testing Derma Stuff, Lol" ) DermaPanel:SetVisible( true ) DermaPanel:SetDraggable( false ) DermaPanel:ShowCloseButton( true ) DermaPanel:MakePopup() local PropertySheet = vgui.Create( "DPropertySheet" ) PropertySheet:SetParent( DermaPanel ) PropertySheet:SetPos( 5, 30 ) PropertySheet:SetSize( 340, 315 ) local Menu1 = vgui.Create( "DCheckBoxLabel" ) Menu1:SetText( "Noclip" ) Menu1:SetConVar( "sbox_noclip" ) Menu1:SetValue( 1 ) Menu1:SizeToContents() local Menu1 = vgui.Create( "DCheckBoxLabel" ) Menu1:SetText( "God Mode" ) Menu1:SetConVar( "sbox_godmode" ) Menu1:SetValue( 1 ) Menu1:SizeToContents() local Menu1 = vgui.Create( "DCheckBoxLabel" ) Menu1:SetText( "PvP Damage" ) Menu1:SetConVar( "sbox_pvpdamage" ) Menu1:SetValue( 1 ) Menu1:SizeToContents() --menu 2! local Menu2 = vgui.Create("DButton") Menu2:SetParent( DermaPanel ) Menu2:SetText( "Menu >" ) Menu2:SetPos(25, 50) Menu2:SetSize( 150, 175 ) Menu2.DoClick = function ( btn ) local Menu2 = DermaMenu() // Creates the menu Menu2:AddOption("This", function() Msg("Hello") end ) // Add options to the menu Menu2:AddOption("Is, function() Msg("How") end ) Menu2:AddOption("A, function() Msg("Are") end ) Menu2:AddOption("Testfunction() Msg("You") end ) Menu2:AddOption("Button", function() Msg("?") end ) Menu2:Open() // Open the menu AFTER adding your options end local Menu2 = vgui.Create( "DButton" ) Menu2:SetParent( DermaPanel ) // Set parent to our "DermaPanel" Menu2:SetText( "Kill yourself" ) Menu2:SetPos( 25, 50 ) Menu2:SetSize( 150, 50 ) Menu2.DoClick = function () RunConsoleCommand( "kill" ) // What happens when you press the button end PropertySheet:AddSheet( "Server Control Menu", Menu1, "gui/silkicons/user", false, false, "Control Server Client Here!" ) PropertySheet:AddSheet( "Test Menu", Menu2, "gui/silkicons/group", false, false, "I Test Stuff Here" ) end usermessage.Hook("playermenu", testmenu)[/lua] Like garry has said never use a command. Way easier to do it this way. Now when a player presses F1 the menu pop up.
Thanks
[lua] Menu2:AddOption("A, function() Msg("Are") end ) [/lua] I think you're missing quotes [lua] Menu2:AddOption("A", function() Msg("Are") end ) [/lua]
lol? isnt this EXACTLY the same as the guide somewhere on the forum?
Sorry, you need to Log In to post a reply to this thread.