mirror of
https://github.com/jimathy/jim_bridge.git
synced 2026-08-17 05:56:02 +01:00
better documentation layout
- seperated the 2000+ lines in ReadMe.md into seperate files. - useful if things expand - better readability for users - more organised layout
This commit is contained in:
38
documentation/main_functions/callbacks.md
Normal file
38
documentation/main_functions/callbacks.md
Normal file
@@ -0,0 +1,38 @@
|
||||
### callback.lua
|
||||
|
||||
These functions wrap the native callback handling of the selected framework (e.g., OX, QBCore, ESX) instead of implementing a standalone callback system, ensuring full compatibility.
|
||||
|
||||
- **createCallback(callbackName, funct)**
|
||||
|
||||
- Registers a callback function with the appropriate framework.
|
||||
- This function checks which framework is started (e.g., OX, QB, ESX) and registers the callback accordingly.
|
||||
- It adapts the callback function to match the expected signature for the framework.
|
||||
- **Example:**
|
||||
```lua
|
||||
local table = { ["info"] = "HI" }
|
||||
createCallback('myCallback', function(source, ...)
|
||||
return table
|
||||
end)
|
||||
|
||||
createCallback("callback:checkVehicleOwned", function(source, plate)
|
||||
local result = isVehicleOwned(plate)
|
||||
if result then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end)
|
||||
```
|
||||
|
||||
- **triggerCallback(callbackName, ...)**
|
||||
|
||||
- Triggers a server callback and returns the result.
|
||||
- This function uses the appropriate framework's method to call the server-side callback and awaits the result.
|
||||
- **Example:**
|
||||
```lua
|
||||
local result = triggerCallback('myCallback')
|
||||
jsonPrint(result)
|
||||
|
||||
local result = triggerCallback("callback:checkVehicleOwned", plate)
|
||||
print(result)
|
||||
```
|
||||
Reference in New Issue
Block a user