-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.lua
45 lines (33 loc) · 1.1 KB
/
client.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
local currentPaymentMethod
local function requestPaymentMethod(price)
if currentPaymentMethod then return warn('Payment method window is already open!') end
currentPaymentMethod = promise.new()
SetNuiFocus(true, true)
SendNUIMessage({
action = 'setPaymentPrice',
data = price
})
return Citizen.Await(currentPaymentMethod)
end
RegisterNUICallback('init', function(_, cb)
cb('ok')
SendNUIMessage({
action = 'setConfiguration',
data = Config.locales
})
end)
RegisterNUICallback('cancelPayment', function(_, cb)
cb('ok')
if not currentPaymentMethod then return warn('Payment method window is not open!') end
SetNuiFocus(false, false)
currentPaymentMethod:resolve(false)
currentPaymentMethod = nil
end)
RegisterNUICallback('selectPaymentMethod', function(method, cb)
cb('ok')
if not currentPaymentMethod then return warn('Payment method window is not open!') end
SetNuiFocus(false, false)
currentPaymentMethod:resolve(method)
currentPaymentMethod = nil
end)
exports('requestPaymentMethod', requestPaymentMethod)