mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-30 09:48:52 +00:00
Merge pull request #6 from AdrineX/master
Save modifications to car + get modified car from /pv menu
This commit is contained in:
+39
-39
@@ -38,48 +38,48 @@ AddEventHandler('esx_garage:setParking', function(garage, zone, vehicleProps)
|
||||
|
||||
end)
|
||||
|
||||
RegisterServerEvent('esx_vehicleshop:updateOwnedVehicle')
|
||||
AddEventHandler('esx_vehicleshop:updateOwnedVehicle', function(vehicleProps)
|
||||
RegisterServerEvent('esx_garage:updateOwnedVehicle')
|
||||
AddEventHandler('esx_garage:updateOwnedVehicle', function(vehicleProps)
|
||||
|
||||
local _source = source
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
MySQL.Async.fetchAll(
|
||||
'SELECT * FROM owned_vehicles WHERE owner = @owner',
|
||||
{
|
||||
['@owner'] = xPlayer.identifier
|
||||
},
|
||||
function(result)
|
||||
|
||||
local foundVehicleId = nil
|
||||
|
||||
for i=1, #result, 1 do
|
||||
|
||||
local vehicle = json.decode(result[i].vehicle)
|
||||
|
||||
if vehicle.plate == vehicleProps.plate then
|
||||
foundVehicleId = result[i].id
|
||||
break
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if foundVehicleId ~= nil then
|
||||
|
||||
local _source = source
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
MySQL.Async.fetchAll(
|
||||
'SELECT * FROM owned_vehicles WHERE owner = @owner',
|
||||
{
|
||||
['@owner'] = xPlayer.identifier
|
||||
},
|
||||
function(results)
|
||||
|
||||
local foundVehicleId = nil
|
||||
|
||||
for i=1, #result, 1 do
|
||||
|
||||
local vehicle = json.decode(result[i].vehicle)
|
||||
|
||||
if vehicle.plate == vehicleProps.plate then
|
||||
foundVehicleId = result[i].id
|
||||
break
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if foundVehicleId ~= nil then
|
||||
|
||||
MySQL.Async.execute(
|
||||
'UPDATE owned_vehicles SET vehicle = @vehicle WHERE id = @id',
|
||||
{
|
||||
MySQL.Async.execute(
|
||||
'UPDATE owned_vehicles SET vehicle = @vehicle WHERE id = @id',
|
||||
{
|
||||
['@vehicle'] = json.encode(vehicleProps),
|
||||
['@id'] = foundVehicleId
|
||||
}
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
)
|
||||
|
||||
end)
|
||||
}
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
)
|
||||
|
||||
end)
|
||||
|
||||
ESX.RegisterServerCallback('esx_vehicleshop:getVehiclesInGarage', function(source, cb, garage)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user