-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.lua
More file actions
55 lines (43 loc) · 1.31 KB
/
client.lua
File metadata and controls
55 lines (43 loc) · 1.31 KB
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
46
47
48
49
50
51
52
53
54
55
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 = 'paymentMethod:setPrice',
data = price
})
return Citizen.Await(currentPaymentMethod)
end
RegisterNUICallback('init', function(_, cb)
cb('ok')
SendNUIMessage({
action = 'setLocale',
data = {
ui = Config.locales
}
})
end)
RegisterNUICallback('paymentMethod:close', function(_, cb)
cb('ok')
if not currentPaymentMethod then return warn('Payment method window is not open!') end
SetNuiFocus(false, false)
SendNUIMessage({
action = 'paymentMethod:setPrice',
data = nil
})
currentPaymentMethod:resolve(false)
currentPaymentMethod = nil
end)
RegisterNUICallback('paymentMethod:select', function(method, cb)
cb('ok')
if not currentPaymentMethod then return warn('Payment method window is not open!') end
SetNuiFocus(false, false)
SendNUIMessage({
action = 'paymentMethod:setPrice',
data = nil
})
currentPaymentMethod:resolve(method)
currentPaymentMethod = nil
end)
exports('requestPaymentMethod', requestPaymentMethod)