Jump to content

Set gui visible


Nameless

Recommended Posts

Hi,

I have a problem with showing my GUI window;

-- How do I give the status (true or false) to set the window visible?

-- If I press "F10" (as an admin the window gets visible for everybody

Is there a way I can fix this? If you dont understand my problem, please ask!

Here is my code:

--Server script, checking if logged in player is admin 
local root = getRootElement() 
addEventHandler("onPlayerLogin", root, 
  function() 
    if ( hasObjectPermissionTo ( source, "function.aclSetRight", false ) ) then  
     
            bindKey(source, "F10", "down", function(player, key, state) 
            triggerClientEvent("showMsgWdw", getRootElement()) 
  
        end) 
    end 
  end 
) 

--Client script to set window visible 
  
function showMessageWindow(status) 
        --check if function should show or hide window 
        if status ~= true and status ~= false then 
            status = not guiGetVisible(msgWindow)            
        end 
        if status == true then 
         
            guiSetInputEnabled(true) 
            guiSetVisible(msgWindow, true) 
            showCursor(true) 
             
        else 
         
            guiSetInputEnabled(false) 
            guiSetVisible(msgWindow, false) 
            showCursor(false) 
        end 
end 
addEvent( "showMsgWdw", true ) 
addEventHandler( "showMsgWdw", getRootElement(), showMessageWindow ) 

I really hope you guys can find a sollution for my problem!

Link to comment
Guest Guest4401
If I press "F10" (as an admin the window gets visible for everybody
Change
triggerClientEvent("showMsgWdw", getRootElement()) 

to

triggerClientEvent(player,"showMsgWdw", getRootElement()) 

How do I give the status (true or false) to set the window visible?
What do you mean?
Link to comment

you dont know what are you doing

--Server script 
function setVisible(player,key,keyState ) -- our function 
    local accName =  getAccountName ( getPlayerAccount ( player ) ) -- get player account 
    if (keyState == "down") then -- if player pressed on "f10" then 
        if isObjectInACLGroup ( "user." .. tostring( accName ), aclGetGroup( "Admin" ) ) then -- if player have admin rights then 
            triggerClientEvent("showMsgWdw", getRootElement()) -- call client for show window 
        else -- if not 
            outputChatBox ('#ffffffERROR: #ffffffYou not admin',player,255,255,255,true) -- outputchatbox 
        end 
    end 
end 
bindKey ( player, "F10", "down", setVisible ) -- bind on f10 our function 
  
  
--Client script to set window visible 
function showMessageWindow() -- function for trigger 
    if (guiGetVisible(msgWindow) == true) then      -- if window opened then      
        guiSetVisible (msgWindow,false ) -- close window 
        showCursor(false) --disable cursor 
        guiSetInputEnabled(false) --disable input focus 
    else               
        guiSetVisible (msgWindow,true ) enable --//-- 
        showCursor(true) -- enable --//-- 
        guiSetInputEnabled(true) --enable --//-- 
    end 
end 
addEvent( "showMsgWdw", true ) -- our event 
addEventHandler( "showMsgWdw", getRootElement(), showMessageWindow ) -- attach our trigger to function 
  

Link to comment
If I press "F10" (as an admin the window gets visible for everybody
Change
triggerClientEvent("showMsgWdw", getRootElement()) 

to

triggerClientEvent(player,"showMsgWdw", getRootElement()) 

How do I give the status (true or false) to set the window visible?
What do you mean?

Thank you for your reply! I changed the triggerClientEvent, but the window doesnt show up anymore..

For some reason the showMessageWindow function is not executed.

Link to comment
--Server script, checking if logged in player is admin 
  
addEventHandler ( "onPlayerLogin", root, 
    function ( ) 
        if ( hasObjectPermissionTo ( source, "function.aclSetRight", false ) ) then 
            bindKey ( source, "F10", "down", onKeyUse ) 
        end 
    end 
) 
  
function onKeyUse ( thePlayer ) 
    triggerClientEvent ( thePlayer, "showMsgWdw", thePlayer ) 
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...