mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-30 06:01:30 +00:00
59 lines
1.3 KiB
Lua
59 lines
1.3 KiB
Lua
ESX = nil
|
|
local isDead = false
|
|
|
|
Citizen.CreateThread(function()
|
|
while ESX == nil do
|
|
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
|
|
Citizen.Wait(0)
|
|
end
|
|
end)
|
|
|
|
function ShowBillsMenu()
|
|
|
|
ESX.TriggerServerCallback('esx_billing:getBills', function(bills)
|
|
ESX.UI.Menu.CloseAll()
|
|
local elements = {}
|
|
|
|
for i=1, #bills, 1 do
|
|
table.insert(elements, {
|
|
label = ('%s - <span style="color:red;">%s</span>'):format(bills[i].label, _U('invoices_item', ESX.Math.GroupDigits(bills[i].amount))),
|
|
billID = bills[i].id
|
|
})
|
|
end
|
|
|
|
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'billing',
|
|
{
|
|
title = _U('invoices'),
|
|
align = 'bottom-right',
|
|
elements = elements
|
|
}, function(data, menu)
|
|
menu.close()
|
|
|
|
ESX.TriggerServerCallback('esx_billing:payBill', function()
|
|
ShowBillsMenu()
|
|
end, data.current.billID)
|
|
end, function(data, menu)
|
|
menu.close()
|
|
end)
|
|
end)
|
|
|
|
end
|
|
|
|
-- Key controls
|
|
Citizen.CreateThread(function()
|
|
while true do
|
|
Citizen.Wait(0)
|
|
if IsControlJustReleased(0, 168) and not isDead and not ESX.UI.Menu.IsOpen('default', GetCurrentResourceName(), 'billing') then
|
|
ShowBillsMenu()
|
|
end
|
|
end
|
|
end)
|
|
|
|
AddEventHandler('esx:onPlayerDeath', function(data)
|
|
isDead = true
|
|
end)
|
|
|
|
AddEventHandler('playerSpawned', function(spawn)
|
|
isDead = false
|
|
end)
|