Fixed negative bills

This commit is contained in:
ElPumpo
2018-02-22 16:57:43 +01:00
parent bfed8a8f06
commit d052d98042
6 changed files with 36 additions and 34 deletions
+17 -22
View File
@@ -163,30 +163,25 @@ ESX.RegisterServerCallback('esx_billing:payBill', function(source, cb, id)
end
else
TriggerEvent('esx_addonaccount:getSharedAccount', target, function(account)
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 foundPlayer ~= nil then
TriggerClientEvent('esx:showNotification', foundPlayer.source, _U('received_payment') .. amount)
end
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 foundPlayer ~= nil then
TriggerClientEvent('esx:showNotification', foundPlayer.source, _U('received_payment') .. amount)
end
cb()
end
)
end)
else
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('no_money'))
end
end)
end