Code:
addEvent("Tic.addVeh", true)
addEventHandler("Tic.addVeh", root,
function(source, model)
local query = dbPoll(dbQuery(database, "SELECT * FROM playersConce WHERE Account = ?", getAccountName(getPlayerAccount(source))), -1)
if query and #query > 0 then
if vehicleConces[source] then
if isPedInVehicle(source) then
local r1, g1, b1, r2, g2, b2, r3, g3, b3 = getVehicleColor(vehicleConces[source], true)
local conceSQL = {
vehLife = getElementHealth(vehicleConces[source]),
vehColor = {
r1, g1, b1,
r2, g2, b2,
r3, g3, b3,
},
vehTunning = {},
vehUpgrade = {},
}
removeElementData(vehicleConces[source], "Tic.vehicleBank")
destroyElement(vehicleConces[source])
local vehFuel = dbPoll(dbQuery(database, "SELECT * FROM playersConce WHERE Account = ?", getAccountName(getPlayerAccount(source))), -1)
setElementData(vehicleConces[source], "DNL:Combustivel", vehFuel)
dxMsg(source, "Your vehicle was saved in the garage!", "success")
dbExec(database, "UPDATE playersConce SET Estado = ?, Dados = ? WHERE Account = ? AND Model = ?", "Garage", toJSON(conceSQL), getAccountName(getPlayerAccount(source)), model)
dbExec(database, "UPDATE playersConce SET Fuel = ? WHERE Account = ?", getElementData(source, "DNL:Combustivel"), getAccountName(getPlayerAccount(source)))
else
dxMsg(source, "Get inside the vehicle and try again.", "info")
end
else
dxMsg(source, "Your not have a vehicle!", "info")
end
end
end
)
About the solve: As I understand, you had destroyed the element before setElementData ( destroyElement(vehicleConces[source] ).
Also in dbExec you're trying to get ElementData from source, not from vehicleConces[source].