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 - %s'):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)