manve1 Posted October 17, 2012 Share Posted October 17, 2012 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: Link to comment
Callum Posted October 17, 2012 Share Posted October 17, 2012 Either change 'p' to source (and remove 'p' from the function params), or change Line 4 (client-side) to; triggerServerEvent("aclAdmin5",localPlayer,localPlayer) Link to comment
TwiX! Posted October 17, 2012 Share Posted October 17, 2012 addEventHandler('onPlayerLogin', getRootElement(), visibleToAdmin5) This event can use only 'source' Link to comment
Renkon Posted October 17, 2012 Share Posted October 17, 2012 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
manve1 Posted October 17, 2012 Author Share Posted October 17, 2012 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
Renkon Posted October 17, 2012 Share Posted October 17, 2012 In ServerEvent, set as second argument, localPlayer instead of root Link to comment
Araa Posted October 17, 2012 Share Posted October 17, 2012 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
manve1 Posted October 18, 2012 Author Share Posted October 18, 2012 It still doesn't make GUI visible to people that are in the acl group Admin5 Link to comment
myonlake Posted October 18, 2012 Share Posted October 18, 2012 It still doesn't make GUI visible to people that are in the acl group Admin5 Probably because you aren't doing anything when it checks that. Link to comment
manve1 Posted October 18, 2012 Author Share Posted October 18, 2012 It still doesn't make GUI visible to people that are in the acl group Admin5 Probably because you aren't doing anything when it checks that. don't really get what you mean Link to comment
myonlake Posted October 18, 2012 Share Posted October 18, 2012 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
manve1 Posted October 18, 2012 Author Share Posted October 18, 2012 works, thank you. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now