Basic docs for all of ox_lib

This commit is contained in:
Linden committed 2022-03-01 21:09:18 +11:00
1 parent 2350a5bfc1
commit fd5ccc4964
14 files changed
+206 -64

No files matched your search

+46
View File
@@ -0,0 +1,46 @@
# Permissions
Wrapper around the built-in ACL system. Handles lib.addCommand and ox_groups permissions.
Refer to [Basic Aces & Principals overview/guide](https://forum.cfx.re/t/basic-aces-principals-overview-guide/90917) for more information.
### lib.addAce
Assigns the ace permission to a principal. Third parameter defaults to 'allow', while false sets the permission to 'deny'.
```lua
-- principal: string
-- ace: string
-- allow: boolean
lib.addAce(principal, ace, allow)
lib.addAce('group.admin', 'command.say')
```
### lib.removeAce
Removes the ace permission from a principal. Third parameter defaults to 'allow', while false sets the permission to 'deny'.
```lua
-- principal: string
-- ace: string
-- allow: boolean
lib.removeAce(principal, ace, allow)
lib.removeAce('group.admin', 'command.say')
```
### lib.addPrincipal
Assigns a principal to a parent principal. Children inherit permissions from the parent.
```lua
-- child: string
-- parent: string
lib.addPrincipal(child, parent)
lib.addPrincipal('player.1', 'group.moderator')
```
### lib.removePrincipal
Removes a principal from a parent principal.
```lua
-- child: string
-- parent: string
lib.removePrincipal(child, parent)
lib.removePrincipal('player.1', 'group.moderator')
```
+17
View File
@@ -0,0 +1,17 @@
# Command
```lua
-- principal: string or false
-- command: string
-- callback: function
-- parameters: table (optional)
-- help: string (optional)
lib.addCommand(principal, command, callback, parameters, help)
lib.addCommand('group.admin', {'additem', 'giveitem'}, function(source, args)
args.item = Items(args.item)
if args.item and args.count > 0 then
Inventory.AddItem(args.target, args.item.name, args.count, args.metatype)
end
end, {'target:number', 'item:string', 'count:number', 'metatype:?string'})
```
+13
View File
@@ -0,0 +1,13 @@
# Callbacks
### lib.callback.register
```lua
-- name: string
-- cb: function
lib.callback.register(name, cb)
lib.callback.register('ox_inventory:getItemCount', function(source, item, metadata, target)
local inventory = target and Inventory(target) or Inventory(source)
return (inventory and Inventory.GetItem(inventory, item, metadata, true)) or 0
end)
```
+12
View File
@@ -0,0 +1,12 @@
# Version check
### lib.versionCheck
Compares the resource version to the latest published release on GitHub.
```lua
-- repository: string
lib.versionCheck(repository)
lib.versionCheck('overextended/ox_lib')
```
[Utilises GitHub's release API](https://docs.github.com/en/rest/reference/releases)