File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change
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
+ end
25
+ end
26
+
27
+ function QBCore .Functions .GetPlayerData (cb )
28
+ if not cb then return QBCore .PlayerData end
29
+ cb (QBCore .PlayerData )
30
+ end
You can’t perform that action at this time.
0 commit comments