OrbTanT Posted December 1, 2016 Posted December 1, 2016 (edited) I am trying to save the data of the account, when the player leaves the server, but this one presenting the following error, I have already tried several ways, but nothing solved. WARNING: GWlogin\server.lua:171: dbExec failed; (1) near "WHERE": syntax error function savePlayerData(player) local account = getPlayerName(player) local x, y, z = getElementPosition(player) local money = getPlayerMoney(player) local health = getElementHealth(player) local armor = getPedArmor(player) local skin = getElementModel(player) local int = getElementInterior(player) local dim = getElementDimension(player) local weapons = { } local kills = tonumber(getElementData(player, "Kills")) or 0 local deaths = tonumber(getElementData(player, "Deaths")) or 0 local weaponstats = toJSON(weaponstats_) for i=1, 12 do weapons[i] = { getPedWeapon(player, i), getPedTotalAmmo(player, i)} end local weapons = toJSON(weapons) outputDebugString ( "GWsql: Tentando salvar a conta (Player: "..account..") userdata." ) return dbExec(db, "UPDATE accounts SET Money=?, Armour=?, Health=?, x=?, y=?, z=?, Skin=?, Interior=?, Dimension=?, Weapons=?, Kills=?, Deaths=?, weapstats=?, WHERE user = '" .. account .. "' ", money, armor, health, x, y, z, skin, int, dim, weapons, kills, deaths, weaponstats ) end Edited December 1, 2016 by Shinigami
Bonsai Posted December 1, 2016 Posted December 1, 2016 I think there is a comma in the way at "weapstats=?, ". You should probably also insert the account the same way as the other arguments.
Best-Killer Posted December 1, 2016 Posted December 1, 2016 Try This : function savePlayerData(player) local account = getPlayerName(player) local x, y, z = getElementPosition(player) local money = getPlayerMoney(player) local health = getElementHealth(player) local armor = getPedArmor(player) local skin = getElementModel(player) local int = getElementInterior(player) local dim = getElementDimension(player) local weapons = { } local kills = tonumber(getElementData(player, "Kills")) or 0 local deaths = tonumber(getElementData(player, "Deaths")) or 0 local weaponstats = toJSON(weaponstats_) for i=1, 12 do weapons[i] = { getPedWeapon(player, i), getPedTotalAmmo(player, i)} end local weapons = toJSON(weapons) outputDebugString ( "GWsql: Tentando salvar a conta (Player: "..account..") userdata." ) return dbExec(db, "UPDATE accounts SET Money=?, Armour=?, Health=?, x=?, y=?, z=?, Skin=?, Interior=?, Dimension=?, Weapons=?, Kills=?, Deaths=?, weapstats=? AND WHERE user =?",money, armor, health, x, y, z, skin, int, dim, weapons, kills, deaths, weaponstats,account ) end
SetMarcos Posted December 1, 2016 Posted December 1, 2016 return dbExec(db, "UPDATE accounts SET Money=?, Armour=?, Health=?, x=?, y=?, z=?, Skin=?, Interior=?, Dimension=?, Weapons=?, Kills=?, Deaths=?, weapstats=? WHERE user =?",money, armor, health, x, y, z, skin, int, dim, weapons, kills, deaths, weaponstats,account ) teste assim... se precisar de ajuda com o SQL é só chamar! Skype: MarcosPRO20
OrbTanT Posted December 1, 2016 Author Posted December 1, 2016 Is working, thank you to all who helped, had not noticed the comma
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