Jump to content

How to do a GUI only for Admins?


GamerDeMTA

Recommended Posts

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 :wink:

wnd will open only for admin group .

Link to comment

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

Link to comment
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

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