Fixed paying rent with latest ESX accounts, added automatic removal if cannot afford

This commit is contained in:
ElPumpo
2020-03-31 12:28:57 +02:00
parent 6b75c157c0
commit 2855a34038
8 changed files with 53 additions and 18 deletions
+2 -1
View File
@@ -24,7 +24,8 @@ Locales['br'] = {
['not_enough_money'] = 'você não tem dinheiro suficiente',
['not_rental'] = 'isso não é um ~r~veículo de aluguel~s~',
['not_yours'] = 'este veículo não pertence a você',
['paid_rental'] = 'Você tem ~g~pago~s~ para o seu aluguel de veiculos: ~g~$%s~s~',
['paid_rental'] = 'you have paid ~g~$%s~s~ for renting an vehicle with plate ~y~%s~s~',
['paid_rental_evicted'] = 'you could not afford to pay ~g~$%s~s~ for your rented vehicle with plate ~y~%s~s~, it has been returned to the dealership',
['pop_vehicle'] = 'sai do veiculo',
['rent_vehicle'] = 'Concessionária - Veículos para alugar',
['return_provider_menu'] = 'revendedor de carros - Devolver veículo ao fornecedor',
+2 -1
View File
@@ -24,7 +24,8 @@ Locales['cs'] = {
['not_enough_money'] = 'nemáš dostatek peněz',
['not_rental'] = 'tohle není ~r~půjčitelné vozidlo~s~',
['not_yours'] = 'tohle auto ti nepatří',
['paid_rental'] = '~g~zaplatil jsii~s~ za pujceni auta: ~g~$%s~s~',
['paid_rental'] = 'you have paid ~g~$%s~s~ for renting an vehicle with plate ~y~%s~s~',
['paid_rental_evicted'] = 'you could not afford to pay ~g~$%s~s~ for your rented vehicle with plate ~y~%s~s~, it has been returned to the dealership',
['pop_vehicle'] = 'vlozit vozidlo k prodeji',
['rent_vehicle'] = 'autosalon - Vozidla k pujceni',
['return_provider_menu'] = 'autosalon - Vratit vozidlo zprostredkovateli',
+2 -1
View File
@@ -24,7 +24,8 @@ Locales['en'] = {
['not_enough_money'] = 'you do not have enough money',
['not_rental'] = 'this is not a ~r~rental vehicle~s~',
['not_yours'] = 'this vehicle does not belong to you',
['paid_rental'] = 'you have ~g~payed~s~ for your vehicle rental: ~g~$%s~s~',
['paid_rental'] = 'you have paid ~g~$%s~s~ for renting an vehicle with plate ~y~%s~s~',
['paid_rental_evicted'] = 'you could not afford to pay ~g~$%s~s~ for your rented vehicle with plate ~y~%s~s~, it has been returned to the dealership',
['pop_vehicle'] = 'put out vehicle for sale',
['rent_vehicle'] = 'car Dealer - Vehicles for rent',
['return_provider_menu'] = 'car Dealer - Return vehicle to provider',
+2 -1
View File
@@ -24,7 +24,8 @@ Locales['fi'] = {
['not_enough_money'] = 'sinulla ei ole tarpeeksi rahaa',
['not_rental'] = 'tämä ei ole ~r~vuokra ajoneuvo~s~',
['not_yours'] = 'tämä ajoneuvo ei kuulu sinulle',
['paid_rental'] = 'sinä ~g~maksoit~s~ ajoneuvon vuokraamisesta: ~g~$%s~s~',
['paid_rental'] = 'you have paid ~g~$%s~s~ for renting an vehicle with plate ~y~%s~s~',
['paid_rental_evicted'] = 'you could not afford to pay ~g~$%s~s~ for your rented vehicle with plate ~y~%s~s~, it has been returned to the dealership',
['pop_vehicle'] = 'ota ajoneuvo ulos näkyville myyntiä varten',
['rent_vehicle'] = 'autokauppa - Vuokrattavat ajokit',
['return_provider_menu'] = 'car Dealer - Return vehicle to provider',
+2 -1
View File
@@ -24,7 +24,8 @@ Locales['fr'] = {
['not_enough_money'] = 'vous n\'avez pas assez d\'argent',
['not_rental'] = 'ce n\'est pas un ~r~véhicule de location~s~',
['not_yours'] = 'ce véhicule ne vous appartient pas',
['paid_rental'] = 'vous avez ~g~payé~s~ votre location de véhicule: ~g~$%s~s~',
['paid_rental'] = 'you have paid ~g~$%s~s~ for renting an vehicle with plate ~y~%s~s~',
['paid_rental_evicted'] = 'you could not afford to pay ~g~$%s~s~ for your rented vehicle with plate ~y~%s~s~, it has been returned to the dealership',
['pop_vehicle'] = 'sortir véhicule',
['rent_vehicle'] = 'concessionnaire - Véhicules en location',
['return_provider_menu'] = 'concessionnaire - Retour de véhicule',
+2 -1
View File
@@ -24,7 +24,8 @@ Locales['pl'] = {
['not_enough_money'] = 'nie masz wystarczająco pieniędzy',
['not_rental'] = 'to nie jest ~r~wypożyczone auto~s~',
['not_yours'] = 'ten pojazd nie należy do ciebie',
['paid_rental'] = '~g~Płacisz~s~ za wynajęcie auta: ~g~$%s~s~',
['paid_rental'] = 'you have paid ~g~$%s~s~ for renting an vehicle with plate ~y~%s~s~',
['paid_rental_evicted'] = 'you could not afford to pay ~g~$%s~s~ for your rented vehicle with plate ~y~%s~s~, it has been returned to the dealership',
['pop_vehicle'] = 'wyciągnij auto do sprzedaży',
['rent_vehicle'] = 'salon samochodowy - Pojazdy do wynajęcia',
['return_provider_menu'] = 'car Dealer - Return vehicle to provider',
+2 -1
View File
@@ -24,7 +24,8 @@ Locales['sv'] = {
['not_enough_money'] = 'du har inte tillräckligt mycket pengar',
['not_rental'] = 'detta är inte ett ~r~uthyrt fordon~s~',
['not_yours'] = 'det här fordonet tillhör inte dig',
['paid_rental'] = 'du har ~y~betalat~s~ ditt hyrda fordon: ~g~%s SEK~s~',
['paid_rental'] = 'du har betalat ~g~%s SEK~s~ för att hyra ett fordon med reg nummer ~y~%s~s~',
['paid_rental_evicted'] = 'du hade ej råd att betala ~g~%s SEK~s~ för ditt hyrda fordon med reg nummer ~y~%s~s~, den har tagits av bilförsäljaren',
['pop_vehicle'] = 'ställ ut fordon till salu',
['rent_vehicle'] = 'bilförsäljare - fordon för uthyrning',
['return_provider_menu'] = 'bilförsäljare - sälj tillbaka fordon till leverantör',
+39 -11
View File
@@ -419,23 +419,51 @@ AddEventHandler('esx_vehicleshop:setJobVehicleState', function(plate, state)
end)
end)
function UnrentVehicleAsync(identifier, plate)
MySQL.Async.execute('DELETE FROM rented_vehicles WHERE identifier = @identifier AND plate = @plate', {
['@identifier'] = identifier,
['@plate'] = plate
})
end
function PayRent(d, h, m)
local tasks, timeStart = {}, os.clock()
print('[esx_vehicleshop] [^2INFO^7] Paying rent cron job started')
MySQL.Async.fetchAll('SELECT owner, rent_price FROM rented_vehicles', {}, function(result)
for i=1, #result, 1 do
MySQL.Async.fetchAll('SELECT owner, rent_price, plate FROM rented_vehicles', {}, function(result)
for k,v in ipairs(result) do
table.insert(tasks, function(cb)
local xPlayer = ESX.GetPlayerFromIdentifier(result[i].owner)
local xPlayer = ESX.GetPlayerFromIdentifier(v.owner)
if xPlayer then -- message player if connected
xPlayer.removeAccountMoney('bank', result[i].rent_price)
xPlayer.showNotification(_U('paid_rental', ESX.Math.GroupDigits(result[i].rent_price)))
else -- pay rent by updating SQL
MySQL.Sync.execute('UPDATE users SET bank = bank - @bank WHERE identifier = @identifier', {
['@bank'] = result[i].rent_price,
['@identifier'] = result[i].owner
})
if xPlayer then
if xPlayer.getAccount('bank').money >= v.rent_price then
xPlayer.removeAccountMoney('bank', v.rent_price)
xPlayer.showNotification(_U('paid_rental', ESX.Math.GroupDigits(v.rent_price), v.plate))
else
xPlayer.showNotification(_U('paid_rental_evicted', ESX.Math.GroupDigits(v.rent_price), v.plate))
UnrentVehicleAsync(v.owner, v.plate)
end
else
MySQL.Async.fetchScalar('SELECT accounts FROM users WHERE identifier = @identifier', {
['@identifier'] = v.owner
}, function(accounts)
if accounts then
local playerAccounts = json.decode(accounts)
if playerAccounts and playerAccounts.bank then
if playerAccounts.bank >= v.price then
playerAccounts.bank = playerAccounts.bank - v.price
MySQL.Async.execute('UPDATE users SET accounts = @accounts WHERE identifier = @identifier', {
['@identifier'] = v.owner,
['@accounts'] = json.encode(playerAccounts)
})
else
UnrentVehicleAsync(v.owner, v.plate)
end
end
end
end)
end
TriggerEvent('esx_addonaccount:getSharedAccount', 'society_cardealer', function(account)