-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from Mirrrrrow/main
refactor: localized variables, changed a bit of the code structure.
- Loading branch information
Showing
4 changed files
with
143 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.