Jump to content

How to make the DX panel open with a press "F?"


iiv03

Recommended Posts

local key = "f1"

function menu()
	-- dx drawing stuff
end

bindKey(key,"down",function()
	if not menuVisible then
		addEventHandler("onClientRender",getRootElement(),menu)
		-- guiCreate stuff
		menuVisible = true
	else
		removeEventHandler("onClientRender",getRootElement(),menu)
		-- destroyElement(gui element) stuff
		menuVisible = nil
	end
end)

 

Link to comment
  • Discord Moderators
local isMenuVisible = false

function menu()
	-- dx drawing stuff
end

bindKey("f1","down",function()
    isMenuVisible = not isMenuVisible -- Flip the state(if it's was true now it's false, and vice versa)
    ((isMenuVisible and addEventHandler) or (removeEventHandler))("onClientRender", root, menu)
	if menuVisible then
		--// Do some stuff here if you want
	else
		--// or here
	end
end)

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...