Andreas. Posted July 29, 2012 Author Posted July 29, 2012 nevermind, solved it but how can I check if a player has a GUI window open? like if (guiGetVisible(root)) then
Andreas. Posted July 29, 2012 Author Posted July 29, 2012 if guiGetVisible (yourgui, true) then I want to to check if a GUI window is open(all) not only a special window, get me?
Andreas. Posted July 29, 2012 Author Posted July 29, 2012 I think using "guiRoot" would work. nope, already tried wrong argument.
_Dark_ Posted July 29, 2012 Posted July 29, 2012 (edited) function isAnyGUIWindowOpen() local gui = getElementsByType('gui-window') -- get all created GUI windows for _, v in ipairs(gui) do if(guiGetVisible(v)) then return true end end return false end Edited July 29, 2012 by Guest
Anderl Posted July 29, 2012 Posted July 29, 2012 function isAnyGUIOpen() local gui = getElementsByType('gui-window') for _, v in ipairs(gui) do if(guiGetVisible(v)) then return true end end return false end You should break loop after return true, it's not necessary to continue.
Andreas. Posted July 29, 2012 Author Posted July 29, 2012 addEvent("checkIFGUIOpen", true) function checkIFGUIOpen() if (isAnyGUIOpen) then outputChatBox("GUI open") else outputChatBox("false") end end addEventHandler("checkIFGUIOpen", root, checkIFGUIOpen) function isAnyGUIOpen() local gui = getElementsByType('gui-window') for _, v in ipairs(gui) do if(guiGetVisible(v)) then return true end end return false end it outputs GUI open even thought I don't have any open, or does it count a cursor as one?
_Dark_ Posted July 29, 2012 Posted July 29, 2012 gui-window isn't an element type?? gui-window is an element.
Andreas. Posted July 29, 2012 Author Posted July 29, 2012 ok but why wont this work: addEvent("checkIFGUIOpen", true) function checkIFGUIOpen() if (isAnyGUIOpen) then outputChatBox("GUI open") else outputChatBox("false") end end addEventHandler("checkIFGUIOpen", root, checkIFGUIOpen) function isAnyGUIOpen() local gui = getElementsByType('gui-window') for _, v in ipairs(gui) do if(guiGetVisible(v)) then return true end end return false end it outputs GUI open even thought I don't have any open, or does it count a cursor as one?
_Dark_ Posted July 29, 2012 Posted July 29, 2012 ok but why wont this work: My function works fine. addEventHandler('onClientResourceStart', getResourceRootElement(), function() setTimer( function() exports.GUI:show('welcome') -- this is my function for showing GUI end, 5000, 1 ) bindKey("F1", "down", function() if(isAnyGUIOpen()) then outputChatBox("Open") else outputChatBox("Close") end end) end ) function isAnyGUIOpen() local gui = getElementsByType('gui-window') for _, v in ipairs(gui) do if(guiGetVisible(v)) then return true end end return false end I pressed F1 twice. For the first time it output close, after 5 seconds (when the GUI window appears) - Open.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now