mirror of
https://github.com/darksaid98/overextended.github.io.git
synced 2026-12-01 22:21:48 +00:00
* oxmysql and some lib interface fixes - Various fixes throughout oxmysql - started ox_lib audit * chore: More clean up - Reword some confusing descriptions - Add some descriptions - Type fixes - Spelling and grammar fixes - Swapping in `-` where `*` used to be for bullet point consistency ox_lib - Interface, ACL through GetClosestVehicle audited * chore: Finishing up ox_lib
60 lines
1.2 KiB
Plaintext
60 lines
1.2 KiB
Plaintext
## Trigger Server Callback
|
|
|
|
### lib.callback
|
|
|
|
The response is handled in a separate coroutine.
|
|
|
|
```lua
|
|
lib.callback(name, delay, cb, ...)
|
|
```
|
|
|
|
- name: `string`
|
|
- delay: `number` or `false`
|
|
- Amount of time until this callback can be triggered again
|
|
- cb: `function`
|
|
- ...: `any`
|
|
|
|
```lua
|
|
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
|
|
lib.callback.await(name, delay, ...)
|
|
```
|
|
|
|
- name: `string`
|
|
- delay: `number` or `false`
|
|
- Amount of time until this callback can be triggered again
|
|
- ...: `any`
|
|
|
|
```lua
|
|
local count = lib.callback.await('ox_inventory:getItemCount', false, 'water', {type = 'fresh'})
|
|
print(count)
|
|
```
|
|
|
|
## Register Client Callback
|
|
|
|
### lib.callback.register
|
|
|
|
Register an event handler for responding to server requests.
|
|
|
|
```lua
|
|
lib.callback.register(name, cb)
|
|
```
|
|
|
|
- name: `string`
|
|
- cb: `function`
|
|
|
|
```lua
|
|
lib.callback.register('ox:getNearbyVehicles', function(radius)
|
|
local nearbyVehicles = lib.getNearbyVehicles(GetEntityCoords(cache.ped), radius, true)
|
|
return nearbyVehicles
|
|
end)
|
|
```
|