Hi im trying to do when i impound a car in sql update some values
I NEED TO CHANGE THE SPECIFICALLY THIS (state, x, y, z, h, garage)
CLIENT:
function ImpoundVehicle(vehicle)
local playerPed = PlayerPedId()
local vehicle = ESX.Game.GetVehicleInDirection()
if IsPedInAnyVehicle(playerPed, true) then
vehicle = GetVehiclePedIsIn(playerPed, false)
end
local entity = vehicle
carModel = GetEntityModel(entity)
carName = GetDisplayNameFromVehicleModel(carModel)
NetworkRequestControlOfEntity(entity)
local timeout = 2000
while timeout > 0 and not NetworkHasControlOfEntity(entity) do
Wait(100)
timeout = timeout - 100
end
SetEntityAsMissionEntity(entity, true, true)
local timeout = 2000
while timeout > 0 and not IsEntityAMissionEntity(entity) do
Wait(100)
timeout = timeout - 100
end
Citizen.InvokeNative( 0xEA386986E786A54F, Citizen.PointerValueIntInitialized( entity ) )
if (DoesEntityExist(entity)) then
DeleteEntity(entity)
local vehicle = ESX.Game.GetClosestVehicle(coords)
local vehiclecoords = GetEntityCoords(vehicle)
local vehDistance = GetDistanceBetweenCoords(coords, vehiclecoords, true)
local vehProps = ESX.Game.GetVehicleProperties(vehicle)
TriggerServerEvent('master_polstrabalho:apreender', vehProps.plate)
end
ESX.ShowNotification(_U('impound_successful'))
currentTask.busy = false
end
SERVER:
RegisterServerEvent('master_polstrabalho:apreender')
AddEventHandler('master_polstrabalho:apreender', function(target, plate)
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
local _target = target
local tPlayer = ESX.GetPlayerFromId(_target)
local result = MySQL.Sync.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @identifier AND plate = @plate', {
['@identifier'] = xPlayer.identifier,
['@plate'] = plate
})
if result[1] ~= nil then
MySQL.Async.execute('UPDATE owned_vehicles SET state = @state, x = @x, y = @y, z = @z, h = @h, garage = @garage WHERE plate = @plate AND owner = @owner', {
['@owner'] = xPlayer.identifier,
['@plate'] = plate,
['@state'] = '3',
['@x'] = '',
['@y'] = '',
['@z'] = '',
['@h'] = '',
['@garage'] = 'OUT'
})
end
end)