Pouloud Posted June 3, 2018 Share Posted June 3, 2018 (edited) 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: Quote WARNING: vehicle-system\s_vehicle_system.lua:6: Bad argument @ 'fromJSON' [Expected string at argument 1, got nil] 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 Edited June 3, 2018 by Pouloud spelling mistake Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now