mirror of
https://github.com/qbcore-fivem/qb-core.git
synced 2026-08-29 02:01:33 +00:00
Merge branch 'main' into feature/getname
This commit is contained in:
+19
-7
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user