Jump to content

[HELP]Bind problem


Seba500PLK

Recommended Posts

Hi, I want to make this bind work only admins. I have this code, but bind runs each

  
--Client 
addEventHandler("onClientResourceStart",resourceRoot, 
function() 
    if not isElement(window1) then shopInterface6() end 
    bindKey ( "F2", "down", openGui ) 
end ) 
  
function openGui(a) 
if (a) then 
    if not isElement(window1) then shopInterface6() end 
    if not guiGetVisible(window1) then 
        --stats() 
        guiSetVisible ( window1, true ) 
        showCursor(true) 
    else 
        guiSetVisible ( window1, false ) 
        showCursor(false) 
    end 
    end 
    end 
addEvent("accadmin", true) 
addEventHandler("accadmin", getRootElement(), openGui) 
  

  
--Server 
function accb() 
    local account = getPlayerAccount ( source )    
        triggerClientEvent(playerSource, "accadmin", playerSource, isObjectInACLGroup ( "user." .. getAccountName(account), aclGetGroup ( "Admin" ) )) 
end 
addEventHandler("onClientResourceStart", resourceRoot, accb) 
  

Link to comment

Try it.

Server-Side

addEventHandler("onPlayerLogin", function(_,account) 
    if isObjectInACLGroup ( "user." .. getAccountName(account), aclGetGroup ( "Admin" )) then 
        bindKey ( "F2", "down", openClientGui ) 
    end 
end) 
  
function openClientGui(thePlayer, key, keyState) 
triggerClientEvent(thePlayer, "accadmin", thePlayer) 
end 

Client-Side

function openGui() 
    if not isElement(window1) then shopInterface6() end 
    guiSetVisible ( window1, not guiGetVisible(window1) ) 
    showCursor(guiGetVisible(window1)) 
end 
addEvent("accadmin", true) 
addEventHandler("accadmin", getRootElement(), openGui) 

Edited by Guest
Link to comment

Try using this

--Client 
addEventHandler("onClientResourceStart", resourceRoot, function() 
    if not isElement(window1) then  
        shopInterface6()  
    end 
    triggerServerEvent ( "onClientRequestIsPlayerAdmin", localPlayer ) 
end ) 
      
function openGui(a) 
    if (a) then 
        if not isElement(window1) then shopInterface6() end 
        if not guiGetVisible(window1) then 
            --stats() 
            guiSetVisible ( window1, true ) 
            showCursor(true) 
        else 
            guiSetVisible ( window1, false ) 
            showCursor(false) 
        end 
    end 
end 
  
addEvent ("onServerSendClientIsAdmin", true ) 
addEventHandler("onServerSendClientIsAdmin", root, function ( isAdmin )  
    if isAdmin then 
        bindKey ( "f2", "down", openGui ) 
    end  
end ) 
      
  
  
-- server 
addEvent ( "onClientRequestIsPlayerAdmin", true ) 
addEventHandler ( "onClientRequestIsPlayerAdmin", root, function ( ) 
    local a = getPlerAccount ( source ) 
    local admin = isObjectInACLGroup( "user"..getAccountName ( a ), aclGetGroup ( "Admin" ) ) 
    triggerClientEvent ( source, "onServerSendClientIsAdmin", source, admin ) 
end ) 

Link to comment

--ClientSide

function toggleGUI() 
    if guiGetVisible(GUIEditor_Window[1]) == true then --- change GUIEditor_Window[1] to your window name 
        guiSetVisible(GUIEditor_Window[1],false) 
        showCursor(false) 
    else 
        guiSetVisible(GUIEditor_Window[1],true) 
        showCursor(true) 
    end 
end 
addEvent("toggleGUI",true) 
addEventHandler("toggleGUI",root,toggleGUI) 

---server

addEventHandler("onPlayerJoin",root, 
function () 
    bindKey(source,"F2","down",showGUI) 
end) 
  
addEventHandler("onResourceStart",resourceRoot, 
function () 
    for index, player in ipairs(getElementsByType("player")) do 
        bindKey(player,"F2","down",showGUI) 
    end 
end) 
  
function showGUI(thePlayer) 
    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)),aclGetGroup("Admin")) then 
        triggerClientEvent(thePlayer,"toggleGUI",thePlayer) 
    else 
    outputChatBox(" You Dont Have Access to This Panel",thePlayer,255,0,0) 
    end 
end 
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...