Jump to content

output playername on click


Andreas.

Recommended Posts

Posted

I think using "guiRoot" would work.

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted (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 by Guest
 #define if while#define TRUE FALSE// problems?
Posted
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.

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

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

Posted

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?

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

 #define if while#define TRUE FALSE// problems?

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