mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 01:08:54 +00:00
Merge pull request #741 from AstroNext/Astro_5
refactor(esx_lscustom) : fix cache sync with client
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -495,7 +495,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'),
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 = vehicleProps
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user