Hello i need help to save the handling of my vehicles in my mysql database.
part of my script works because the handling is well modified when the vehicle spawn but i have this error:
First i save the handling: (i think this funtion works properly)
function saveVehicle (source)
local dbid = tonumber(getElementData(source, "dbid")) or -1
if isElement(source) and getElementType(source) == "vehicle" and dbid >= 0 then
local hTable = getVehicleHandling(source)
local hString = toJSON(hTable)
mysql:query_free("UPDATE vehicles SET `handling`='" .. mysql:escape_string(hString) .. "' WHERE id='" .. mysql:escape_string(dbid) .. "'")
after that i would like to apply the handling to my vehicle:
function loadVehicle (id)
local row = mysql:query_fetch_assoc("SELECT * FROM vehicles WHERE id = " .. mysql:escape_string(id) .. " LIMIT 1" )
if row then
local veh = createVehicle(row.model, row.currx, row.curry, row.currz, row.currrx, row.currry, row.currrz, row.plate, false, var1, var2)
if veh then
local hTable = fromJSON(row["handling"])
if row.handling ~= null then
for property, value in pairs(hTable) do
setVehicleHandling(veh, property, value)
end
else
local modelID = getElementModel ( veh )
local handlingTable = getOriginalHandling ( modelID )
for property, value in pairs (handlingTable) do
setVehicleHandling(veh, property, value)
end
end
end
end
Excuse my bad english