Jump to content

How to do a GUI only for Admins?


GamerDeMTA

Recommended Posts

Posted

-- Server Function's 
addEvent 
addEventHandler 
isObjectInACLGroup 
triggerClientEvent 
  
-- Client Funciton's  
  
guiSetVisible 
showCursor 
bindKey 
addEvent 
addEventHandler 
triggerServerEvent 
Posted

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 .

Posted

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 
  

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

Posted
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

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

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