This repository has been archived by the owner on Aug 30, 2023. It is now read-only.
forked from yagizher/orp-banking
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclient.lua
128 lines (109 loc) · 2.53 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
-- TODO: Multiple UI colors (Fleeca, Lombank, Maze bank)
local uiOpened = false
local isInBank = false
local OpenBank = function(bank)
ESX.TriggerServerCallback('orp_banking:getBalance', function(balance)
uiOpened = true
isInBank = bank == true
SetNuiFocus(true, true)
SendNUIMessage({
type = 'openBank',
balance = balance,
isInBank = isInBank
})
if not isInBank then
SendNotify('Please note that you can only deposit money at bank', 'inform')
end
end)
end
local CloseBank = function()
uiOpened = false
SetNuiFocus(false, false)
end
local currentResource = GetCurrentResourceName()
AddEventHandler('onResourceStop', function(resource)
if resource == currentResource then CloseBank() end
end)
-- NUI callbacks
RegisterNUICallback('closeMenu', CloseBank)
RegisterNetEvent('orp_banking:update', function(balance)
if uiOpened then
SendNUIMessage({
type = 'updateBalance',
balance = balance
})
end
end)
RegisterNUICallback('deposit', function(data)
if isInBank then
TriggerServerEvent('orp_banking:deposit', data)
else
SendNotify('You cannot deposit money at an ATM', 'error')
end
end)
RegisterNUICallback('withdraw', function(data)
TriggerServerEvent('orp_banking:withdraw', data)
end)
RegisterNUICallback('transfer', function(data)
TriggerServerEvent('orp_banking:transfer', data)
end)
-- qtarget stuff
exports.qtarget:AddTargetModel(Config.ATMProps, {
options = {{
icon = 'fas fa-credit-card',
label = 'Use ATM',
action = OpenBank
}},
distance = 1.5
})
exports.qtarget:AddBoxZone('ATM_L', vec3(147.49, -1036.18, 29.34), 0.4, 1.3,
{
name = 'ATM_L',
heading = 340.0,
minZ = 28.69,
maxZ = 30.64
},
{
options = {{
icon = 'fas fa-credit-card',
label = 'Use ATM',
action = OpenBank
}},
distance = 1.5
}
)
exports.qtarget:AddBoxZone('ATM_R', vec3(145.85, -1035.61, 29.34), 0.4, 1.3,
{
name = 'ATM_R',
heading = 340.0,
minZ = 28.69,
maxZ = 30.64
}, {
options = {{
icon = 'fas fa-credit-card',
label = 'Use ATM',
action = OpenBank
}},
distance = 1.5
}
)
for k,v in pairs(Config.BankZones) do
local name = ('Bank_%s'):format(k)
exports.qtarget:AddBoxZone(name, v.pos, v.length, v.width,
{
name = name,
heading = v.h,
minZ = v.minZ,
maxZ = v.maxZ
}, {
options = {{
icon = 'fas fa-money-bill-wave',
label = 'Access bank account',
action = function()
OpenBank(true)
end
}},
distance = 2.0
}
)
end