-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathmoneywash.lua
75 lines (66 loc) · 1.63 KB
/
moneywash.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
local menuOpen = false
local wasOpen = false
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
local playerPed = PlayerPedId()
local coords = GetEntityCoords(playerPed)
if GetDistanceBetweenCoords(coords, Config.CircleZones.MoneyWash.coords, true) < 5 then
if not menuOpen then
ESX.ShowHelpNotification(_U('moneywash_prompt'))
if IsControlJustReleased(0, Keys['E']) then
if Config.MoneyWashLicenseEnabled then
CheckMoneyWashLicense()
else
wasOpen = true
OpenMoneyWash()
end
end
else
Citizen.Wait(500)
end
--[[else
if wasOpen then
wasOpen = false
ESX.UI.Menu.CloseAll()
end
Citizen.Wait(500)--]]
end
end
end)
function CheckMoneyWashLicense()
ESX.TriggerServerCallback('esx_illegal:CheckMoneyWashLicense', function(cb)
if cb then
wasOpen = true
OpenMoneyWash()
else
ESX.ShowNotification(_U('need_license'))
end
end)
end
function OpenMoneyWash()
ESX.UI.Menu.CloseAll()
local elements = {
{label = _U('moneywash_wash'), value = 'moneywash_wash'}
}
menuOpen = true
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'drug_shop', {
title = _U('moneywash_title'),
align = 'top-left',
elements = elements
}, function(data, menu)
if data.current.value == 'moneywash_wash' then
TriggerServerEvent('esx_illegal:Wash')
end
end, function(data, menu)
menu.close()
menuOpen = false
end)
end
AddEventHandler('onResourceStop', function(resource)
if resource == GetCurrentResourceName() then
if menuOpen then
ESX.UI.Menu.CloseAll()
end
end
end)