Andreas. Posted July 29, 2012 Share Posted July 29, 2012 (edited) solved Edited July 29, 2012 by Guest Link to comment
Andreas. Posted July 29, 2012 Author Share 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 Link to comment
Mega9 Posted July 29, 2012 Share Posted July 29, 2012 if guiGetVisible (yourgui, true) then Link to comment
Andreas. Posted July 29, 2012 Author Share 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? Link to comment
Anderl Posted July 29, 2012 Share Posted July 29, 2012 I think using "guiRoot" would work. Link to comment
Andreas. Posted July 29, 2012 Author Share Posted July 29, 2012 I think using "guiRoot" would work. nope, already tried wrong argument. Link to comment
_Dark_ Posted July 29, 2012 Share 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 Link to comment
Anderl Posted July 29, 2012 Share 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. Link to comment
Andreas. Posted July 29, 2012 Author Share 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? Link to comment
Andreas. Posted July 29, 2012 Author Share Posted July 29, 2012 gui-window isn't an element type?? Link to comment
_Dark_ Posted July 29, 2012 Share Posted July 29, 2012 gui-window isn't an element type?? gui-window is an element. Link to comment
Andreas. Posted July 29, 2012 Author Share 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? Link to comment
_Dark_ Posted July 29, 2012 Share 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. Link to comment
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