GamerDeMTA Posted March 14, 2013 Share Posted March 14, 2013 I can do it? When I press for example F6 opens a GUI only If I'm logged in as Moderator/sMod/admin I can? Link to comment
iPrestege Posted March 14, 2013 Share Posted March 14, 2013 -- Server Function's addEvent addEventHandler isObjectInACLGroup triggerClientEvent -- Client Funciton's guiSetVisible showCursor bindKey addEvent addEventHandler triggerServerEvent Link to comment
Renkon Posted March 14, 2013 Share Posted March 14, 2013 isObjectInACLGroup triggerClientEvent Link to comment
iPrestege Posted March 14, 2013 Share Posted March 14, 2013 You can try this : -- Server -- addEventHandler( 'onPlayerLogin', root, function( _, acc ) if isObjectInACLGroup( 'user.'..getAccountName( acc ), aclGetGroup( "Admin" ) ) then setElementData( source, 'OpenPanel', true) else setElementData( source, 'OpenPanel', nil) end end ) addEventHandler( 'onPlayerJoin', root, function() setElementData( source, 'OpenPanel', nil) end ) -- Client -- bindKey ("F6", "down", function() if getElementData( localPlayer, 'OpenPanel') ~= nil then guiSetVisible(wnd, not guiGetVisible(wnd)) showCursor(guiGetVisible(wnd)) end end ) wnd = You're Window wnd will open only for admin group . Link to comment
OGF Posted March 14, 2013 Share Posted March 14, 2013 Much easier if you bind the key server sided Good because it checks if the person is admin to bind the key and when the player presses the key, just a little more security. server function onlogin () local accountname = getAccountName(getPlayerAccount(source)) if isObjectInACLGroup("user." ..accountname, aclGetGroup("Admin")) then bindKey ( source, "F6", "down", triggerWindow) end end addEventHandler ( "onPlayerLogin", root, onlogin ) function triggerWindow(source) local accountname = getAccountName(getPlayerAccount(source)) if isObjectInACLGroup("user." ..accountname, aclGetGroup("Admin")) then triggerClientEvent ( contenthere ) end end Link to comment
iPrestege Posted March 14, 2013 Share Posted March 14, 2013 Much easier if you bind the key server sided Good because it checks if the person is admin to bind the key and when the player presses the key, just a little more security. server function onlogin () local accountname = getAccountName(getPlayerAccount(source)) if isObjectInACLGroup("user." ..accountname, aclGetGroup("Admin")) then bindKey ( source, "F6", "down", triggerWindow) end end addEventHandler ( "onPlayerLogin", root, onlogin ) function triggerWindow(source) local accountname = getAccountName(getPlayerAccount(source)) if isObjectInACLGroup("user." ..accountname, aclGetGroup("Admin")) then triggerClientEvent ( contenthere ) end end Hmm. i use set and get data better for me lol it will work any way . Link to comment
PaiN^ Posted March 14, 2013 Share Posted March 14, 2013 addEventHandler( 'onPlayerLogin', root, function( _, acc ) if isObjectInACLGroup( 'user.'..getAccountName( acc ), aclGetGroup( "Admin" ) ) then setElementData( source, 'OpenPanel', true) else setElementData( source, 'OpenPanel', nil) end end ) addEventHandler( 'onPlayerJoin', root, function() setElementData( source, 'OpenPanel', nil) end ) I guess that it's better to use onResourceStart instead of onPlayerLogin Link to comment
PaiN^ Posted March 14, 2013 Share Posted March 14, 2013 No that's will be fine . I said it's better because if an admin logged in and then started the resource after he won't be able to open the GUI wnd that's all .. 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