-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathlisenceshop.lua
75 lines (65 loc) · 1.7 KB
/
lisenceshop.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.LicenseShop.coords, true) < 5 then
if not menuOpen then
checkjob()
end
--[[else
if wasOpen then
wasOpen = false
ESX.UI.Menu.CloseAll()
end
Citizen.Wait(500)--]]
end
end
end)
function checkjob()
ESX.TriggerServerCallback('esx_illegal:CheckJob', function(cb)
if cb then
ESX.ShowHelpNotification(_U('licenseshop_prompt'))
if IsControlJustReleased(0, Keys['E']) then
wasOpen = true
OpenlicenseShop()
else
Citizen.Wait(500)
end
end
end)
end
function OpenlicenseShop()
ESX.UI.Menu.CloseAll()
local elements = {}
menuOpen = true
for k, v in pairs(ESX.GetPlayerData().inventory) do
local price = Config.Licenses[v.name]
if price and v.count >= 0 then
table.insert(elements, {
label = ('%s - <span style="color:green;">%s</span>'):format("Buy " .. v.label, _U('dealer_item', ESX.Math.GroupDigits(price))),
name = v.name,
price = price,
})
end
end
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'license_shop', {
title = _U('licenseshop_title'),
align = 'top-left',
elements = elements
}, function(data, menu)
TriggerServerEvent('esx_illegal:buyLisense2', data.current.name)
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)