mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-02 11:18:53 +00:00
Fixed paying rent with latest ESX and added evict
This commit is contained in:
+2
-1
@@ -30,7 +30,8 @@ Locales['br'] = {
|
||||
['press_to_exit'] = 'Pressione ~INPUT_CONTEXT~ para sair da propriedade',
|
||||
['not_enough'] = 'Você não tem dinheiro suficiente',
|
||||
['invalid_quantity'] = 'Quantidade inválida',
|
||||
['paid_rent'] = 'Você ~g~pagou~s~ seu aluguel: ~g~$%s~s~',
|
||||
['paid_rent'] = 'you paid your rent at ~g~$%s~s~ for ~y~%s~s~',
|
||||
['paid_rent_evicted'] = 'you have been ~o~evicted~s~ from ~y~%s~s~ for not affording rent at ~g~$%s~s~',
|
||||
['not_enough_in_property'] = 'não há o suficiente de que esse item esteja na propriedade!',
|
||||
['player_cannot_hold'] = 'você não tem espaço suficiente em seu inventário!',
|
||||
}
|
||||
|
||||
+2
-3
@@ -28,11 +28,10 @@ Locales['de'] = {
|
||||
['amount'] = 'Anzahlt?',
|
||||
['amount_invalid'] = 'Ungültiger Wert',
|
||||
['press_to_exit'] = 'Drücke ~INPUT_CONTEXT~ um die Immobilie zu verlassen',
|
||||
['rent_for'] = 'Du hast eine Immobilie gemietet ~g~$%s~s~',
|
||||
['purchased_for'] = 'Du hast eine Immobilie gekauft ~g~$%s~s~',
|
||||
['not_enough'] = 'du hast nicht genug Geld',
|
||||
['invalid_quantity'] = 'Ungültiger Betrag',
|
||||
['paid_rent'] = 'du ~g~bezahlst~s~ deine Miete: ~g~$%s~s~',
|
||||
['paid_rent'] = 'you paid your rent at ~g~$%s~s~ for ~y~%s~s~',
|
||||
['paid_rent_evicted'] = 'you have been ~o~evicted~s~ from ~y~%s~s~ for not affording rent at ~g~$%s~s~',
|
||||
['not_enough_in_property'] = 'there\'s not enough of ~r~that item~s~ in the property!',
|
||||
['player_cannot_hold'] = 'you do ~r~not~s~ have enough ~y~free space~s~ in your inventory!',
|
||||
}
|
||||
|
||||
+2
-1
@@ -30,7 +30,8 @@ Locales['en'] = {
|
||||
['press_to_exit'] = 'press ~INPUT_CONTEXT~ to exit the property',
|
||||
['not_enough'] = 'you do not have enough money',
|
||||
['invalid_quantity'] = 'invalid quantity',
|
||||
['paid_rent'] = 'you ~g~paid~s~ your rent: ~g~$%s~s~',
|
||||
['paid_rent'] = 'you paid your rent at ~g~$%s~s~ for ~y~%s~s~',
|
||||
['paid_rent_evicted'] = 'you have been ~o~evicted~s~ from ~y~%s~s~ for not affording rent at ~g~$%s~s~',
|
||||
['not_enough_in_property'] = 'there\'s not enough of ~r~that item~s~ in the property!',
|
||||
['player_cannot_hold'] = 'you do ~r~not~s~ have enough ~y~free space~s~ in your inventory!',
|
||||
}
|
||||
|
||||
+2
-1
@@ -30,7 +30,8 @@ Locales['es'] = {
|
||||
['press_to_exit'] = 'Presione ~INPUT_CONTEXT~ para salir de la propiedad',
|
||||
['not_enough'] = 'n\'No tiene suficiente d\'dinero',
|
||||
['invalid_quantity'] = 'Cantidad inválida',
|
||||
['paid_rent'] = 'Has ~g~pagado~s~ por el alquiler: ~g~€%s~s~',
|
||||
['paid_rent'] = 'you paid your rent at ~g~€%s~s~ for ~y~%s~s~',
|
||||
['paid_rent_evicted'] = 'you have been ~o~evicted~s~ from ~y~%s~s~ for not affording rent at ~g~€%s~s~',
|
||||
['not_enough_in_property'] = 'there\'s not enough of ~r~that item~s~ in the property!',
|
||||
['player_cannot_hold'] = 'you do ~r~not~s~ have enough ~y~free space~s~ in your inventory!',
|
||||
}
|
||||
|
||||
+2
-1
@@ -30,7 +30,8 @@ Locales['fi'] = {
|
||||
['press_to_exit'] = 'paina ~INPUT_CONTEXT~ poistuaksesi kiinteistöstä',
|
||||
['not_enough'] = 'sinulla ei ole tarpeeksi rahaa',
|
||||
['invalid_quantity'] = 'virheellinen määrä',
|
||||
['paid_rent'] = 'sinä ~g~maksoit~s~ vuokraasi: ~g~$%s~s~',
|
||||
['paid_rent'] = 'you paid your rent at ~g~$%s~s~ for ~y~%s~s~',
|
||||
['paid_rent_evicted'] = 'you have been ~o~evicted~s~ from ~y~%s~s~ for not affording rent at ~g~$%s~s~',
|
||||
['not_enough_in_property'] = 'täällä ei ole enempää ~r~tätä itemiä~s~ tässä kiinteistössä!',
|
||||
['player_cannot_hold'] = 'sinulla ~r~ei ole~s~ tarpeeksi ~y~vapaata tilaa~s~ repussasi!',
|
||||
}
|
||||
|
||||
+2
-1
@@ -30,7 +30,8 @@ Locales['fr'] = {
|
||||
['press_to_exit'] = 'appuyez sur ~INPUT_CONTEXT~ pour sortir de la propriété',
|
||||
['not_enough'] = 'vous n\'avez pas assez d\'argent',
|
||||
['invalid_quantity'] = 'quantité invalide',
|
||||
['paid_rent'] = 'vous avez ~g~payé~s~ votre loyer: ~g~$%s~s~',
|
||||
['paid_rent'] = 'you paid your rent at ~g~$%s~s~ for ~y~%s~s~',
|
||||
['paid_rent_evicted'] = 'you have been ~o~evicted~s~ from ~y~%s~s~ for not affording rent at ~g~$%s~s~',
|
||||
['not_enough_in_property'] = 'il n\'a pas assez de ~r~cet objet~s~ dans votre coffre!',
|
||||
['player_cannot_hold'] = 'vous n\'avez pas assez ~y~de place~s~ dans votre inventaire!',
|
||||
}
|
||||
|
||||
+2
-1
@@ -30,7 +30,8 @@ Locales['pl'] = {
|
||||
['press_to_exit'] = 'wciśnij ~INPUT_CONTEXT~ aby wyjść z mieszkania',
|
||||
['not_enough'] = 'nie posiadasz wystarczająco pieniędzy',
|
||||
['invalid_quantity'] = 'nieprawidłowa ilość',
|
||||
['paid_rent'] = '~g~zapłaciłeś/aś~s~ za wynajem: ~g~$%s~s~',
|
||||
['paid_rent'] = 'you paid your rent at ~g~$%s~s~ for ~y~%s~s~',
|
||||
['paid_rent_evicted'] = 'you have been ~o~evicted~s~ from ~y~%s~s~ for not affording rent at ~g~$%s~s~',
|
||||
['not_enough_in_property'] = 'nie ma wystarczająco ~r~tego przedmiotu~s~ w mieszkaniu!',
|
||||
['player_cannot_hold'] = '~r~nie masz~s~ wystarczająco ~y~wolnego~s~ miejsca w ekwipunku!',
|
||||
}
|
||||
|
||||
+2
-1
@@ -30,7 +30,8 @@ Locales['sv'] = {
|
||||
['press_to_exit'] = 'tryck ~INPUT_CONTEXT~ för att lämna fastigheten',
|
||||
['not_enough'] = 'du har inte tillräckligt med pengar!',
|
||||
['invalid_quantity'] = 'ogiltlig mängd',
|
||||
['paid_rent'] = 'du ~y~betalade~s~ din hyra: ~g~%s SEK~s~',
|
||||
['paid_rent'] = 'du betalade din hyra på ~g~%s SEK~s~ för ~y~%s~s~',
|
||||
['paid_rent_evicted'] = 'du blev ~o~vräkt~s~ från ~y~%s~s~ för att du inte har råd för att betala hyran på ~g~%s SEK~s~',
|
||||
['not_enough_in_property'] = 'det finns ~r~inte~s~ tillräckligt av ~r~det objektet~s~ i fastigheten!',
|
||||
['player_cannot_hold'] = 'du har ~r~inte~s~ tillräckligt med ~y~utrymme~s~ för att hålla det!',
|
||||
}
|
||||
|
||||
+52
-28
@@ -31,7 +31,7 @@ function SetPropertyOwned(name, price, rented, owner)
|
||||
end)
|
||||
end
|
||||
|
||||
function RemoveOwnedProperty(name, owner)
|
||||
function RemoveOwnedProperty(name, owner, noPay)
|
||||
MySQL.Async.fetchAll('SELECT id, rented, price FROM owned_properties WHERE name = @name AND owner = @owner', {
|
||||
['@name'] = name,
|
||||
['@owner'] = owner
|
||||
@@ -45,13 +45,15 @@ function RemoveOwnedProperty(name, owner)
|
||||
if xPlayer then
|
||||
xPlayer.triggerEvent('esx_property:setPropertyOwned', name, false)
|
||||
|
||||
if result[1].rented == 1 then
|
||||
xPlayer.showNotification(_U('moved_out'))
|
||||
else
|
||||
local sellPrice = ESX.Math.Round(result[1].price / Config.SellModifier)
|
||||
if not noPay then
|
||||
if result[1].rented == 1 then
|
||||
xPlayer.showNotification(_U('moved_out'))
|
||||
else
|
||||
local sellPrice = ESX.Math.Round(result[1].price / Config.SellModifier)
|
||||
|
||||
xPlayer.showNotification(_U('moved_out_sold', ESX.Math.GroupDigits(sellPrice)))
|
||||
xPlayer.addAccountMoney('bank', sellPrice)
|
||||
xPlayer.showNotification(_U('moved_out_sold', ESX.Math.GroupDigits(sellPrice)))
|
||||
xPlayer.addAccountMoney('bank', sellPrice)
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
@@ -60,6 +62,8 @@ function RemoveOwnedProperty(name, owner)
|
||||
end
|
||||
|
||||
MySQL.ready(function()
|
||||
Citizen.Wait(1500)
|
||||
|
||||
MySQL.Async.fetchAll('SELECT * FROM properties', {}, function(properties)
|
||||
|
||||
for i=1, #properties, 1 do
|
||||
@@ -162,7 +166,7 @@ AddEventHandler('esx_property:removeOwnedProperty', function(name, owner)
|
||||
RemoveOwnedProperty(name, owner)
|
||||
end)
|
||||
|
||||
RegisterServerEvent('esx_property:rentProperty')
|
||||
RegisterNetEvent('esx_property:rentProperty')
|
||||
AddEventHandler('esx_property:rentProperty', function(propertyName)
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
local property = GetProperty(propertyName)
|
||||
@@ -171,7 +175,7 @@ AddEventHandler('esx_property:rentProperty', function(propertyName)
|
||||
SetPropertyOwned(propertyName, rent, true, xPlayer.identifier)
|
||||
end)
|
||||
|
||||
RegisterServerEvent('esx_property:buyProperty')
|
||||
RegisterNetEvent('esx_property:buyProperty')
|
||||
AddEventHandler('esx_property:buyProperty', function(propertyName)
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
local property = GetProperty(propertyName)
|
||||
@@ -184,7 +188,7 @@ AddEventHandler('esx_property:buyProperty', function(propertyName)
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterServerEvent('esx_property:removeOwnedProperty')
|
||||
RegisterNetEvent('esx_property:removeOwnedProperty')
|
||||
AddEventHandler('esx_property:removeOwnedProperty', function(propertyName)
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
RemoveOwnedProperty(propertyName, xPlayer.identifier)
|
||||
@@ -194,7 +198,7 @@ AddEventHandler('esx_property:removeOwnedPropertyIdentifier', function(propertyN
|
||||
RemoveOwnedProperty(propertyName, identifier)
|
||||
end)
|
||||
|
||||
RegisterServerEvent('esx_property:saveLastProperty')
|
||||
RegisterNetEvent('esx_property:saveLastProperty')
|
||||
AddEventHandler('esx_property:saveLastProperty', function(property)
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
@@ -204,7 +208,7 @@ AddEventHandler('esx_property:saveLastProperty', function(property)
|
||||
})
|
||||
end)
|
||||
|
||||
RegisterServerEvent('esx_property:deleteLastProperty')
|
||||
RegisterNetEvent('esx_property:deleteLastProperty')
|
||||
AddEventHandler('esx_property:deleteLastProperty', function()
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
@@ -213,7 +217,7 @@ AddEventHandler('esx_property:deleteLastProperty', function()
|
||||
})
|
||||
end)
|
||||
|
||||
RegisterServerEvent('esx_property:getItem')
|
||||
RegisterNetEvent('esx_property:getItem')
|
||||
AddEventHandler('esx_property:getItem', function(owner, type, item, count)
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
local xPlayerOwner = ESX.GetPlayerFromIdentifier(owner)
|
||||
@@ -262,7 +266,7 @@ AddEventHandler('esx_property:getItem', function(owner, type, item, count)
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterServerEvent('esx_property:putItem')
|
||||
RegisterNetEvent('esx_property:putItem')
|
||||
AddEventHandler('esx_property:putItem', function(owner, type, item, count)
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
local xPlayerOwner = ESX.GetPlayerFromIdentifier(owner)
|
||||
@@ -389,7 +393,7 @@ ESX.RegisterServerCallback('esx_property:getPlayerOutfit', function(source, cb,
|
||||
end)
|
||||
end)
|
||||
|
||||
RegisterServerEvent('esx_property:removeOutfit')
|
||||
RegisterNetEvent('esx_property:removeOutfit')
|
||||
AddEventHandler('esx_property:removeOutfit', function(label)
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
@@ -401,28 +405,48 @@ AddEventHandler('esx_property:removeOutfit', function(label)
|
||||
end)
|
||||
end)
|
||||
|
||||
function PayRent(d, h, m)
|
||||
function payRent(d, h, m)
|
||||
local tasks, timeStart = {}, os.clock()
|
||||
print('[esx_property] [^2INFO^7] Paying rent cron job started')
|
||||
|
||||
MySQL.Async.fetchAll('SELECT * FROM owned_properties WHERE rented = 1', {}, function(result)
|
||||
for i=1, #result, 1 do
|
||||
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)
|
||||
|
||||
-- message player if connected
|
||||
if xPlayer then
|
||||
xPlayer.removeAccountMoney('bank', result[i].price)
|
||||
xPlayer.showNotification(_U('paid_rent', ESX.Math.GroupDigits(result[i].price)))
|
||||
else -- pay rent either way
|
||||
MySQL.Sync.execute('UPDATE users SET bank = bank - @bank WHERE identifier = @identifier', {
|
||||
['@bank'] = result[i].price,
|
||||
['@identifier'] = result[i].owner
|
||||
})
|
||||
if xPlayer.getAccount('bank').money >= v.price then
|
||||
xPlayer.removeAccountMoney('bank', v.price)
|
||||
xPlayer.showNotification(_U('paid_rent', ESX.Math.GroupDigits(v.price), GetProperty(v.name).label))
|
||||
else
|
||||
xPlayer.showNotification(_U('paid_rent_evicted', GetProperty(v.name).label, ESX.Math.GroupDigits(v.price)))
|
||||
RemoveOwnedProperty(v.name, v.owner, true)
|
||||
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
|
||||
RemoveOwnedProperty(v.name, v.owner, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
TriggerEvent('esx_addonaccount:getSharedAccount', 'society_realestateagent', function(account)
|
||||
account.addMoney(result[i].price)
|
||||
account.addMoney(v.price)
|
||||
end)
|
||||
|
||||
cb()
|
||||
@@ -436,4 +460,4 @@ function PayRent(d, h, m)
|
||||
end)
|
||||
end
|
||||
|
||||
TriggerEvent('cron:runAt', 22, 0, PayRent)
|
||||
TriggerEvent('cron:runAt', 22, 0, payRent)
|
||||
|
||||
Reference in New Issue
Block a user