From 146328ddea5fc8e96a39c8eee2cff9ee4800e9de Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Wed, 5 Feb 2020 11:16:02 +0100 Subject: [PATCH] Implemented only show menu if bills available, closes #25 --- client/main.lua | 46 +++++++++++++++++++++++++--------------------- locales/br.lua | 1 + locales/de.lua | 1 + locales/en.lua | 1 + locales/es.lua | 1 + locales/fi.lua | 1 + locales/fr.lua | 1 + locales/pl.lua | 1 + locales/sv.lua | 9 +++++---- 9 files changed, 37 insertions(+), 25 deletions(-) diff --git a/client/main.lua b/client/main.lua index eb624e21..f9a8e4df 100644 --- a/client/main.lua +++ b/client/main.lua @@ -10,29 +10,33 @@ end) function ShowBillsMenu() ESX.TriggerServerCallback('esx_billing:getBills', function(bills) - ESX.UI.Menu.CloseAll() - local elements = {} + if #bills > 0 then + ESX.UI.Menu.CloseAll() + local elements = {} - for k,v in ipairs(bills) do - table.insert(elements, { - label = ('%s - %s'):format(v.label, _U('invoices_item', ESX.Math.GroupDigits(v.amount))), - billId = v.id - }) + for k,v in ipairs(bills) do + table.insert(elements, { + label = ('%s - %s'):format(v.label, _U('invoices_item', ESX.Math.GroupDigits(v.amount))), + billId = v.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) + else + ESX.ShowNotification(_U('no_invoices')) 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 diff --git a/locales/br.lua b/locales/br.lua index c0b129c1..01825293 100644 --- a/locales/br.lua +++ b/locales/br.lua @@ -3,6 +3,7 @@ Locales['br'] = { ['invoices_item'] = '$%s', ['received_invoice'] = 'você ~r~recebeu~s~ uma fatura', ['paid_invoice'] = 'você ~g~pagou~s~ uma fatura de ~r~$%s~s~', + ['no_invoices'] = 'you do not have any bills to pay at this moment', ['received_payment'] = 'você ~g~recebeu~s~ um pagamento de ~r~$%s~s~', ['player_not_online'] = 'o jogador não está na cidade', ['no_money'] = 'você não tem dinheiro suficiente para pagar esta fatura', diff --git a/locales/de.lua b/locales/de.lua index 3e4eaef1..80991e28 100644 --- a/locales/de.lua +++ b/locales/de.lua @@ -3,6 +3,7 @@ Locales['de'] = { ['invoices_item'] = '$%s', ['received_invoice'] = 'you hast eine Rechnung ~r~erhlaten~s~', ['paid_invoice'] = 'du ~g~bezahlst~s~ eine Rechnung von ~r~$%s~s~', + ['no_invoices'] = 'you do not have any bills to pay at this moment', ['received_payment'] = 'du ~g~erhältst~s~ eine Zahlung von ~r~$%s~s~', ['player_not_online'] = 'der Spieler ist nicht online', ['no_money'] = 'you do not have enough money to pay this bill', diff --git a/locales/en.lua b/locales/en.lua index 2d03ba00..07f47970 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -3,6 +3,7 @@ Locales['en'] = { ['invoices_item'] = '$%s', ['received_invoice'] = 'you have just ~r~received~s~ an invoice', ['paid_invoice'] = 'you ~g~paid~s~ an invoice of ~r~$%s~s~', + ['no_invoices'] = 'you do not have any bills to pay at this moment', ['received_payment'] = 'you ~g~received~s~ a payment of ~r~$%s~s~', ['player_not_online'] = 'the player is not logged in', ['no_money'] = 'you do not have enough money to pay this bill', diff --git a/locales/es.lua b/locales/es.lua index 10788119..8351147b 100644 --- a/locales/es.lua +++ b/locales/es.lua @@ -3,6 +3,7 @@ Locales['es'] = { ['invoices_item'] = '€%s', ['received_invoice'] = 'has ~r~recibido~s~ una multa', ['paid_invoice'] = 'has ~g~pagado~s~ una multa de ~r~€%s~s~', + ['no_invoices'] = 'you do not have any bills to pay at this moment', ['received_payment'] = 'has ~g~recibido~s~ un pago de ~g~€%s~s~', ['player_not_online'] = 'el jugador no está conectado', ['no_money'] = 'you do not have enough money to pay this bill', diff --git a/locales/fi.lua b/locales/fi.lua index 34a45010..4303012d 100644 --- a/locales/fi.lua +++ b/locales/fi.lua @@ -3,6 +3,7 @@ Locales['fi'] = { ['invoices_item'] = '$%s', ['received_invoice'] = 'sinä ~r~sait~s~ laskun', ['paid_invoice'] = 'sinä ~g~maksoit~s~ laskun suuruudelta ~r~$%s~s~', + ['no_invoices'] = 'you do not have any bills to pay at this moment', ['received_payment'] = 'sinä ~g~sait~s~ maksun suuruudelta ~r~$%s~s~', ['player_not_online'] = 'pelaaja ei ole sisäänkirjautuneena', ['no_money'] = 'sinulla ei ole tarpeeksi rahaa maksaaksesi tätä laskua.', diff --git a/locales/fr.lua b/locales/fr.lua index d8e23916..1fbac84d 100644 --- a/locales/fr.lua +++ b/locales/fr.lua @@ -3,6 +3,7 @@ Locales['fr'] = { ['invoices_item'] = '$%s', ['received_invoice'] = 'vous avez ~r~reçu~s~ une facture', ['paid_invoice'] = 'vous avez ~g~payé~s~ une facture de ~r~$%s~s~', + ['no_invoices'] = 'you do not have any bills to pay at this moment', ['received_payment'] = 'vous avez ~g~reçu~s~ un paiement de ~g~$%s~s~', ['player_not_online'] = 'le joueur n\'est pas connecté', ['no_money'] = 'you do not have enough money to pay this bill', diff --git a/locales/pl.lua b/locales/pl.lua index 59cebbff..1275092f 100644 --- a/locales/pl.lua +++ b/locales/pl.lua @@ -3,6 +3,7 @@ Locales['pl'] = { ['invoices_item'] = '$%s', ['received_invoice'] = 'właśnie ~r~dostałeś/aś~s~ fakture', ['paid_invoice'] = '~g~Zapłaciłeś/aś~s~ fakture: ~r~$%s~s~', + ['no_invoices'] = 'you do not have any bills to pay at this moment', ['received_payment'] = '~g~Otrzymałeś/aś~s~ zapłate: ~r~$%s~s~', ['player_not_online'] = 'gracz nie jest zalogowany', ['no_money'] = 'nie masz wystarczająco pieniędzy aby zapłacić tą fakture', diff --git a/locales/sv.lua b/locales/sv.lua index 600246c0..44eb3466 100644 --- a/locales/sv.lua +++ b/locales/sv.lua @@ -3,9 +3,10 @@ Locales['sv'] = { ['invoices_item'] = '%s SEK', ['received_invoice'] = 'du har ~y~mottagit~s~ en räkning', ['paid_invoice'] = 'du ~y~betalade~s~ precis en räkning på ~g~%s SEK~s~', + ['no_invoices'] = 'du har inga inkommande räkningar', ['received_payment'] = 'du har ~y~mottagit~s~ en räkning på ~g~%s SEK~s~', - ['player_not_online'] = 'personen är inte online', - ['no_money'] = 'du har ~r~inte råd~s~ för att kunna betala räkningen', - ['target_no_money'] = 'personen har ~r~inte råd~s~ för att betala räkningen', - ['keymap_showbills'] = 'open bills menu', + ['player_not_online'] = 'spelaren är inte online', + ['no_money'] = 'du har ~r~inte råd~s~ för att betala räkningen', + ['target_no_money'] = 'spelaren har ~r~inte råd~s~ för att betala räkningen', + ['keymap_showbills'] = 'öppna menyn för räkningar', }