• 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!

How do I add to my player's maxhealth whenever I use the code with db.query

Tempesto

Member
Joined
Feb 12, 2018
Messages
79
Reaction score
6
Location
Ruining your servers.
I looked around otland/forgottenserver and I can't find anything on db.query, I want to add to my players max health by 10,000 and max mana everytime the script is executed. Or should I use a meta table. I've seen getMaxHealth, addhealth. I'm not sure how to add it to my script.

Not self though, whatever player has the script run for them.
Basically. Everytime the script runs, it adds 10000 hp and 10000 mp that adds to the value in its row in my database.

This is for TFS 1.2 . I'd really like to do it with sql code that fits in luascript if possible.
 
Last edited:
Solution
Lua:
local id = player:getGuid()
db.query("UPDATE `players` SET `health` = `health` + 10000, `healthmax` = `healthmax` + 10000 WHERE `id` = ".. id)
db.query("UPDATE `players` SET `mana` = `mana` + 10000, `manamax` = `manamax` + 10000 WHERE `id` = ".. id)
Lua:
local id = player:getGuid()
db.query("UPDATE `players` SET `health` = `health` + 10000, `healthmax` = `healthmax` + 10000 WHERE `id` = ".. id)
db.query("UPDATE `players` SET `mana` = `mana` + 10000, `manamax` = `manamax` + 10000 WHERE `id` = ".. id)
 
Solution
are you doing it while the character is still online?
anything player stats in database will be overwritten once the player logs off, so if you make changes while the player is still online it won't matter
this is how you'd do it directly on the character while it's online
Lua:
player:setMaxHealth(player:getMaxHealth() + 10000)
player:addHealth(10000)
player:setMaxMana(player:getMaxMana() + 10000)
player:addMana(10000)
 
Back
Top