• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Problem with "db.executeQuery"

  • Thread starter Thread starter Icy
  • Start date Start date
I

Icy

Guest
LUA:
function onAdvance(cid, skill, oldLevel, newLevel)
		if skill == SKILL__LEVEL then
			doSendMagicEffect(getCreaturePosition(cid), 45)
			db.executeQuery("UPDATE players SET skill_points = skill_points + 1 WHERE name = "..getPlayerName(cid)..";")
		end

	return true
end

Any idea why my script is not working? It calls everything correctly, I put the magic effect in for debugging purposes, so I know that the script executes for sure...

However, the database query seems to not be working. If I change it to
Code:
db.executeQuery("UPDATE players SET skill_points = skill_points + 1 WHERE online = 1")
it works; what am I doing wrong with the last segment of my code?



EDIT: Fixed code for any individual who feels like using or modifying my script for their own needs:
LUA:
function onAdvance(cid, skill, oldLevel, newLevel)
		if skill == SKILL__LEVEL then
			db.executeQuery("UPDATE players SET skill_points = skill_points + 1 WHERE id = "..getPlayerGUID(cid)..";")
		end

	return true
end
 
Last edited by a moderator:
Well that worked, thanks mate.

Any idea why getPlayerName doesn't work though?
You have to put it inside quotes for SQL to treat it as a string.
Code:
WHERE name = [B][COLOR="Red"]'[/COLOR][/B]"..getPlayerName(cid).."[B][COLOR="Red"]'[/COLOR][/B];")
 
Back
Top