Merge branch 'main' into feature/getname

This commit is contained in:
Cocodrulo
2025-01-08 21:09:08 +01:00
committed by GitHub
5 changed files with 68 additions and 26 deletions
+19 -7
View File
@@ -6,14 +6,26 @@ function QBCore.Functions.CreateClientCallback(name, cb)
QBCore.ClientCallbacks[name] = cb
end
function QBCore.Functions.TriggerClientCallback(name, cb, ...)
if not QBCore.ClientCallbacks[name] then return end
QBCore.ClientCallbacks[name](cb, ...)
end
function QBCore.Functions.TriggerCallback(name, ...)
local cb = nil
local args = { ... }
function QBCore.Functions.TriggerCallback(name, cb, ...)
QBCore.ServerCallbacks[name] = cb
TriggerServerEvent('QBCore:Server:TriggerCallback', name, ...)
if QBCore.Shared.IsFunction(args[1]) then
cb = args[1]
table.remove(args, 1)
end
QBCore.ServerCallbacks[name] = {
callback = cb,
promise = promise.new()
}
TriggerServerEvent('QBCore:Server:TriggerCallback', name, table.unpack(args))
if cb == nil then
Citizen.Await(QBCore.ServerCallbacks[name].promise)
return QBCore.ServerCallbacks[name].promise.value
end
end
function QBCore.Debug(resource, obj, depth)