-
Notifications
You must be signed in to change notification settings - Fork 9
/
client.lua
154 lines (146 loc) · 4.91 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
local QBCore = exports['qb-core']:GetCoreObject()
-- Functions
local function comma_value(amount)
local formatted = amount
while true do
formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
if (k == 0) then
break
end
end
return formatted
end
local function RegisterBusiness()
QBCore.Functions.TriggerCallback('qb-laundering:server:getBusiness', function(business)
if business then
exports['qb-menu']:openMenu({
{ header = business.business..' | Value: $'..comma_value(business.worth), isMenuHeader = true},
{
header = 'Invest',
params = {
event = 'qb-laundering:client:invest',
args = {}
}
},
{
header = 'Sell',
params = {
isServer = true,
event = 'qb-laundering:server:sell',
args = {}
}
}
})
else
local dialog = exports['qb-input']:ShowInput({
header = 'Register LLC',
submitText = 'Submit',
inputs = {
{
type = 'text',
isRequired = true,
name = 'name',
text = 'Business Name'
},
{
type = 'number',
isRequired = true,
name = 'amount',
text = 'Minimum $'..Config.StartupFee
}
}
})
if dialog then
if not dialog.name then return end
if not dialog.amount then return end
if tonumber(dialog.amount) < Config.StartupFee then return QBCore.Functions.Notify('Didn\'t meet minimum', 'error') end
TriggerServerEvent('qb-laundering:server:register', dialog.name, dialog.amount)
end
end
end)
end
local function CleanMoney()
QBCore.Functions.TriggerCallback('qb-laundering:server:getBusiness', function(business)
if business then
local dialog = exports['qb-input']:ShowInput({
header = 'Wash Money',
submitText = 'Submit',
inputs = {
{
type = 'number',
isRequired = true,
name = 'amount',
text = 'Maximum $'..business.worth
}
}
})
if dialog then
if not dialog.amount then return end
if tonumber(dialog.amount) > business.worth then return QBCore.Functions.Notify('Can\'t clean that much', 'error') end
TriggerServerEvent('qb-laundering:server:clean', dialog.amount)
end
end
end)
end
-- Events
RegisterNetEvent('qb-laundering:client:invest', function()
local dialog = exports['qb-input']:ShowInput({
header = 'Investment Amount',
submitText = 'Submit',
inputs = {
{
type = 'number',
isRequired = true,
name = 'amount',
text = 'Amount ($)'
}
}
})
if dialog then
if not dialog.amount then return end
TriggerServerEvent('qb-laundering:server:invest', dialog.amount)
end
end)
-- Threads
CreateThread(function()
for k,v in pairs(Config.Locations) do
if k == 'cityhall' then
exports['qb-target']:AddBoxZone(v.name, v.coords, v.length, v.width, {
name = v.name,
debugPoly = v.debugPoly,
minZ = v.coords.z - 2,
maxZ = v.coords.z + 2,
}, {
options = {
{
icon = 'fa-solid fa-briefcase',
label = 'Register/Manage LLC',
action = function ()
RegisterBusiness()
end
},
},
distance = 1.5
})
end
if k == 'washing' then
exports['qb-target']:AddBoxZone(v.name, v.coords, v.length, v.width, {
name = v.name,
debugPoly = v.debugPoly,
minZ = v.coords.z - 2,
maxZ = v.coords.z + 2,
}, {
options = {
{
icon = 'fa-solid fa-sack-dollar',
label = 'Clean Money',
action = function ()
CleanMoney()
end
},
},
distance = 1.5
})
end
end
end)