mirror of
https://github.com/darksaid98/overextended.github.io.git
synced 2026-12-01 14:38:50 +00:00
Basic docs for all of ox_lib
This commit is contained in:
1 parent
2350a5bfc1
commit
fd5ccc4964
14 files changed
+206
-64
No files matched your search
@@ -0,0 +1,14 @@
|
||||
# Cache
|
||||
|
||||
Caches data related to the player and handling some events or statebags.
|
||||
An interval runs every 100ms to update data that cannot be checked via handlers.
|
||||
|
||||
Still a work-in-progress and does not have any API or events.
|
||||
https://github.com/overextended/ox_lib/blob/master/resource/states/client.lua
|
||||
|
||||
## States
|
||||
```lua
|
||||
cache.ped = PlayerPedId()
|
||||
cache.vehicle = GetVehiclePedIsIn(cache.ped, false)
|
||||
cache.driver = GetPedInVehicleSeat(cache.vehicle, -1) == cache.ped
|
||||
```
|
||||
@@ -0,0 +1,27 @@
|
||||
# Callbacks
|
||||
|
||||
Triggers a registered server callback and registers an event handler for the response.
|
||||
|
||||
### lib.callback
|
||||
The response is handled in a separate coroutine.
|
||||
```lua
|
||||
-- name: string
|
||||
-- delay: number or false
|
||||
-- cb: function
|
||||
lib.callback(name, delay, cb, ...)
|
||||
|
||||
lib.callback('ox_inventory:getItemCount', false, function(count)
|
||||
print(count)
|
||||
end, 'water', {type = 'fresh'})
|
||||
```
|
||||
|
||||
### lib.callback.await
|
||||
The current coroutine is yielded until a response is received.
|
||||
```lua
|
||||
-- name: string
|
||||
-- delay: number or false
|
||||
lib.callback.await(name, delay, ...)
|
||||
|
||||
local count = lib.callback('ox_inventory:getItemCount', false, 'water', {type = 'fresh'})
|
||||
print(count)
|
||||
```
|
||||
@@ -0,0 +1,24 @@
|
||||
# Disable Controls
|
||||
|
||||
### lib.disableControls
|
||||
```lua
|
||||
lib.disableControls()
|
||||
```
|
||||
|
||||
### lib.disableControls:Add
|
||||
```lua
|
||||
-- vararg: number
|
||||
lib.disableControls:Add(...)
|
||||
```
|
||||
|
||||
### lib.disableControls:Remove
|
||||
```lua
|
||||
-- vararg: number
|
||||
lib.disableControls:Remove(...)
|
||||
```
|
||||
|
||||
### lib.disableControls:Clear
|
||||
```lua
|
||||
-- vararg: number
|
||||
lib.disableControls:Clear(...)
|
||||
```
|
||||
@@ -0,0 +1,39 @@
|
||||
# Streaming
|
||||
|
||||
Check if assets exist, such as models, and loads them into memory.
|
||||
Throws errors for invalid assets and returns false if it could not be loaded.
|
||||
|
||||
### lib.requestAnimDict
|
||||
```lua
|
||||
-- dict: string
|
||||
-- timeout: number [default: 100]
|
||||
lib.requestAnimDict(dict, timeout)
|
||||
```
|
||||
|
||||
### lib.requestAnimSet
|
||||
```lua
|
||||
-- set: string
|
||||
-- timeout: number [default: 100]
|
||||
lib.requestAnimSet(set, timeout)
|
||||
```
|
||||
|
||||
### lib.requestModel
|
||||
```lua
|
||||
-- model: string
|
||||
-- timeout: number [default: 100]
|
||||
lib.requestModel(model, timeout)
|
||||
```
|
||||
|
||||
### lib.requestStreamedTextureDict
|
||||
```lua
|
||||
-- dict: string
|
||||
-- timeout: number [default: 100]
|
||||
lib.requestStreamedTextureDict(dict, timeout)
|
||||
```
|
||||
|
||||
### lib.requestNamedPtfxAsset
|
||||
```lua
|
||||
-- fxName: string
|
||||
-- timeout: number [default: 100]
|
||||
lib.requestNamedPtfxAsset(fxName, timeout)
|
||||
```
|
||||
@@ -0,0 +1,29 @@
|
||||
# Vehicle Properties
|
||||
Mostly follows the format used by ESX and QBCore, with extra data such as damaged/missing props.
|
||||
https://github.com/overextended/ox_lib/blob/master/resource/entities/client/vehicleproperties.lua#L5
|
||||
|
||||
### lib.getVehicleProperties
|
||||
```lua
|
||||
-- vehicle: entity
|
||||
lib.getVehicleProperties(vehicle)
|
||||
|
||||
lib.getVehicleProperties(GetVehiclePedIsUsing(PlayerPedId()))
|
||||
```
|
||||
|
||||
### lib.setVehicleProperties
|
||||
Requires the vehicle to belong to the client. _Do not use NetworkRequestControlOfEntity_.
|
||||
```lua
|
||||
-- vehicle: entity
|
||||
-- props: table
|
||||
lib.setVehicleProperties(vehicle, props)
|
||||
|
||||
RegisterNetEvent('lualib:setVehicleProperties', function(netid, data)
|
||||
lib.setVehicleProperties(NetToVeh(netid), data)
|
||||
end)
|
||||
```
|
||||
|
||||
#### Recommended usage
|
||||
The server should tell the owner of the entity to set properties, using the following trigger.
|
||||
```lua
|
||||
TriggerClientEvent('lualib:setVehicleProperties', entityOwner, vehNetId, data)
|
||||
```
|
||||
@@ -1,21 +0,0 @@
|
||||
---
|
||||
title: lib.disableControls
|
||||
---
|
||||
|
||||
```lua
|
||||
lib.disableControls:Add(...)
|
||||
lib.disableControls:Remove(...)
|
||||
lib.disableControls:Clear(...)
|
||||
lib.disableControls()
|
||||
```
|
||||
|
||||
```lua
|
||||
lib.disableControls:Add(23, 25, 36, 263)
|
||||
|
||||
CreateThread(function()
|
||||
while true do
|
||||
Wait(0)
|
||||
lib.disableControls()
|
||||
end
|
||||
end)
|
||||
```
|
||||
@@ -1,14 +0,0 @@
|
||||
---
|
||||
title: lib.callback.await
|
||||
---
|
||||
|
||||
```lua
|
||||
-- name: string
|
||||
-- delay: number or false
|
||||
lib.callback.await(name, delay, ...)
|
||||
```
|
||||
|
||||
```lua
|
||||
local count = lib.callback('ox_inventory:getItemCount', false, 'water', {type = 'fresh'})
|
||||
print(count)
|
||||
```
|
||||
@@ -1,16 +0,0 @@
|
||||
---
|
||||
title: lib.callback
|
||||
---
|
||||
|
||||
```lua
|
||||
-- name: string
|
||||
-- delay: number or false
|
||||
-- cb: function
|
||||
lib.callback(name, delay, cb, ...)
|
||||
```
|
||||
|
||||
```lua
|
||||
lib.callback('ox_inventory:getItemCount', false, function(count)
|
||||
print(count)
|
||||
end, 'water', {type = 'fresh'})
|
||||
```
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
title: Imports
|
||||
---
|
||||
|
||||
These functions are loaded into the environment for the invoking resource.
|
||||
@@ -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')
|
||||
```
|
||||
@@ -1,3 +1,5 @@
|
||||
# Command
|
||||
|
||||
```lua
|
||||
-- principal: string or false
|
||||
-- command: string
|
||||
@@ -5,9 +7,7 @@
|
||||
-- parameters: table (optional)
|
||||
-- help: string (optional)
|
||||
lib.addCommand(principal, command, callback, parameters, help)
|
||||
```
|
||||
|
||||
```lua
|
||||
lib.addCommand('group.admin', {'additem', 'giveitem'}, function(source, args)
|
||||
args.item = Items(args.item)
|
||||
if args.item and args.count > 0 then
|
||||
+2
-6
@@ -1,15 +1,11 @@
|
||||
---
|
||||
id: register
|
||||
title: lib.callback.register
|
||||
---
|
||||
# Callbacks
|
||||
|
||||
### lib.callback.register
|
||||
```lua
|
||||
-- name: string
|
||||
-- cb: function
|
||||
lib.callback.register(name, cb)
|
||||
```
|
||||
|
||||
```lua
|
||||
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
|
||||
@@ -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)
|
||||
@@ -0,0 +1,11 @@
|
||||
# Dependency version
|
||||
|
||||
### lib.checkDependency
|
||||
Check if a resource is using a specified version or higher, allowing for compatibility checks or throwing errors.
|
||||
```lua
|
||||
-- repository: string
|
||||
-- version: string
|
||||
lib.versionCheck(repository, version)
|
||||
|
||||
if not lib.checkDependency('ox_lib', '1.5.0') then error() end
|
||||
```
|
||||
Reference in new issue
Block a user