vidadeboy13 Posted November 3, 2014 Share Posted November 3, 2014 Who can help me? I have this script, and there is a command: /dog, i wanna make this this command be used only by ADMINS that are in the ACL. How? Here the is two parts of the script! PART 1: addCommandHandler("dog", DMCreateDog) addCommandHandler("deletedog", DMDeleteDog) addCommandHandler("unlockall", DMUnlockAll) PART 2: --DOG CREATOR function DMCreateDog() if(DMClientOwnerGotDog == true)then outputChatBox("You already have a dog!", 255, 0,0) else if(DMDogPanel == true)then removeEventHandler("onClientRender", getRootElement(), DMDogPanelGui) DMDogPanel = false guiSetVisible(DMDogPanelButton1, false) guiSetVisible(DMDogPanelButton2, false) guiSetVisible(DMDogPanelButton3, false) guiSetVisible(DMDogPanelButton4, false) guiSetVisible(DMDogPanelButton5, false) guiSetVisible(DMDogPanelButton6, false) guiSetVisible(DMDogPanelButton7, false) showCursor(false) end I Alredy try this, but dont work: PART 1: addCommandHandler("dog", DMCreateDog) addCommandHandler("deletedog", DMDeleteDog) addCommandHandler("unlockall", DMUnlockAll) PART 2: --DOG CREATOR function DMCreateDog() if isObjectInACLGroup ( "user."..getAccountName(getPlayerAccount(Player)), aclGetGroup ( "Admin" ) ) then else return outputChatBox("This command can be used by admins only!", Player, 255, 0, 0, false) end if(DMClientOwnerGotDog == true)then outputChatBox("You already have a dog!", 255, 0,0) else if(DMDogPanel == true)then removeEventHandler("onClientRender", getRootElement(), DMDogPanelGui) DMDogPanel = false guiSetVisible(DMDogPanelButton1, false) guiSetVisible(DMDogPanelButton2, false) guiSetVisible(DMDogPanelButton3, false) guiSetVisible(DMDogPanelButton4, false) guiSetVisible(DMDogPanelButton5, false) guiSetVisible(DMDogPanelButton6, false) guiSetVisible(DMDogPanelButton7, false) showCursor(false) end Who can help me? Link to comment
Dealman Posted November 3, 2014 Share Posted November 3, 2014 The ACL functions are server side. Your script is client side. I can further assist you when I'm back home, unless someone else does so before me. Link to comment
vidadeboy13 Posted November 3, 2014 Author Share Posted November 3, 2014 Ok, thanks, i'am waiting you Link to comment
Dealman Posted November 4, 2014 Share Posted November 4, 2014 Sorry for the delay, I had forgotten about this thread... Back to the subject, the issue you were having was that you tried to use the ACL functions on a client-side script. You'll have to use triggerServerEvent and triggerClientEvent to check a client's permissions. I suggest you read up on those functions as well as addEvent. Anyway, I wrote this to provide you with a working(hopefully) example. Client Side: addCommandHandler("deletedog", DMDeleteDog); addCommandHandler("unlockall", DMUnlockAll); function DMCreateDogPermissionCheck_Handler() if(DMClientOwnerGotDog == true) then outputChatBox("You've already got a dog...!", 255, 0, 0, true); else triggerServerEvent("onPlayerAttemptDogCreation", localPlayer); -- Trigger a server-side event to check the player permissions end end addCommandhandler("Dog", DMCreateDogPermissionCheck_Handler, false); -- False makes it non-case sensitive, so you can enter dog, Dog, DOG, doG and etc function DMCreateDog_Handler() if(DMDogPanel == true)then removeEventHandler("onClientRender", root, DMDogPanelGui); DMDogPanel = false guiSetVisible(DMDogPanelButton1, false); guiSetVisible(DMDogPanelButton2, false); guiSetVisible(DMDogPanelButton3, false); guiSetVisible(DMDogPanelButton4, false); guiSetVisible(DMDogPanelButton5, false); guiSetVisible(DMDogPanelButton6, false); guiSetVisible(DMDogPanelButton7, false); showCursor(false); end end addEvent("onClientAllowedDogCreation", true); addEventHandler("onClientAllowedDogCreation", root, DMCreateDog_Handler); Server Side: function onPlayerAttemptDogCreation_Handler() if(getElementType(client) == "player") then local theAccount = getAccountName(getPlayerAccount(client)); if(theAccount) then if(isObjectInACLGroup("user"..theAccount, aclGetGroup("Admin")) then triggerClientEvent("onClientAllowedDogCreation", root); -- Trigger a client event if the permission check was successful else outputChatBox("You do not have permission to use this command(Dog)!", client, 255, 0, 0, true); -- Display a message if they do not have permission end else outputDebugString("[Dog] Error, couldn't check permissions - account is false or nil!", 0, 187, 0, 0); end end end addEvent("onPlayerAttemptDogCreation", true); addEventHandler("onPlayerAttemptDogCreation", root, checkPlayerPermission_Handler); I apologize if there are any errors, I haven't tried it. But I'm sure you'll be able to work it out from here on. Link to comment
vidadeboy13 Posted November 5, 2014 Author Share Posted November 5, 2014 So, I'm not very good in scripts, can you make for me? Link to comment
Dealman Posted November 5, 2014 Share Posted November 5, 2014 I already did, the code's in the spoilers. Link to comment
vidadeboy13 Posted November 5, 2014 Author Share Posted November 5, 2014 So, tjanks, but it doeasnt work.... 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