From fec16e1b17c1b576354460b819c5ecc3dc0f1a4a Mon Sep 17 00:00:00 2001 From: Mycroft Date: Fri, 26 Aug 2022 16:10:37 +0100 Subject: [PATCH] fix(esx_property): Vehicle Duplication --- [esx_addons]/esx_property/config.lua | 2 +- [esx_addons]/esx_property/server/main.lua | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/[esx_addons]/esx_property/config.lua b/[esx_addons]/esx_property/config.lua index c812a14c..ffcf9061 100644 --- a/[esx_addons]/esx_property/config.lua +++ b/[esx_addons]/esx_property/config.lua @@ -28,10 +28,10 @@ Config.Raiding = { }, } - Config.Garage = { Enabled = true, -- Enable/Disable Garage Default: true OwnedVehiclesOnly = true, -- Only allow owned vehicles to be stored Default: true + MySQLquery = "UPDATE `owned_vehicles` SET `stored` = ? WHERE `plate` = ?" -- MySQL Query to store vehicles `?` = True/false, Vehicle Plate } Config.Logs ={ diff --git a/[esx_addons]/esx_property/server/main.lua b/[esx_addons]/esx_property/server/main.lua index 17c34b5c..fb0344a9 100644 --- a/[esx_addons]/esx_property/server/main.lua +++ b/[esx_addons]/esx_property/server/main.lua @@ -851,6 +851,7 @@ ESX.RegisterServerCallback('esx_property:StoreVehicle', function(source, cb, Pro vehicle = VehicleProperties} cb(true) end + MySQL.query(Config.Garage.MySQLquery, {1, VehicleProperties.plate}) -- Set vehicle as stored in MySQL else xPlayer.showNotification('Garage Not Enabled On This Property.', 'error') cb(false) @@ -1012,12 +1013,13 @@ RegisterNetEvent('esx_property:leave', function(PropertyId) end) RegisterNetEvent('esx_property:SetVehicleOut', function(PropertyId, VehIndex) - local source = source - local Property = Properties[PropertyId] - local xPlayer = ESX.GetPlayerFromId(source) + local VehicleData = Properties[PropertyId].garage.StoredVehicles[VehIndex] + local plate = VehicleData.vehicle.plate table.remove(Properties[PropertyId].garage.StoredVehicles, VehIndex) + MySQL.query(Config.Garage.MySQLquery, {0, plate}) -- Set vehicle as no longer stored end) + AddEventHandler('playerDropped', function() local source = source for PropertyId = 1, #Properties do