mirror of
https://github.com/darksaid98/overextended.github.io.git
synced 2026-12-02 22:22:46 +00:00
new docs
This commit is contained in:
1 parent
3cebaf7fa5
commit
b5eba8423f
229 files changed
+6238
-10690
No files matched your search
@@ -0,0 +1,57 @@
|
||||
## 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`
|
||||
- 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`
|
||||
- ...: `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)
|
||||
```
|
||||
Reference in new issue
Block a user