Jump to content

dbExec problem WHERE


OrbTanT

Recommended Posts

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 by Shinigami
Link to comment

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

 

Link to comment
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

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...