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)
|
||||
```
|
||||
Reference in new issue
Block a user