We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 11052e2 commit e8dc8f8Copy full SHA for e8dc8f8
client/functions.lua
@@ -0,0 +1,30 @@
1
+-- Callbacks
2
+
3
+function QBCore.Functions.CreateClientCallback(name, cb)
4
+ QBCore.ClientCallbacks[name] = cb
5
+end
6
7
+function QBCore.Functions.TriggerCallback(name, ...)
8
+ local cb = nil
9
+ local args = { ... }
10
11
+ if QBCore.Functions.IsFunction(args[1]) then
12
+ cb = args[1]
13
+ table.remove(args, 1)
14
+ end
15
16
+ QBCore.ServerCallbacks[name] = {
17
+ callback = cb,
18
+ promise = promise.new()
19
+ }
20
+ TriggerServerEvent('QBCore:Server:TriggerCallback', name, table.unpack(args))
21
+ if cb == nil then
22
+ Citizen.Await(QBCore.ServerCallbacks[name].promise)
23
+ return QBCore.ServerCallbacks[name].promise.value
24
25
26
27
+function QBCore.Functions.GetPlayerData(cb)
28
+ if not cb then return QBCore.PlayerData end
29
+ cb(QBCore.PlayerData)
30
0 commit comments