DanielHuynh Posted March 21, 2020 Share Posted March 21, 2020 I am trying to save the data of the account. But something wrong. WARNING: [mod]\dayz\login.Lua:571: dbExec failed; (1) near "s": syntax error function saveDataBased() outputChatBox(" ",getRootElement(),255,255,255,true) outputChatBox("#FF0000BACKUP:#FFFFFF Server data is being saved...",getRootElement(),255,255,255,true) destroyDataBase("tents") destroyDataBase("vehicles") for i,tent in ipairs(getElementsByType("colshape")) do if getElementData(tent,"tent") then local x,y,z = getElementPosition(tent) local col = getElementData(tent,"parent") local rotx,roty,rot = getElementRotation(getElementData(tent,"parent")) local dataT = {} local noDeleteTent = false for i,v in ipairs(serverData["items"]) do local data = getElementData(tent,v[1]) or 0 if data > 0 then noDeleteTent = true end table.insert(dataT,{v[1],data}) end if noDeleteTent == true then local result = dbQuery( database , "INSERT INTO `tents` VALUES ("..x..", "..y..", "..z..", "..rot..","..toJSON(dataT)..");") dbFree ( result ) else destroyElement(tent) destroyElement(col) end end end for index,element in ipairs(getElementsByType("vehicle")) do local x,y,z = getElementPosition(element) local col = getElementData(element,"parent") local rotx,roty,rot = getElementRotation(element) local model = getElementModel(element) local health = getElementHealth(element) local dataT = {} for i,v in ipairs(serverData["items"]) do if col ~= false then local data = getElementData(col,v[1]) or 0 table.insert(dataT,{v[1],data}) end end for i,v in ipairs(serverData["vehicle"]) do if col ~= false then local data = getElementData(col,v[1]) or 0 table.insert(dataT,{v[1],data}) end end local result = dbQuery( database , "INSERT INTO vehicles VALUES ('"..model.."','"..x.."', '"..y.."', '"..z.."', '"..rot.."','"..health.."', '"..toJSON(dataT).."');") dbFree ( result ) end outputChatBox("#FF0000BACKUP:#FFFFFF Data save completed successfully..",getRootElement(),255,255,255,true) baseCopy() end setTimer(saveDataBased,backTime,0) Link to comment
The_GTA Posted March 21, 2020 Share Posted March 21, 2020 Hello DanielHuynh, could you please use the "<>" to format your code? It would greatly improve the readability. Link to comment
Moderators Citizen Posted March 21, 2020 Moderators Share Posted March 21, 2020 (edited) EDIT: nvm, I've mixed my open tabs Edited March 21, 2020 by Citizen 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