From 8b466eb2b27a766401b3bf869c89f21b51dc07bc Mon Sep 17 00:00:00 2001 From: Amir_Lynx <60301485+AmirLynx@users.noreply.github.com> Date: Wed, 14 Dec 2022 17:40:03 +0330 Subject: [PATCH 1/3] refactor(esx_lscustom\server):fix nil table values --- [esx_addons]/esx_lscustom/server/main.lua | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/[esx_addons]/esx_lscustom/server/main.lua b/[esx_addons]/esx_lscustom/server/main.lua index a2f41376..9c0912ac 100644 --- a/[esx_addons]/esx_lscustom/server/main.lua +++ b/[esx_addons]/esx_lscustom/server/main.lua @@ -4,10 +4,10 @@ local Customs = {} RegisterNetEvent('esx_lscustom:startModing', function(props, netId) local src = tostring(source) if Customs[src] then - Customs[src][props.plate] = {props = props, netId = netId} + Customs[src][tostring(props.plate)] = {props = props, netId = netId} else Customs[src] = {} - Customs[src][props.plate] = {props = props, netId = netId} + Customs[src][tostring(props.plate)] = {props = props, netId = netId} end end) @@ -25,7 +25,7 @@ AddEventHandler('esx:playerDropped', function(src) for k,v in pairs(Customs[src]) do local entity = NetworkGetEntityFromNetworkId(v.netId) if DoesEntityExist(entity) then - if players > 0 then + if playersCount > 0 then TriggerClientEvent('esx_lscustom:restoreMods', -1, v.netId, v.props) else DeleteEntity(entity) @@ -70,16 +70,25 @@ AddEventHandler('esx_lscustom:buyMod', function(price) end) RegisterServerEvent('esx_lscustom:refreshOwnedVehicle') -AddEventHandler('esx_lscustom:refreshOwnedVehicle', function(vehicleProps) +AddEventHandler('esx_lscustom:refreshOwnedVehicle', function(vehicleProps, netId) + local src = tostring(source) local xPlayer = ESX.GetPlayerFromId(source) - MySQL.single('SELECT vehicle FROM owned_vehicles WHERE plate = ?', {vehicleProps.plate}, function(result) if result then local vehicle = json.decode(result.vehicle) if vehicleProps.model == vehicle.model then MySQL.update('UPDATE owned_vehicles SET vehicle = ? WHERE plate = ?', {json.encode(vehicleProps), vehicleProps.plate}) - Customs[tostring(source)][tostring(vehicleProps.plate)].props = props + if Customs[src] then + if Customs[src][tostring(vehicleProps.plate)] then + Customs[src][tostring(vehicleProps.plate)].props = vehicleProps + else + Customs[src][tostring(vehicleProps.plate)] = {props = vehicleProps, netId = netId} + end + else + Customs[src] = {} + Customs[src][tostring(vehicleProps.plate)] = {props = vehicleProps, netId = netId} + end else print(('[^3WARNING^7] Player ^5%s^7 Attempted To upgrade with mismatching vehicle model'):format(xPlayer.source)) end From 27462c40449acee9680e0b8c83927ceac07b170c Mon Sep 17 00:00:00 2001 From: Amir_Lynx <60301485+AmirLynx@users.noreply.github.com> Date: Wed, 14 Dec 2022 17:41:30 +0330 Subject: [PATCH 2/3] refactor(esx_lscustom\config):Missed vehicle price --- [esx_addons]/esx_lscustom/config.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/[esx_addons]/esx_lscustom/config.lua b/[esx_addons]/esx_lscustom/config.lua index 3ed2514d..c8983ed5 100644 --- a/[esx_addons]/esx_lscustom/config.lua +++ b/[esx_addons]/esx_lscustom/config.lua @@ -472,7 +472,7 @@ Config.Menus = { label = TranslateCap('transmission'), parent = 'upgrades', modType = 13, - price = {13.95, 20.93, 46.51} + price = {13.95, 20.93, 46.51, 63.55} }, modSuspension = { label = TranslateCap('suspension'), From 45f4db04ab4573a2bfbf4a8e2f36bd5b711f1e67 Mon Sep 17 00:00:00 2001 From: Amir_Lynx <60301485+AmirLynx@users.noreply.github.com> Date: Wed, 14 Dec 2022 17:42:01 +0330 Subject: [PATCH 3/3] refactor(esx_lscustom\client):Fixed netid --- [esx_addons]/esx_lscustom/client/main.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/[esx_addons]/esx_lscustom/client/main.lua b/[esx_addons]/esx_lscustom/client/main.lua index c5c79fd6..fefc6934 100644 --- a/[esx_addons]/esx_lscustom/client/main.lua +++ b/[esx_addons]/esx_lscustom/client/main.lua @@ -14,7 +14,7 @@ RegisterNetEvent('esx_lscustom:installMod') AddEventHandler('esx_lscustom:installMod', function() local vehicle = GetVehiclePedIsIn(PlayerPedId(), false) myCar = ESX.Game.GetVehicleProperties(vehicle) - TriggerServerEvent('esx_lscustom:refreshOwnedVehicle', myCar) + TriggerServerEvent('esx_lscustom:refreshOwnedVehicle', myCar, NetworkGetNetworkIdFromEntity(vehicle)) end) RegisterNetEvent('esx_lscustom:restoreMods', function(netId, props) @@ -79,8 +79,8 @@ function OpenLSMenu(elems, menuName, menuTitle, parent) if data.current.label == TranslateCap('by_default') or string.match(data.current.label, TranslateCap('installed')) then ESX.ShowNotification(TranslateCap('already_own', data.current.label)) - myCar = ESX.Game.GetVehicleProperties(vehicle) - TriggerServerEvent('esx_lscustom:refreshOwnedVehicle', myCar) + myCar = ESX.Game.GetVehicleProperties(vehicle) + TriggerServerEvent('esx_lscustom:refreshOwnedVehicle', myCar, NetworkGetNetworkIdFromEntity(vehicle)) else local vehiclePrice = 50000