fix createCallback complaining on client side

This commit is contained in:
Jim Shield
2025-03-07 13:29:43 +00:00
committed by GitHub
parent c947993e9e
commit daa9dca142

View File

@@ -13,21 +13,23 @@
--- end)
--- ```
function createCallback(callbackName, funct)
if isStarted(OXLibExport) then
lib.callback.register(callbackName, funct)
else
local adaptedFunction = function(source, cb, ...)
local result = funct(source, ...)
cb(result)
end
if isStarted(QBExport) then
Core = Core or exports[QBExport]:GetCoreObject()
Core.Functions.CreateCallback(callbackName, adaptedFunction)
elseif isStarted(ESXExport) then
ESX.RegisterServerCallback(callbackName, adaptedFunction)
if isServer() then
if isStarted(OXLibExport) then
lib.callback.register(callbackName, funct)
else
print("^6Bridge^7: ^1ERROR^7: ^3Can't find any script to register callback with", callbackName)
local adaptedFunction = function(source, cb, ...)
local result = funct(source, ...)
cb(result)
end
if isStarted(QBExport) then
Core = Core or exports[QBExport]:GetCoreObject()
Core.Functions.CreateCallback(callbackName, adaptedFunction)
elseif isStarted(ESXExport) then
ESX.RegisterServerCallback(callbackName, adaptedFunction)
else
print("^6Bridge^7: ^1ERROR^7: ^3Can't find any script to register callback with", callbackName)
end
end
end
end