HelpTrouble with derma menu!

Posts 1–4 of 4 · Page 1 of 1
Trouble with derma menu!
So basically when i type derma_menu in console and submit it, the menu shows up, but when i submit derma_menu again nothing seems to happen (unless you moved the first derma menu), but when i moved the derma menu there was two of them, i tried it a third time and now there was three derma menus, i want it so that when you submit derm_menu in console it opens the derma menu and when you submit it again it closes/removes the derma menu, and when you submit it again it opens the derma menu, pretty much like a toggle.

Man thats alot of "derma menu", lol :P Thank You for your help!

Code:
local function DrawMenu()
	local frame = vgui.Create("DFrame")
	frame:SetSize(1110, 650)
	frame:Center()
	frame:SetTitle("")
	frame:MakePopup()
	frame:SetVisible(true)
	frame:ShowCloseButton(false)
	frame:SetDraggable(true)
	local button = vgui.Create("DButton", frame)
	button:SetFont('marlett')
	button:SetText('r')
	button:SetColor(Color(20, 20, 20))
	button:SetSize(15, 15)
	button:SetDrawBackground(false)
	button:SetPos(frame:GetWide() - 20, 5)
	button.DoClick = function()
		frame:Remove()
	end
end

concommand.Add("derma_menu", DrawMenu)
Make another concommand called -derma_menu and tell it to remove the frame instead of drawling it, all you're doing at this point is telling it to drawl another.
Quote Originally Posted by JayFromSubway View Post
Make another concommand called -derma_menu and tell it to remove the frame instead of drawling it, all you're doing at this point is telling it to drawl another.
How would you do that im kinda new at lua :|
maybe try this

Code:
local open = false;
local frame;

local function DrawMenu()
        open = !open
        
        if !open && frame then
             frame:Remove()
             return
        end        

	frame = vgui.Create("DFrame")
	frame:SetSize(1110, 650)
	frame:Center()
	frame:SetTitle("")
	frame:MakePopup()
	frame:SetVisible(true)
	frame:ShowCloseButton(false)
	frame:SetDraggable(true)
	local button = vgui.Create("DButton", frame)
	button:SetFont('marlett')
	button:SetText('r')
	button:SetColor(Color(20, 20, 20))
	button:SetSize(15, 15)
	button:SetDrawBackground(false)
	button:SetPos(frame:GetWide() - 20, 5)
	button.DoClick = function()
		frame:Remove()
	end
end

concommand.Add("derma_menu", DrawMenu)
Posts 1–4 of 4 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us