Jump to content

Help


manve1

Recommended Posts

i'm trying to trigger ACL to client side and i just can't manage it my self, tried out different way's, but still didn't open the window.

client:

    function triggering_cc() 
            if ( guiGetVisible ( Wnd ) == true ) then               
                guiSetVisible ( Wnd, false ) 
                showCursor(false) 
        else               
                guiSetVisible ( Wnd, true ) 
                showCursor(true) 
        end 
    end 
    addEvent( "triggering_c", true ) 
    addEventHandler("triggering_c", root, triggering_cc) 

server:

    function triggering() 
            if isObjectInACLGroup ( "user." ..getAccountName ( getPlayerAccount ( p ) ), aclGetGroup ( "Moderator" ) )then 
                    bindKey('p','down', 
                    function() 
                    guiSetVisible(Wnd, not guiGetVisible(Wnd)) 
                    showCursor(not isCursorShowing()) 
                    end 
                    ) 
                    triggerClientEvent ( thePlayer, "triggering_c", getRootElement() ) 
            end 
    end 

Link to comment

You need the server to tell the client if he/she has access to the window and the client should do the rest of the job. Something like this:

Server:

function letUseTheGUIIfModerator(player) 
    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Moderator")) then 
        triggerClientEvent(player, "letUseTheGUI", root) 
    end 
end 

Client:

function createModeratorGUI() 
    Wnd = guiCreateWindow(100, 100, 100, 100, "SomeWindow", false) 
    --do everything else what you need in that window 
  
    bindKey("p", "down", 
        function() 
            local show = not guiGetVisible(Wnd) 
            guiSetVisible(Wnd, show) 
            showCursor(show) 
        end 
    ) 
end 
addEvent("letUseTheGUI", true) 
addEventHandler("letUseTheGUI", root, createModeratorGUI) 

You will need to call letUseTheGUIIfModerator from the server-side script (make sure the client will have downloaded the script when you do so). This function checks if the player is a moderator, and if so, then tells the client to create the window by triggering "letUseTheGUI" event. On the client, this causes createModeratorGUI to be called and this function creates the window and binds the key P to toggle the visibility of that window.

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