Jump to content

Got a problem.


manve1

Recommended Posts

I have a problem trying to trigger ACL functions to client side from server side.

LUA - CLIENT:

hWnd_Commands = guiCreateWindow( 0.2, 0.2, 0.6, 0.6, "Admin LVL.5 Commands || By Enjoy || Version 1.0", true ) 
hGrid_Admin = guiCreateGridList( 0.1, 0.1, 0.8, 0.6, true, hWnd_Commands ) 
function visibleToAdmin5(p) 
    triggerServerEvent('aclAdmin5', root) 
        guiSetVisible(hWnd_Commands, true) 
        showCursor(true) 
end 
addCommandHandler('mycmds', visibleToAdmin5) 
addEventHandler('onPlayerLogin', getRootElement(), visibleToAdmin5) 

LUA - SERVER:

addEvent('aclAdmin5',true) 
function aclAdmin5_( p ) 
    if isObjectInACLGroup ( "user." ..getAccountName ( getPlayerAccount ( p ) ), aclGetGroup ( "Admin5" ) ) then 
    end 
end 
addEventHandler('aclAdmin5', getRootElement(), aclAdmin5_) 

ERRORS - PIC:

TAHP7.png

Link to comment

You are triggering the event from client to server, but you haven't added any ARGUMENT, so p is null.

hWnd_Commands = guiCreateWindow( 0.2, 0.2, 0.6, 0.6, "Admin LVL.5 Commands || By Enjoy || Version 1.0", true ) 
hGrid_Admin = guiCreateGridList( 0.1, 0.1, 0.8, 0.6, true, hWnd_Commands ) 
function visibleToAdmin5() 
    triggerServerEvent('aclAdmin5', root, source) 
        guiSetVisible(hWnd_Commands, true) 
        showCursor(true) 
end 
addCommandHandler('mycmds', visibleToAdmin5) 
addEventHandler('onPlayerLogin', getRootElement(), visibleToAdmin5) 

Link to comment
You are triggering the event from client to server, but you haven't added any ARGUMENT, so p is null.
hWnd_Commands = guiCreateWindow( 0.2, 0.2, 0.6, 0.6, "Admin LVL.5 Commands || By Enjoy || Version 1.0", true ) 
hGrid_Admin = guiCreateGridList( 0.1, 0.1, 0.8, 0.6, true, hWnd_Commands ) 
function visibleToAdmin5() 
    triggerServerEvent('aclAdmin5', root, source) 
        guiSetVisible(hWnd_Commands, true) 
        showCursor(true) 
end 
addCommandHandler('mycmds', visibleToAdmin5) 
addEventHandler('onPlayerLogin', getRootElement(), visibleToAdmin5) 

oh yeh, i am, ty bro, only problem = it don't work :)

Link to comment

LUA - CLIENT:

  
addEventHandler("onClientResourceStart", resourceRoot, function() 
hWnd_Commands = guiCreateWindow( 0.2, 0.2, 0.6, 0.6, "Admin LVL.5 Commands || By Enjoy || Version 1.0", true ) 
hGrid_Admin = guiCreateGridList( 0.1, 0.1, 0.8, 0.6, true, hWnd_Commands ) 
  
guiSetVisible(hWnd_Commands, false) 
end) 
  
function visibleToAdmin5() 
    triggerServerEvent('aclAdmin5', root) 
        guiSetVisible(hWnd_Commands, true) 
        showCursor(true) 
end 
addCommandHandler('mycmds', visibleToAdmin5) 
addEventHandler('onPlayerLogin', getRootElement(), visibleToAdmin5) 

LUA - SERVER:

addEvent('aclAdmin5',true) 
function aclAdmin5_( ) 
    if isObjectInACLGroup ( "user." ..getAccountName ( getPlayerAccount ( client ) ), aclGetGroup ( "Admin5" ) ) then 
    end 
end 
addEventHandler('aclAdmin5', getRootElement(), aclAdmin5_) 

Anyways, what you are trying to do it to make the check serverside? If so, it doesn't return any value, thus won't really make any effect on the clientside function.

Link to comment
  • MTA Team

The event which you have server-side doesn't return anything. This should work.

Client-side

function g_commands() 
    if not isElement(hWnd_Commands) then 
        hWnd_Commands = guiCreateWindow(0.2, 0.2, 0.6, 0.6, "Admin LVL.5 Commands || By Enjoy || Version 1.0", true) 
        hGrid_Admin = guiCreateGridList(0.1, 0.1, 0.8, 0.6, true, hWnd_Commands) 
        showCursor(true) 
    else 
        destroyElement(hWnd_Commands) 
        showCursor(false) 
    end 
) 
  
function visibleToAdmin5() 
    triggerServerEvent("aclAdmin5", localPlayer) 
end 
addCommandHandler("mycmds", visibleToAdmin5) 
addEventHandler("onPlayerLogin", root, visibleToAdmin5) 
  
addEvent("onPermissionGranted", true) 
addEventHandler("onPermissionGranted", root, 
    function() 
        g_commands() 
    end 
) 

Server-side

addEvent("aclAdmin5", true) 
addEventHandler("aclAdmin5", root, 
    function() 
        if isObjectInACLGroup("user." ..getAccountName(getPlayerAccount(source)), aclGetGroup ("Admin5")) then 
            triggerClientEvent("onPermissionGranted", source) 
        end 
    end 
) 

Edit: Just realized this is my 666th post, lmao.

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