Seba500PLK Posted August 16, 2014 Posted August 16, 2014 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)
undefined Posted August 16, 2014 Posted August 16, 2014 (edited) 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 August 16, 2014 by Guest
xXMADEXx Posted August 16, 2014 Posted August 16, 2014 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 )
Seba500PLK Posted August 16, 2014 Author Posted August 16, 2014 already gives'm sorry I did not have internet No, errors
Max+ Posted August 16, 2014 Posted August 16, 2014 --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
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