delete. Posted January 27, 2017 Share Posted January 27, 2017 Hi, I have installed a resource called "fly", lets you fly with a vehicle using /fly. I wanted to make this for admins only, so I added a line in acl.xml under the "<acl name="Default">", so I added a line called <right name="command.fly" access="true"></right>. I have tested it with a NON admin account and seems like that it's not working. How to fix this issue? Link to comment
Dimos7 Posted January 27, 2017 Share Posted January 27, 2017 put acess false in default Link to comment
delete. Posted January 27, 2017 Author Share Posted January 27, 2017 i have set from "true" to "false", but it's still not working Link to comment
MIKI785 Posted January 27, 2017 Share Posted January 27, 2017 Do you have restricted argument set to true in your addCommandHandler? Link to comment
delete. Posted January 28, 2017 Author Share Posted January 28, 2017 Nope, here's the code, it's a small one; addCommandHandler ("fly", function () if not flyEnabled then setWorldSpecialPropertyEnabled ( "aircars", true ) flyEnabled = true else setWorldSpecialPropertyEnabled ( "aircars", false ) flyEnabled = false end end ) I'm not a pro in scripting, so what should I do in there? @MIKI785 Link to comment
Dimos7 Posted January 28, 2017 Share Posted January 28, 2017 (edited) -- client addCommandHandler("fly", function() if not flyEnabled then trrigerServerEvent("access", localPlayer) setWorldSpecialPropertyEnabled("aircars", true) flyEnabled = true else triggerServerEvent("access", localPlayer) setWorldSpecialPropertyEnabled("aircars", false) flyEnabled = false end end) -- server function flyAblility(thePlayer) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin")) then executeCommandHandler("fly", thePlayer) end end addEvent("access", true) addEventHandler("access", root, flyAbility) Edited January 28, 2017 by Dimos7 Link to comment
delete. Posted January 28, 2017 Author Share Posted January 28, 2017 The code that I provided, was server side originally @Dimos7 So would it still work? Link to comment
Dimos7 Posted January 28, 2017 Share Posted January 28, 2017 no was client is one client and one server make another lua file @testchannel50 Link to comment
delete. Posted January 29, 2017 Author Share Posted January 29, 2017 I got this: [2017-01-29 16:46:13] WARNING: fly\s_fly.lua:7: Bad argument @ 'addEventHandler' [Expected function at argument 3, got nil] Yes, I've added everything, a separate file, added it in meta.xml, but tried doing /fly ingame and it doesn't work. @Dimos7 Link to comment
mint3d Posted January 29, 2017 Share Posted January 29, 2017 function flyAbility(thePlayer) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin")) then executeCommandHandler("fly", thePlayer) end end addEvent("access", true) addEventHandler("access", root, flyAbility) Link to comment
delete. Posted January 29, 2017 Author Share Posted January 29, 2017 isn't it the same as dimos provided? Link to comment
mint3d Posted January 29, 2017 Share Posted January 29, 2017 Try it and see, he had a spelling mistake in his. Link to comment
delete. Posted February 1, 2017 Author Share Posted February 1, 2017 (edited) still doesnt work @mint3d edit: tried in debugscript 3 and got this: ERROR: fly\c_fly.lua:4: attempt to call global 'triggerServerEvent' (a nil value) Edited February 1, 2017 by testchannel50 Link to comment
Dimos7 Posted February 1, 2017 Share Posted February 1, 2017 (edited) -- client addCommandHandler("fly", function() triggerServerEvent("access", localPlayer, isPlayerAdmin) if isPlayerAdmin == true then if not flyEnabled then setWorldSpecialPropertyEnabled("aircars", true) flyEnabled = true else setWorldSpecialPropertyEnabled("aircars", false) flyEnabled = false end end end) -- server function flyAbility(thePlayer) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin")) then isPlayerAdmin = true end end addEvent("access", true) addEventHandler("access", root, flyAbility) Edited February 1, 2017 by Dimos7 Link to comment
Addlibs Posted February 1, 2017 Share Posted February 1, 2017 (edited) -- client addCommandHandler("fly", function() triggerServerEvent("access", localPlayer) --ask server for access end ) addEventHandler("onFlyGranted", localPlayer, function() flyEnabled = not flyEnabled --invert flyEnabled setWorldSpecialPropertyEnabled("aircars", flyEnabled) --set aircars to the new, inverted flyEnabled end ) -- server function flyAbility() if client then else return false end --make sure that the event was properly called (see https://wiki.multitheftauto.com/wiki/Script_security#Validating_client_triggerServerEvent) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(client)), aclGetGroup("Admin")) then -- if authorised triggerClientEvent(client, "onFlyGranted", client) --tell client to change flyEnabled and aircars property end end addEvent("access", true) addEventHandler("access", root, flyAbility) --catch client's requests for authorisation Edited February 1, 2017 by MrTasty Link to comment
delete. Posted February 1, 2017 Author Share Posted February 1, 2017 5 hours ago, Dimos7 said: -- client addCommandHandler("fly", function() triggerServerEvent("access", localPlayer, isPlayerAdmin) if isPlayerAdmin == true then if not flyEnabled then setWorldSpecialPropertyEnabled("aircars", true) flyEnabled = true else setWorldSpecialPropertyEnabled("aircars", false) flyEnabled = false end end end) -- server function flyAbility(thePlayer) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin")) then isPlayerAdmin = true end end addEvent("access", true) addEventHandler("access", root, flyAbility) WARNING: fly\s_fly.lua:2: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] WARNING: fly\s_fly.lua:2: Bad argument @ 'getAccountName' [Expected account at argument 1, got boolean] ERROR: fly\s_fly.lua:2: attempt to concatenate a boolean value @Dimos7 3 hours ago, MrTasty said: -- client addCommandHandler("fly", function() triggerServerEvent("access", localPlayer) --ask server for access end ) addEventHandler("onFlyGranted", localPlayer, function() flyEnabled = not flyEnabled --invert flyEnabled setWorldSpecialPropertyEnabled("aircars", flyEnabled) --set aircars to the new, inverted flyEnabled end ) -- server function flyAbility() if client then else return false end --make sure that the event was properly called (see https://wiki.multitheftauto.com/wiki/Script_security#Validating_client_triggerServerEvent) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(client)), aclGetGroup("Admin")) then -- if authorised triggerClientEvent(client, "onFlyGranted", client) --tell client to change flyEnabled and aircars property end end addEvent("access", true) addEventHandler("access", root, flyAbility) --catch client's requests for authorisation Got this in debug: ERROR: Server triggered clientside event onFlyGranted, but event is not added clientside @MrTasty Link to comment
pa3ck Posted February 1, 2017 Share Posted February 1, 2017 The error message tells you exactly what to do. "event is not added clientside" you are missing the client-side addEvent("onFlyGranted", true) Link to comment
Dimos7 Posted February 1, 2017 Share Posted February 1, 2017 -- client addCommandHandler("fly", function() triggerServerEvent("access", localPlayer) --ask server for access end ) addEvent("onFlyGranted", true) addEventHandler("onFlyGranted", localPlayer, function() flyEnabled = not flyEnabled --invert flyEnabled setWorldSpecialPropertyEnabled("aircars", flyEnabled) --set aircars to the new, inverted flyEnabled end ) -- server function flyAbility() if client then else return false end --make sure that the event was properly called (see https://wiki.multitheftauto.com/wiki/Script_security#Validating_client_triggerServerEvent) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(client)), aclGetGroup("Admin")) then -- if authorised triggerClientEvent(client, "onFlyGranted", client) --tell client to change flyEnabled and aircars property end end addEvent("access", true) addEventHandler("access", root, flyAbility) --catch client's requests for authorisation Link to comment
delete. Posted February 5, 2017 Author Share Posted February 5, 2017 It works now. Thanks to all of you guys! 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