-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added documentation for clientcallbacks
- Loading branch information
1 parent
7df05b3
commit 01e5be1
Showing
2 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# RegisterClientCallback | ||
|
||
```lua | ||
ESX.RegisterClientCallback(name, handler) | ||
``` | ||
|
||
This function registers a client callback, which is used for sending Client Data, to the Server. | ||
|
||
## Arguments | ||
|
||
| Argument | Data Type | Optional | Default Value | Explaination | | ||
| -------- | --------- | -------- | ------------- | ---------------------------------------------------------------------------------------------------------------- | | ||
| name | string | No | - | Client callback name | | ||
| cb | function | No | - | Callback function, which contains an varied size of arguments depending on how many arguments parsed from client | | ||
| ...args | any | No | - | The args provided after the handler on the client TriggerClientCallback | | ||
|
||
## Example | ||
|
||
```lua | ||
local myVariable = 'hello' | ||
|
||
ESX.RegisterClientCallback('esx_example:test', function(cb, myArgument) | ||
print(myArgument) | ||
print('this code is an asynchronous task') | ||
cb(myVariable) | ||
end) | ||
|
||
print('this code is running in sync') | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# TriggerClientCallback | ||
|
||
```lua | ||
ESX.TriggerClientCallback(name, source, cb, ...args) | ||
``` | ||
|
||
This function triggers a client callback. See [ESX.RegisterClientCallback](./../../client/functions/registerclientcallback) on registering client callbacks. | ||
|
||
## Arguments | ||
|
||
| Argument | Data Type | Optional | Default Value | Explaination | | ||
| -------- | --------- | -------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| name | string | No | - | A valid client callback name | | ||
| source | number | No | - | The source of the player to trigger the callback on | | ||
| cb | function | No | - | The returned function when the async task has completed. The invoked function a varied size of arguments depending on how many arguments are parsed from the client | | ||
| args | any | Yes | - | Any arguments to parse to the async function | | ||
|
||
## Example | ||
|
||
```lua | ||
local myArgument = 'hello' | ||
|
||
ESX.TriggerClientCallback('esx_example:test', source, function(isBusy, numKills) | ||
print(isBusy, numKills) | ||
print('this code is an asynchronous task') | ||
end, myArgument) | ||
|
||
print('this code is running in sync') | ||
``` |