Fix mistake

This commit is contained in:
Jérémie N'gadi
2017-08-27 11:04:30 +02:00
parent 9f60b01bd0
commit 7255dcab27
3 changed files with 56 additions and 8 deletions
+43
View File
@@ -38,6 +38,49 @@ AddEventHandler('esx_garage:setParking', function(garage, zone, vehicleProps)
end)
RegisterServerEvent('esx_vehicleshop:updateOwnedVehicle')
AddEventHandler('esx_vehicleshop: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(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',
{
['@vehicle'] = json.encode(vehicleProps),
['@id'] = foundVehicleId
}
)
end
end
)
end)
ESX.RegisterServerCallback('esx_vehicleshop:getVehiclesInGarage', function(source, cb, garage)
local xPlayer = ESX.GetPlayerFromId(source)