mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-31 10:18:54 +00:00
Implemented paying with bank balance, cleanup
This commit is contained in:
+2
-2
@@ -36,7 +36,7 @@ function ShowBillsMenu()
|
||||
'default', GetCurrentResourceName(), 'billing',
|
||||
{
|
||||
title = _U('invoices'),
|
||||
align = 'bottom-right',
|
||||
align = 'bottom-right',
|
||||
elements = elements
|
||||
},
|
||||
function(data, menu)
|
||||
@@ -63,7 +63,7 @@ end
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
Citizen.Wait(10)
|
||||
if IsControlJustReleased(0, Keys["F7"]) and not isDead and not ESX.UI.Menu.IsOpen('default', GetCurrentResourceName(), 'billing') then
|
||||
if IsControlJustReleased(0, Keys['F7']) and not isDead and not ESX.UI.Menu.IsOpen('default', GetCurrentResourceName(), 'billing') then
|
||||
ShowBillsMenu()
|
||||
end
|
||||
end
|
||||
|
||||
+7
-5
@@ -1,7 +1,9 @@
|
||||
Locales['br'] = {
|
||||
['invoices'] = 'Faturas',
|
||||
['received_invoice'] = 'Você ~r~recebeu~s~ uma fatura',
|
||||
['paid_invoice'] = 'Você ~g~pagou~s~ uma fatura de ~r~$%s~s~',
|
||||
['received_payment'] = 'Você ~g~recebeu~s~ um pagamento de ~r~$%s~s~',
|
||||
['player_not_logged'] = 'O jogador não está logado',
|
||||
['invoices'] = 'faturas',
|
||||
['received_invoice'] = 'você ~r~recebeu~s~ uma fatura',
|
||||
['paid_invoice'] = 'você ~g~pagou~s~ uma fatura de ~r~$%s~s~',
|
||||
['received_payment'] = 'você ~g~recebeu~s~ um pagamento de ~r~$%s~s~',
|
||||
['player_not_online'] = 'o jogador não está logado',
|
||||
['no_money'] = 'you do not have enough money to pay this bill',
|
||||
['target_no_money'] = 'the player ~r~does not~s~ have enough money to pay the bill!',
|
||||
}
|
||||
|
||||
+4
-2
@@ -1,7 +1,9 @@
|
||||
Locales['de'] = {
|
||||
['invoices'] = 'Rechnungen',
|
||||
['invoices'] = 'rechnungen',
|
||||
['received_invoice'] = 'you hast eine Rechnung ~r~erhlaten~s~',
|
||||
['paid_invoice'] = 'du ~g~bezahlst~s~ eine Rechnung von ~r~$%s~s~',
|
||||
['received_payment'] = 'du ~g~erhältst~s~ eine Zahlung von ~r~$%s~s~',
|
||||
['player_not_logged'] = 'der Spieler ist nicht online',
|
||||
['player_not_online'] = 'der Spieler ist nicht online',
|
||||
['no_money'] = 'you do not have enough money to pay this bill',
|
||||
['target_no_money'] = 'the player ~r~does not~s~ have enough money to pay the bill!',
|
||||
}
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@ Locales['en'] = {
|
||||
['received_invoice'] = 'you have just ~r~received~s~ an invoice',
|
||||
['paid_invoice'] = 'you ~g~paid~s~ an invoice of ~r~$%s~s~',
|
||||
['received_payment'] = 'you ~g~received~s~ a payment of ~r~$%s~s~',
|
||||
['player_not_logged'] = 'the player is not logged in',
|
||||
['player_not_online'] = 'the player is not logged in',
|
||||
['no_money'] = 'you do not have enough money to pay this bill',
|
||||
['target_no_money'] = 'the player ~r~does not~w~ have enough money to pay the bill!',
|
||||
['target_no_money'] = 'the player ~r~does not~s~ have enough money to pay the bill!',
|
||||
}
|
||||
|
||||
+7
-5
@@ -1,7 +1,9 @@
|
||||
Locales['es'] = {
|
||||
['invoices'] = 'Facturas',
|
||||
['received_invoice'] = 'Has ~r~recibido~s~ una multa',
|
||||
['paid_invoice'] = 'Has ~g~pagado~s~ una multa de ~r~€%s~s~',
|
||||
['received_payment'] = 'Has ~g~recibido~s~ un pago de ~g~€%s~s~',
|
||||
['player_not_logged'] = 'El jugador no está conectado',
|
||||
['invoices'] = 'facturas',
|
||||
['received_invoice'] = 'has ~r~recibido~s~ una multa',
|
||||
['paid_invoice'] = 'has ~g~pagado~s~ una multa de ~r~€%s~s~',
|
||||
['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',
|
||||
['target_no_money'] = 'the player ~r~does not~s~ have enough money to pay the bill!',
|
||||
}
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ Locales['fi'] = {
|
||||
['received_invoice'] = 'sinä ~r~sait~s~ laskun',
|
||||
['paid_invoice'] = 'sinä ~g~maksoit~s~ laskun suuruudelta ~r~$%s~s~',
|
||||
['received_payment'] = 'sinä ~g~sait~s~ maksun suuruudelta ~r~$%s~s~',
|
||||
['player_not_logged'] = 'pelaaja ei ole sisäänkirjautuneena',
|
||||
['player_not_online'] = 'pelaaja ei ole sisäänkirjautuneena',
|
||||
['no_money'] = 'sinulla ei ole tarpeeksi rahaa maksaaksesi tätä laskua.',
|
||||
['target_no_money'] = 'pelaajalla ~r~ei ole~w~ tarpeeksi rahaa maksaakseentätä laskua',
|
||||
}
|
||||
|
||||
+3
-1
@@ -3,5 +3,7 @@ Locales['fr'] = {
|
||||
['received_invoice'] = 'vous avez ~r~reçu~s~ une facture',
|
||||
['paid_invoice'] = 'vous avez ~g~payé~s~ une facture de ~r~$%s~s~',
|
||||
['received_payment'] = 'vous avez ~g~reçu~s~ un paiement de ~g~$%s~s~',
|
||||
['player_not_logged'] = 'le joueur n\'est pas connecté',
|
||||
['player_not_online'] = 'le joueur n\'est pas connecté',
|
||||
['no_money'] = 'you do not have enough money to pay this bill',
|
||||
['target_no_money'] = 'the player ~r~does not~s~ have enough money to pay the bill!',
|
||||
}
|
||||
|
||||
+5
-5
@@ -1,9 +1,9 @@
|
||||
Locales['sv'] = {
|
||||
['invoices'] = 'räkningar',
|
||||
['received_invoice'] = 'du har ~y~mottagit~s~ en räkning',
|
||||
['paid_invoice'] = 'du ~y~betalade~w~ precis en räkning på ~g~$%s~s~',
|
||||
['received_payment'] = 'du har ~y~mottagit~w~ en räkning på ~g~$%s~s~',
|
||||
['player_not_logged'] = 'spelaren är inte online',
|
||||
['no_money'] = 'du har ~r~inte råd~w~ för att kunna betala räkningen',
|
||||
['target_no_money'] = 'Spelaren har ~r~inte råd~w~ för att betala räkningen',
|
||||
['paid_invoice'] = 'du ~y~betalade~s~ precis en räkning på ~g~$%s~s~',
|
||||
['received_payment'] = 'du har ~y~mottagit~s~ en räkning på ~g~$%s~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',
|
||||
}
|
||||
|
||||
+73
-35
@@ -94,13 +94,12 @@ ESX.RegisterServerCallback('esx_billing:payBill', function(source, cb, id)
|
||||
'SELECT * FROM billing WHERE id = @id',
|
||||
{
|
||||
['@id'] = id
|
||||
},
|
||||
function(result)
|
||||
}, function(result)
|
||||
|
||||
local sender = result[1].sender
|
||||
local targetType = result[1].target_type
|
||||
local target = result[1].target
|
||||
local amount = result[1].amount
|
||||
local sender = result[1].sender
|
||||
local targetType = result[1].target_type
|
||||
local target = result[1].target
|
||||
local amount = result[1].amount
|
||||
|
||||
local xTarget = ESX.GetPlayerFromIdentifier(sender)
|
||||
|
||||
@@ -108,55 +107,94 @@ ESX.RegisterServerCallback('esx_billing:payBill', function(source, cb, id)
|
||||
|
||||
if xTarget ~= nil then
|
||||
|
||||
if xPlayer.get('money') >= amount then
|
||||
if xPlayer.getMoney() >= amount then
|
||||
|
||||
MySQL.Async.execute(
|
||||
'DELETE from billing WHERE id = @id',
|
||||
{
|
||||
['@id'] = id
|
||||
},
|
||||
function(rowsChanged)
|
||||
MySQL.Async.execute('DELETE from billing WHERE id = @id',
|
||||
{
|
||||
['@id'] = id
|
||||
}, function(rowsChanged)
|
||||
xPlayer.removeMoney(amount)
|
||||
xTarget.addMoney(amount)
|
||||
|
||||
xPlayer.removeMoney(amount)
|
||||
xTarget.addMoney(amount)
|
||||
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('paid_invoice', amount))
|
||||
TriggerClientEvent('esx:showNotification', xTarget.source, _U('received_payment', amount))
|
||||
|
||||
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('paid_invoice', amount))
|
||||
TriggerClientEvent('esx:showNotification', xTarget.source, _U('received_payment', amount))
|
||||
cb()
|
||||
end)
|
||||
|
||||
cb()
|
||||
elseif xPlayer.getBank() >= amount then
|
||||
|
||||
end
|
||||
)
|
||||
MySQL.Async.execute('DELETE from billing WHERE id = @id',
|
||||
{
|
||||
['@id'] = id
|
||||
}, function(rowsChanged)
|
||||
xPlayer.removeAccountMoney('bank', amount)
|
||||
xTarget.addAccountMoney('bank', amount)
|
||||
|
||||
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('paid_invoice', amount))
|
||||
TriggerClientEvent('esx:showNotification', xTarget.source, _U('received_payment', amount))
|
||||
|
||||
cb()
|
||||
end)
|
||||
|
||||
else
|
||||
TriggerClientEvent('esx:showNotification', source, _U('player_not_logged'))
|
||||
TriggerClientEvent('esx:showNotification', xTarget.source, _U('target_no_money'))
|
||||
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('no_money'))
|
||||
|
||||
cb()
|
||||
end
|
||||
|
||||
else
|
||||
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('player_not_online'))
|
||||
cb()
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
TriggerEvent('esx_addonaccount:getSharedAccount', target, function(account)
|
||||
if xPlayer.get('money') >= amount then
|
||||
MySQL.Async.execute(
|
||||
'DELETE from billing WHERE id = @id',
|
||||
{
|
||||
['@id'] = id
|
||||
},
|
||||
function(rowsChanged)
|
||||
xPlayer.removeMoney(amount)
|
||||
account.addMoney(amount)
|
||||
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('paid_invoice', amount))
|
||||
if xTarget ~= nil then
|
||||
TriggerClientEvent('esx:showNotification', xTarget.source, _U('received_payment', amount))
|
||||
end
|
||||
|
||||
if xPlayer.getMoney() >= amount then
|
||||
|
||||
MySQL.Async.execute('DELETE from billing WHERE id = @id',
|
||||
{
|
||||
['@id'] = id
|
||||
}, function(rowsChanged)
|
||||
xPlayer.removeMoney(amount)
|
||||
account.addMoney(amount)
|
||||
|
||||
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('paid_invoice', amount))
|
||||
if xTarget ~= nil then
|
||||
TriggerClientEvent('esx:showNotification', xTarget.source, _U('received_payment', amount))
|
||||
end
|
||||
|
||||
cb()
|
||||
end)
|
||||
|
||||
elseif xPlayer.getBank() >= amount then
|
||||
|
||||
MySQL.Async.execute('DELETE from billing WHERE id = @id',
|
||||
{
|
||||
['@id'] = id
|
||||
}, function(rowsChanged)
|
||||
xPlayer.removeAccountMoney('bank', amount)
|
||||
account.addMoney(amount)
|
||||
|
||||
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('paid_invoice', amount))
|
||||
if xTarget ~= nil then
|
||||
TriggerClientEvent('esx:showNotification', xTarget.source, _U('received_payment', amount))
|
||||
end
|
||||
|
||||
cb()
|
||||
end)
|
||||
|
||||
else
|
||||
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('no_money'))
|
||||
|
||||
if xTarget ~= nil then
|
||||
TriggerClientEvent('esx:showNotification', xTarget.source, _U('target_no_money'))
|
||||
end
|
||||
|
||||
cb()
|
||||
end
|
||||
end)
|
||||
|
||||
@@ -165,4 +203,4 @@ ESX.RegisterServerCallback('esx_billing:payBill', function(source, cb, id)
|
||||
end
|
||||
)
|
||||
|
||||
end)
|
||||
end)
|
||||
Reference in New Issue
Block a user