Jump to content

output playername on click


Andreas.

Recommended Posts

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 by Guest
Link to comment
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
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

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
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

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...