Jump to content

ACL help needed


delete.

Recommended Posts

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

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
-- 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 by Dimos7
Link to comment
-- 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 by Dimos7
Link to comment
-- 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 by MrTasty
Link to comment
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

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

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