mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-31 02:08:55 +00:00
Optimized paying rent, locate improvements
This commit is contained in:
+21
-19
@@ -2,31 +2,33 @@ resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937'
|
||||
|
||||
description 'ESX Property'
|
||||
|
||||
version '1.0.2'
|
||||
version '1.0.3'
|
||||
|
||||
server_scripts {
|
||||
'@es_extended/locale.lua',
|
||||
'locales/de.lua',
|
||||
'locales/br.lua',
|
||||
'locales/en.lua',
|
||||
'locales/fr.lua',
|
||||
'locales/es.lua',
|
||||
'@mysql-async/lib/MySQL.lua',
|
||||
'config.lua',
|
||||
'server/main.lua'
|
||||
'@es_extended/locale.lua',
|
||||
'locales/de.lua',
|
||||
'locales/br.lua',
|
||||
'locales/en.lua',
|
||||
'locales/fr.lua',
|
||||
'locales/es.lua',
|
||||
'locales/sv.lua',
|
||||
'@mysql-async/lib/MySQL.lua',
|
||||
'config.lua',
|
||||
'server/main.lua'
|
||||
}
|
||||
|
||||
client_scripts {
|
||||
'@es_extended/locale.lua',
|
||||
'locales/de.lua',
|
||||
'locales/br.lua',
|
||||
'locales/en.lua',
|
||||
'locales/fr.lua',
|
||||
'locales/es.lua',
|
||||
'config.lua',
|
||||
'client/main.lua'
|
||||
'@es_extended/locale.lua',
|
||||
'locales/de.lua',
|
||||
'locales/br.lua',
|
||||
'locales/en.lua',
|
||||
'locales/fr.lua',
|
||||
'locales/es.lua',
|
||||
'locales/sv.lua',
|
||||
'config.lua',
|
||||
'client/main.lua'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
'instance'
|
||||
'instance'
|
||||
}
|
||||
|
||||
+8
-3
@@ -1,5 +1,6 @@
|
||||
Locales['br'] = {
|
||||
|
||||
['have_withdrawn'] = 'you have withdrawn ~y~x%s~s~ ~b~%s~s~',
|
||||
['have_deposited'] = 'you have deposited ~y~x%s~s~ ~b~%s~s~',
|
||||
['free_prop'] = 'Propriedade gratuita',
|
||||
['property'] = 'Propriedade',
|
||||
['enter'] = 'Entrar',
|
||||
@@ -11,7 +12,10 @@ Locales['br'] = {
|
||||
['owned_properties'] = 'Propriedades adquiridas',
|
||||
['available_properties'] = 'Propriedades disponíveis',
|
||||
['invite_player'] = 'Convidar um jogador',
|
||||
['you_invited'] = 'you invited ~y~%s~s~ to your property',
|
||||
['player_clothes'] = 'Roupas',
|
||||
['remove_cloth'] = 'remove clothing',
|
||||
['removed_cloth'] = 'the outfit has been removed from your wardrobe!',
|
||||
['remove_object'] = 'Remover objeto',
|
||||
['deposit_object'] = 'Depositar objeto',
|
||||
['invite'] = 'Convidar',
|
||||
@@ -25,6 +29,7 @@ Locales['br'] = {
|
||||
['made_property'] = 'Você criou uma propriedade',
|
||||
['not_enough'] = 'Você não tem dinheiro suficiente',
|
||||
['invalid_quantity'] = 'Quantidade inválida',
|
||||
['paid_rent'] = 'Você ~g~pagou~s~ seu aluguel: ~g~$',
|
||||
|
||||
['paid_rent'] = 'Você ~g~pagou~s~ seu aluguel: ~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!',
|
||||
}
|
||||
|
||||
+7
-3
@@ -1,5 +1,6 @@
|
||||
Locales['de'] = {
|
||||
|
||||
['have_withdrawn'] = 'you have withdrawn ~y~x%s~s~ ~b~%s~s~',
|
||||
['have_deposited'] = 'you have deposited ~y~x%s~s~ ~b~%s~s~',
|
||||
['free_prop'] = 'Kostenlose Immobilie',
|
||||
['property'] = 'Immobilie',
|
||||
['enter'] = 'Eintreten',
|
||||
@@ -13,6 +14,8 @@ Locales['de'] = {
|
||||
['invite_player'] = 'Spieler einladen',
|
||||
['you_invited'] = 'Du hast %s eingeladen',
|
||||
['player_clothes'] = 'Kleidung',
|
||||
['remove_cloth'] = 'remove clothing',
|
||||
['removed_cloth'] = 'the outfit has been removed from your wardrobe!',
|
||||
['remove_object'] = 'Objekt nehmen',
|
||||
['deposit_object'] = 'Objekt deponieren',
|
||||
['invite'] = 'Einladen',
|
||||
@@ -26,6 +29,7 @@ Locales['de'] = {
|
||||
['made_property'] = 'Du hast eine Immobilie gemacht',
|
||||
['not_enough'] = 'du hast nicht genug Geld',
|
||||
['invalid_quantity'] = 'Ungültiger Betrag',
|
||||
['paid_rent'] = 'du ~g~bezahlst~s~ deine Miete: ~g~$',
|
||||
|
||||
['paid_rent'] = 'du ~g~bezahlst~s~ deine Miete: ~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!',
|
||||
}
|
||||
|
||||
+9
-9
@@ -1,9 +1,10 @@
|
||||
Locales['en'] = {
|
||||
|
||||
['have_withdrawn'] = 'you have withdrawn ~y~x%s~s~ ~b~%s~s~',
|
||||
['have_deposited'] = 'you have deposited ~y~x%s~s~ ~b~%s~s~',
|
||||
['free_prop'] = 'free property',
|
||||
['property'] = 'property',
|
||||
['enter'] = 'enter',
|
||||
['leave'] = 'leave',
|
||||
['leave'] = 'leave the property',
|
||||
['buy'] = 'buy',
|
||||
['rent'] = 'rent',
|
||||
['visit'] = 'visit',
|
||||
@@ -11,10 +12,10 @@ Locales['en'] = {
|
||||
['owned_properties'] = 'acquired properties',
|
||||
['available_properties'] = 'available properties',
|
||||
['invite_player'] = 'invite a player',
|
||||
['you_invited'] = 'you invited %s',
|
||||
['you_invited'] = 'you invited ~y~%s~s~ to your property',
|
||||
['player_clothes'] = 'clothes',
|
||||
['remove_cloth'] = 'remove clothing',
|
||||
['removed_cloth'] = 'this outfit has been removed from your wardrobe!',
|
||||
['removed_cloth'] = 'the outfit has been removed from your wardrobe!',
|
||||
['remove_object'] = 'remove object',
|
||||
['deposit_object'] = 'deposit object',
|
||||
['invite'] = 'invite',
|
||||
@@ -28,8 +29,7 @@ Locales['en'] = {
|
||||
['made_property'] = 'you have made a property',
|
||||
['not_enough'] = 'you do not have enough money',
|
||||
['invalid_quantity'] = 'invalid quantity',
|
||||
['paid_rent'] = 'you ~g~paid~s~ your rent: ~g~$',
|
||||
['not_enough_in_property'] = 'there\'s not enough of ~r~that item~w~ in the property!',
|
||||
['player_cannot_hold'] = 'you do ~r~not~w~ have enough ~y~free space~w~ in your inventory!',
|
||||
|
||||
}
|
||||
['paid_rent'] = 'you ~g~paid~s~ your rent: ~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!',
|
||||
}
|
||||
+6
-2
@@ -1,5 +1,6 @@
|
||||
Locales['es'] = {
|
||||
|
||||
['have_withdrawn'] = 'you have withdrawn ~y~x%s~s~ ~b~%s~s~',
|
||||
['have_deposited'] = 'you have deposited ~y~x%s~s~ ~b~%s~s~',
|
||||
['free_prop'] = 'Propiedad libre',
|
||||
['property'] = 'Propiedad',
|
||||
['enter'] = 'Entrar',
|
||||
@@ -13,6 +14,8 @@ Locales['es'] = {
|
||||
['invite_player'] = 'Invitar a un jugador',
|
||||
['you_invited'] = 'Has invitado a %s',
|
||||
['player_clothes'] = 'Ropa',
|
||||
['remove_cloth'] = 'remove clothing',
|
||||
['removed_cloth'] = 'the outfit has been removed from your wardrobe!',
|
||||
['remove_object'] = 'Retirar objeto',
|
||||
['deposit_object'] = 'Depositar objeto',
|
||||
['invite'] = 'Invitar',
|
||||
@@ -27,5 +30,6 @@ Locales['es'] = {
|
||||
['not_enough'] = 'n\'No tiene suficiente d\'dinero',
|
||||
['invalid_quantity'] = 'Cantidad inválida',
|
||||
['paid_rent'] = 'Has ~g~pagado~s~ por el alquiler : ~g~€',
|
||||
|
||||
['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!',
|
||||
}
|
||||
|
||||
+4
-2
@@ -1,5 +1,6 @@
|
||||
Locales['fr'] = {
|
||||
|
||||
['have_withdrawn'] = 'you have withdrawn ~y~x%s~s~ ~b~%s~s~',
|
||||
['have_deposited'] = 'you have deposited ~y~x%s~s~ ~b~%s~s~',
|
||||
['free_prop'] = 'propriété libre',
|
||||
['property'] = 'propriété',
|
||||
['enter'] = 'entrer',
|
||||
@@ -29,5 +30,6 @@ Locales['fr'] = {
|
||||
['not_enough'] = 'vous n\'avez pas assez d\'argent',
|
||||
['invalid_quantity'] = 'quantité invalide',
|
||||
['paid_rent'] = 'vous avez ~g~payé~s~ votre loyer : ~g~$',
|
||||
|
||||
['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!',
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
Locales['sv'] = {
|
||||
['have_withdrawn'] = 'du har tagit ut ~y~x%s~s~ ~b~%s~s~',
|
||||
['have_deposited'] = 'du har lagrat ~y~x%s~s~ ~b~%s~s~',
|
||||
['free_prop'] = 'ledig fastighet',
|
||||
['property'] = 'fastighet',
|
||||
['enter'] = 'gå in',
|
||||
['leave'] = 'lämna',
|
||||
['buy'] = 'köp',
|
||||
['rent'] = 'hyr',
|
||||
['visit'] = 'besök',
|
||||
['press_to_menu'] = 'tryck ~INPUT_CONTEXT~ för att komma åt menyn',
|
||||
['owned_properties'] = 'upptagna fastigheter',
|
||||
['available_properties'] = 'lediga fastigheter',
|
||||
['invite_player'] = 'bjud in granne',
|
||||
['you_invited'] = 'du bjöd in ~y~%s~s~ till din fastighet',
|
||||
['player_clothes'] = 'Kläder',
|
||||
['remove_cloth'] = 'ta bort klädstil',
|
||||
['removed_cloth'] = 'denna outfit har blivit borttagen från din garderob!',
|
||||
['remove_object'] = 'ta ut objekt',
|
||||
['deposit_object'] = 'lagra objekt',
|
||||
['invite'] = 'bjud in',
|
||||
['dirty_money'] = 'Smutsiga pengar: $',
|
||||
['inventory'] = 'inventory',
|
||||
['amount'] = 'summa?',
|
||||
['amount_invalid'] = 'ogiltlig summa',
|
||||
['press_to_exit'] = 'tryck ~INPUT_CONTEXT~ för att gå ur fastigheten',
|
||||
['rented_for'] = 'du hyrde en fastighet för: ~g~$',
|
||||
['purchased_for'] = 'du köpte en fastighet för: ~g~$',
|
||||
['made_property'] = 'you have made a property',
|
||||
['not_enough'] = 'du har inte tillräckligt med pengar!',
|
||||
['invalid_quantity'] = 'ogiltlig mängd',
|
||||
['paid_rent'] = 'du ~y~betalade~s~ din hyra: ~g~$%s~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!',
|
||||
}
|
||||
+32
-46
@@ -263,10 +263,12 @@ AddEventHandler('esx_property:getItem', function(owner, type, item, count)
|
||||
|
||||
if type == 'item_standard' then
|
||||
local sourceItem = xPlayer.getInventoryItem(item)
|
||||
|
||||
TriggerEvent('esx_addoninventory:getInventory', 'property', xPlayerOwner.identifier, function(inventory)
|
||||
|
||||
local inventoryItem = inventory.getItem(item)
|
||||
|
||||
-- is there enough in the property?
|
||||
if count > 0 and inventory.getItem(item).count >= count then
|
||||
if count > 0 and inventoryItem.count >= count then
|
||||
|
||||
-- can the player carry the said amount of x item?
|
||||
if sourceItem.limit ~= -1 and (sourceItem.count + count) > sourceItem.limit then
|
||||
@@ -274,6 +276,7 @@ AddEventHandler('esx_property:getItem', function(owner, type, item, count)
|
||||
else
|
||||
inventory.removeItem(item, count)
|
||||
xPlayer.addInventoryItem(item, count)
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('have_withdrawn', count, inventoryItem.label))
|
||||
end
|
||||
else
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('not_enough_in_property'))
|
||||
@@ -345,13 +348,13 @@ AddEventHandler('esx_property:putItem', function(owner, type, item, count)
|
||||
local playerItemCount = xPlayer.getInventoryItem(item).count
|
||||
|
||||
if playerItemCount >= count then
|
||||
|
||||
xPlayer.removeInventoryItem(item, count)
|
||||
|
||||
|
||||
TriggerEvent('esx_addoninventory:getInventory', 'property', xPlayerOwner.identifier, function(inventory)
|
||||
xPlayer.removeInventoryItem(item, count)
|
||||
inventory.addItem(item, count)
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('have_deposited', count, inventory.getItem(item).label))
|
||||
end)
|
||||
|
||||
|
||||
else
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('invalid_quantity'))
|
||||
end
|
||||
@@ -544,48 +547,31 @@ AddEventHandler('esx_property:removeOutfit', function(label)
|
||||
|
||||
end)
|
||||
|
||||
function PayRent(d, h, m)
|
||||
function PayRent()
|
||||
MySQL.Async.fetchAll(
|
||||
'SELECT * FROM owned_properties WHERE rented = 1', {},
|
||||
function (result)
|
||||
for i=1, #result, 1 do
|
||||
local xPlayer = ESX.GetPlayerFromIdentifier(result[i].owner)
|
||||
|
||||
MySQL.Async.fetchAll(
|
||||
'SELECT * FROM owned_properties WHERE rented = 1',
|
||||
{
|
||||
|
||||
}, function (result)
|
||||
local xPlayers = ESX.GetPlayers()
|
||||
|
||||
for i=1, #result, 1 do
|
||||
|
||||
local foundPlayer = false
|
||||
local xPlayer = nil
|
||||
|
||||
for j=1, #xPlayers, 1 do
|
||||
|
||||
local xPlayer2 = ESX.GetPlayerFromId(xPlayers[j])
|
||||
|
||||
if xPlayer2.identifier == result[i].owner then
|
||||
foundPlayer = true
|
||||
xPlayer = xPlayer2
|
||||
end
|
||||
end
|
||||
|
||||
if foundPlayer then
|
||||
xPlayer.removeMoney(result[i].price)
|
||||
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('paid_rent') .. result[i].price)
|
||||
else
|
||||
MySQL.Sync.execute(
|
||||
'UPDATE users SET money = money - @money WHERE identifier = @identifier',
|
||||
{
|
||||
['@money'] = result[i].price,
|
||||
['@identifier'] = result[i].owner
|
||||
})
|
||||
end
|
||||
|
||||
TriggerEvent('esx_addonaccount:getSharedAccount', 'society_realestateagent', function(account)
|
||||
account.addMoney(result[i].price)
|
||||
end)
|
||||
end
|
||||
end)
|
||||
-- message player if connected
|
||||
if xPlayer ~= nil then
|
||||
xPlayer.removeBank(result[i].price)
|
||||
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('paid_rent', 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
|
||||
})
|
||||
end
|
||||
|
||||
TriggerEvent('esx_addonaccount:getSharedAccount', 'society_realestateagent', function(account)
|
||||
account.addMoney(result[i].price)
|
||||
end)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
TriggerEvent('cron:runAt', 22, 0, PayRent)
|
||||
|
||||
Reference in New Issue
Block a user