Skip to content

Commit

Permalink
Merge pull request #22 from Mirrrrrow/main
Browse files Browse the repository at this point in the history
refactor: localized variables, changed a bit of the code structure.
  • Loading branch information
Gellipapa authored Jul 26, 2024
2 parents 39b0bb0 + c0e08f5 commit 56d1732
Show file tree
Hide file tree
Showing 4 changed files with 143 additions and 188 deletions.
55 changes: 26 additions & 29 deletions client/main.lua
Original file line number Diff line number Diff line change
@@ -1,45 +1,42 @@
local isDead = false

function ShowBillsMenu()
local function showBillsMenu()
ESX.TriggerServerCallback('esx_billing:getBills', function(bills)
if #bills > 0 then
local elements = {
{unselectable = true, icon = "fas fa-scroll", title = TranslateCap('invoices')}
if #bills <= 0 then return ESX.ShowNotification(TranslateCap('no_invoices')) end

local elements = {
{ unselectable = true, icon = 'fas fa-scroll', title = TranslateCap('invoices') }
}

for _, v in ipairs(bills) do
elements[#elements + 1] = {
icon = 'fas fa-scroll',
title = ('%s - <span style="color:red;">%s</span>'):format(v.label,
TranslateCap('invoices_item', ESX.Math.GroupDigits(v.amount))),
billId = v.id
}

for k,v in ipairs(bills) do
elements[#elements+1] = {
icon = "fas fa-scroll",
title = ('%s - <span style="color:red;">%s</span>'):format(v.label, TranslateCap('invoices_item', ESX.Math.GroupDigits(v.amount))),
billId = v.id
}
end

ESX.OpenContext("right", elements, function(menu,element)
local billId = element.billId

ESX.TriggerServerCallback('esx_billing:payBill', function(resp)
ShowBillsMenu()

if not resp then
return
end
TriggerEvent("esx_billing:paidBill", billId)
end, billId)
end)
else
ESX.ShowNotification(TranslateCap('no_invoices'))
end

ESX.OpenContext('right', elements, function(menu, element)
local billId = element.billId

ESX.TriggerServerCallback('esx_billing:payBill', function(resp)
showBillsMenu()

if not resp then return end
TriggerEvent('esx_billing:paidBill', billId)
end, billId)
end)
end)
end

RegisterCommand('showbills', function()
if not isDead then
ShowBillsMenu()
showBillsMenu()
end
end, false)

RegisterKeyMapping('showbills', TranslateCap('keymap_showbills'), 'keyboard', 'F7')

AddEventHandler('esx:onPlayerDeath', function() isDead = true end)
AddEventHandler('esx:onPlayerSpawn', function(spawn) isDead = false end)
AddEventHandler('esx:onPlayerSpawn', function() isDead = false end)
22 changes: 9 additions & 13 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
fx_version 'adamant'

fx_version 'cerulean'
game 'gta5'
lua54 'yes'

description 'Allows Players to recieve and Send Bills'
lua54 'yes'
version '1.0'

shared_script '@es_extended/imports.lua'
shared_scripts {
'@es_extended/imports.lua',
'@es_extended/locale.lua',
'config.lua',
'locales/*.lua'
}

server_scripts {
'@oxmysql/lib/MySQL.lua',
'@es_extended/locale.lua',
'locales/*.lua',
'config.lua',
'server/main.lua'
}

client_scripts {
'@es_extended/locale.lua',
'locales/*.lua',
'config.lua',
'client/main.lua'
}
client_script 'client/main.lua'

dependency 'es_extended'
10 changes: 5 additions & 5 deletions locales/de.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ Locales['de'] = {
['invoices'] = 'Rechnungen',
['invoices_item'] = '%s€',
['received_invoice'] = 'Du hast eine ~r~Rechnung~r~ erhalten!',
['paid_invoice'] = 'Du bezahlst eine Rechung in der Höhe von ~r~%s€',
['no_invoices'] = 'Du hast derzeit keine Rechnung!',
['received_payment'] = 'Du bekommst eine bezahlung von ~r~%s€',
['paid_invoice'] = 'Du hast eine Rechung in Höhe von ~r~%s€~r~ bezahlt!',
['no_invoices'] = 'Du hast derzeit keine Rechnungen offen!',
['received_payment'] = 'Du hast ~r~%s€~r~ durch eine Rechnung erhalten!',
['player_not_online'] = 'Dieser Spieler ist nicht Online!',
['no_money'] = 'Du hast nicht genügend Geld um diese Rechung zu zahlen',
['target_no_money'] = 'Diese Person ~r~hat nicht genug Geld um die Rechnung zu zahlen!',
['keymap_showbills'] = 'Rechnungen Menü Öffnen',
['target_no_money'] = 'Diese Person hat nicht genug Geld um die Rechnung zu zahlen!',
['keymap_showbills'] = 'Rechnungs Menü Öffnen',
}
Loading

0 comments on commit 56d1732

Please sign in to comment.