• Creating Two Separate Derma Panels
    2 replies, posted
I need a little help with something. I'm creating two derma menus. Seems simple enough. However, if I create the second one(even if I change the bind as to what you press to open it), it just ends up replacing the old one I made. Help? Code for the first one: [CODE]local DermaButton = vgui.Create( "DButton", DermaPanel ) DermaButton:SetParent( DermaPanel ) -- Set parent to our "DermaPanel" DermaButton:SetText( "Get the Pistol" ) DermaButton:SetPos( 25, 150 ) DermaButton:SetSize( 150, 50 ) DermaButton.DoClick = function() RunConsoleCommand( "stripsecondaryweapons" ) RunConsoleCommand("get_pistol") end DermaPanel.OnClose = function() gui.EnableScreenClicker(false) end local DermaButton = vgui.Create( "DButton", DermaPanel ) DermaButton:SetParent( DermaPanel ) -- Set parent to our "DermaPanel" DermaButton:SetText( "Get the DMR" ) DermaButton:SetPos( 25, 200 ) DermaButton:SetSize( 150, 50 ) DermaButton.DoClick = function() RunConsoleCommand( "stripprimaryweapons" ) RunConsoleCommand("get_dmr") end DermaPanel.OnClose = function() gui.EnableScreenClicker(false) end local DermaButton = vgui.Create( "DButton", DermaPanel ) DermaButton:SetParent( DermaPanel ) -- Set parent to our "DermaPanel" DermaButton:SetText( "Get the Shotgun" ) DermaButton:SetPos( 25, 250 ) DermaButton:SetSize( 150, 50 ) DermaButton.DoClick = function() RunConsoleCommand("stripprimaryweapons") RunConsoleCommand("get_shotgun") end DermaPanel.OnClose = function() gui.EnableScreenClicker(false) end function GM:PlayerBindPress( ply, bind, pressed ) MsgN(bind) if LocalPlayer() then if ( string.find( bind, "menu_context" ) ) then print(pressed) if pressed then DermaPanel:Show() gui.EnableScreenClicker(true) else DermaPanel:Hide() gui.EnableScreenClicker(false) end end end end [/CODE] Now, I got rid of the second one a while ago, but how would I make a copy of this but make it not get overridden? Also, while you're at it(not very important), how do you change the colour of a menu's background? Note: I think it has something to do with teh use of LocalPlayer()? I don't know for sure.
Use different variable names, makes it easier on all levels. (So don't use "dermabutton" for 3 different buttons on this window) Also if you do <main window name>:MakePopup() on the main window you dont need gui.EnableScreenClicker()
Apparantly i cant figure out how to wrap text in code tags, so here is a hastebin to prevent spam here. What you need to do is change the function name at the top and add another concommand.Add() at the bottom to add a brand new window w/o overwriting anything. [url]http://hastebin.com/unetazirov.lua[/url]
Sorry, you need to Log In to post a reply to this thread.