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

TFS 1.X+ TFS 1.3 Reset character hp, mana and level to 8

TomBartezz

Member
Joined
May 29, 2016
Messages
159
Reaction score
17
Can anyone help me make a script if this is not going to bug? I am currently testing monsters in my ot and I want to reset players back to level 8 and other levels, I guess if I have the script for a level 8 I will know how to make the other level resets, when I mean reset, the mana and hp also resets too so it wont bug out the database or anything.

I have something like this so far, but I have no idea how to make a character reset back to level 8 with default mana and hp, and being kicked too after they reset using an item.
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerLevel(cid) == 8 then
        doCreatureSay(cid, 'You have reverted to level 8!', TALKTYPE_ORANGE_1)
        doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)
        return true
    else
        doCreatureSay(cid, 'You are the lowest level!', TALKTYPE_ORANGE_1)
    end
end
 
DEFINITELY THERE IS BETTER WAY TO DO IT LMAO, but I'm so bad with sql that this is all that I have:

change the 'Your character name' at the end of the query to the desired one, make sure the character is offline and execute it on your database via phpmyadmin or equivalent:

SQL:
UPDATE `players` SET `level` = '8', `health` = '185', `healthmax` = '185', `experience` = '4200', `maglevel` = '0', `mana` = '90', `manamax` = '90', `manaspent` = '0', `cap` = '470', `skill_fist` = '10', `skill_fist_tries` = '0', `skill_club` = '10', `skill_club_tries` = '0', `skill_sword` = '10', `skill_sword_tries` = '0', `skill_axe` = '10', `skill_axe_tries` = '0', `skill_dist` = '10', `skill_dist_tries` = '0', `skill_shielding` = '10', `skill_shielding_tries` = '0', `skill_fishing` = '10', `skill_fishing_tries` = '0' WHERE `players`.`name` = 'Your Character name';

please someone give this a proper query 😂🤣
 
Can anyone help me make a script if this is not going to bug? I am currently testing monsters in my ot and I want to reset players back to level 8 and other levels, I guess if I have the script for a level 8 I will know how to make the other level resets, when I mean reset, the mana and hp also resets too so it wont bug out the database or anything.

I have something like this so far, but I have no idea how to make a character reset back to level 8 with default mana and hp, and being kicked too after they reset using an item.
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerLevel(cid) == 8 then
        doCreatureSay(cid, 'You have reverted to level 8!', TALKTYPE_ORANGE_1)
        doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)
        return true
    else
        doCreatureSay(cid, 'You are the lowest level!', TALKTYPE_ORANGE_1)
    end
end
You are looking for THIS. Will change Level, Hp and Mana. If you need reset skills and/or Cap(i guess) too, just use the querys that @Evil Puncker sended above.
 

player:setMaxMana(maxMana)
creature:setMaxHealth(maxHealth)
Unfortunately, there is no ability to set skills/mlvl using lua
@Evil Puncker solution probaby is best solution, combination of talkaction and db.query will let you set player lvl without using database in web browser
Revscript
Lua:
local resetChar = TalkAction("/resChar")

function resetChar.onSay(player, words, param)
    if not player:getGroup():getAccess() or player:getAccountType() < ACCOUNT_TYPE_GOD then
        return true
    end
    local target = Player(param)
    if target then
        player:sendCancelMessage("Player online, please kick him!.")
        return false
    end

    db.asyncQuery(UPDATE `players` SET `level` = '8', `health` = '185', `healthmax` = '185', `experience` = '4200', `maglevel` = '0', `mana` = '90', `manamax` = '90', `manaspent` = '0', `cap` = '470', `skill_fist` = '10', `skill_fist_tries` = '0', `skill_club` = '10', `skill_club_tries` = '0', `skill_sword` = '10', `skill_sword_tries` = '0', `skill_axe` = '10', `skill_axe_tries` = '0', `skill_dist` = '10', `skill_dist_tries` = '0', `skill_shielding` = '10', `skill_shielding_tries` = '0', `skill_fishing` = '10', `skill_fishing_tries` = '0' WHERE `players`.`name` = param;)
    return false
end

resetChar:separator(" ")
resetChar:register()


written without tests so it may not work but will let you get thinking
 
Unfortunately, there is no ability to set skills/mlvl using lua
maybe 🤔
Lua:
function Player.addSkill(self, skillId, amount)
    return self:addSkillTries(skillId, self:getVocation():getRequiredSkillTries(skillId, self:getSkillLevel(skillId) + amount) - self:getSkillTries(skillId))
end

function Player.addMagicLevel(self, amount)
    self:addManaSpent(self:getVocation():getRequiredManaSpent(self:getBaseMagicLevel() + amount + 1) - self:getManaSpent())
end

and you can kick the target player with your script by using target:remove() and then executing the query
 
I just need it to reset the character back to level 8, the magic doesn't matter that much I think, but I get this error when I try it
Lua:
[Warning - Event::checkScript] Can not load script: scripts/resetchar.lua
data/talkactions/scripts/resetchar.lua:10: ')' expected near '`'
With this code
Code:
local resetChar = TalkAction("/resChar")

function resetChar.onSay(player, words, param)
    if not player:getGroup():getAccess() or player:getAccountType() < ACCOUNT_TYPE_GOD then
        return true
    end
    local target = Player(param)
    target:remove()

    db.asyncQuery(UPDATE `players` SET `level` = '8', `health` = '185', `healthmax` = '185', `experience` = '4200', `maglevel` = '0', `mana` = '90', `manamax` = '90', `manaspent` = '0', `cap` = '470', `skill_fist` = '10', `skill_fist_tries` = '0', `skill_club` = '10', `skill_club_tries` = '0', `skill_sword` = '10', `skill_sword_tries` = '0', `skill_axe` = '10', `skill_axe_tries` = '0', `skill_dist` = '10', `skill_dist_tries` = '0', `skill_shielding` = '10', `skill_shielding_tries` = '0', `skill_fishing` = '10', `skill_fishing_tries` = '0' WHERE `players`.`name` = param;)
    return false
    doCreatureSay(cid, 'You have reverted ..Player(param) .. back to level 8!', TALKTYPE_ORANGE_1)
end

resetChar:separator(" ")
resetChar:register()

talkactions.xml
Code:
    <talkaction words="/resChar" separator=" " script="resetchar.lua" />
 
Is it possible to turn this into an item which also removes 1 item when it is used, whereas any player can use it instead of a command?
 
@TomBartezz it is a revscript you should put it inside data/scripts folder, not anywhere else, try this:
Lua:
local resetChar = TalkAction("/resChar")

function resetChar.onSay(player, words, param)
    local playerId = player:getId()
    player:remove()
    db.query("UPDATE `players` SET `level` = '8', `health` = '185', `healthmax` = '185', `experience` = '4200', `maglevel` = '0', `mana` = '90', `manamax` = '90', `manaspent` = '0', `cap` = '470', `skill_fist` = '10', `skill_fist_tries` = '0', `skill_club` = '10', `skill_club_tries` = '0', `skill_sword` = '10', `skill_sword_tries` = '0', `skill_axe` = '10', `skill_axe_tries` = '0', `skill_dist` = '10', `skill_dist_tries` = '0', `skill_shielding` = '10', `skill_shielding_tries` = '0', `skill_fishing` = '10', `skill_fishing_tries` = '0' WHERE `id` = " .. playerId)
    return false
end

resetChar:register()

@MopdaAll
yes it is possible, something like this (put on your data/scripts folder):
Lua:
local resetChar = TalkAction("/reset")

function resetChar.onSay(player, words, param)
    if player:getItemCount(1111) > 0 then
        player:removeItem(1111, 1)
        player:remove()
        db.query("UPDATE `players` SET `level` = '8', `health` = '185', `healthmax` = '185', `experience` = '4200', `maglevel` = '0', `mana` = '90', `manamax` = '90', `manaspent` = '0', `cap` = '470', `skill_fist` = '10', `skill_fist_tries` = '0', `skill_club` = '10', `skill_club_tries` = '0', `skill_sword` = '10', `skill_sword_tries` = '0', `skill_axe` = '10', `skill_axe_tries` = '0', `skill_dist` = '10', `skill_dist_tries` = '0', `skill_shielding` = '10', `skill_shielding_tries` = '0', `skill_fishing` = '10', `skill_fishing_tries` = '0' WHERE `name` = " .. player:getName())
    else
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need item XXX to reset!")
    end
    return false
end

resetChar:register()
 
Last edited by a moderator:
@TomBartezz it is a revscript you should put it inside data/scripts folder, not anywhere else, try this:
Lua:
local resetChar = TalkAction("/resChar")

function resetChar.onSay(player, words, param)
    if not player:getGroup():getAccess() or player:getAccountType() < ACCOUNT_TYPE_GOD then
        return true
    end
    local target = Player(param)
    target:remove()

    db.query("UPDATE `players` SET `level` = '8', `health` = '185', `healthmax` = '185', `experience` = '4200', `maglevel` = '0', `mana` = '90', `manamax` = '90', `manaspent` = '0', `cap` = '470', `skill_fist` = '10', `skill_fist_tries` = '0', `skill_club` = '10', `skill_club_tries` = '0', `skill_sword` = '10', `skill_sword_tries` = '0', `skill_axe` = '10', `skill_axe_tries` = '0', `skill_dist` = '10', `skill_dist_tries` = '0', `skill_shielding` = '10', `skill_shielding_tries` = '0', `skill_fishing` = '10', `skill_fishing_tries` = '0' WHERE `name` = " .. param)
    player:say("You have reverted " .. target .. " back to level 8!", TALKTYPE_MONSTER_SAY)
    return false
end

resetChar:separator(" ")
resetChar:register()

@MopdaAll
yes it is possible, something like this (put on your data/scripts folder):
Lua:
local resetChar = TalkAction("/reset")

function resetChar.onSay(player, words, param)
    if player:getItemCount(1111) > 0 then
        player:removeItem(1111, 1)
        player:remove()
        db.query("UPDATE `players` SET `level` = '8', `health` = '185', `healthmax` = '185', `experience` = '4200', `maglevel` = '0', `mana` = '90', `manamax` = '90', `manaspent` = '0', `cap` = '470', `skill_fist` = '10', `skill_fist_tries` = '0', `skill_club` = '10', `skill_club_tries` = '0', `skill_sword` = '10', `skill_sword_tries` = '0', `skill_axe` = '10', `skill_axe_tries` = '0', `skill_dist` = '10', `skill_dist_tries` = '0', `skill_shielding` = '10', `skill_shielding_tries` = '0', `skill_fishing` = '10', `skill_fishing_tries` = '0' WHERE `name` = " .. player:getName())
    else
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need item XXX to reset!")
    end
    return false
end

resetChar:register()

I get these errors now, I also just realized that a player should be able to do it without being a staff member.
Lua:
[Error - mysql_real_query] Query: UPDATE `players` SET `level` = '8', `health` = '185', `healthmax` = '185', `experience` = '4200', `maglevel` = '0', `mana` = '90', `manamax` = '90', `manaspent` = '0', `cap` = '470', `skill_fist` = '10', `skill_fist_tries` = '0', `skill_club` = '10', `skil
Message: Unknown column 'Awkfark' in 'where clause'

Lua Script Error: [Scripts Interface]
/home/pi/forgottenserver/data/scripts/reschar.lua:callback
/home/pi/forgottenserver/data/scripts/reschar.lua:11: attempt to concatenate local 'target' (a userdata value)
stack traceback:
    [C]: in function '__concat'
    /home/pi/forgottenserver/data/scripts/reschar.lua:11: in function </home/pi/forgottenserver/data/scripts/reschar.lua:3>

Will this work for a player? like a player says /resChar that player will revert back to lvl 8 themselves, and they don't need a because they are doing it to themself
Lua:
local resetChar = TalkAction("/resChar")

function resetChar.onSay(player, words, param)
    local target = Player(param)
    target:remove()

    db.query("UPDATE `players` SET `level` = '8', `health` = '185', `healthmax` = '185', `experience` = '4200', `maglevel` = '0', `mana` = '90', `manamax` = '90', `manaspent` = '0', `cap` = '470', `skill_fist` = '10', `skill_fist_tries` = '0', `skill_club` = '10', `skill_club_tries` = '0', `skill_sword` = '10', `skill_sword_tries` = '0', `skill_axe` = '10', `skill_axe_tries` = '0', `skill_dist` = '10', `skill_dist_tries` = '0', `skill_shielding` = '10', `skill_shielding_tries` = '0', `skill_fishing` = '10', `skill_fishing_tries` = '0' WHERE `name` = " .. param)
    player:say("You have reverted " .. target .. " back to level 8!", TALKTYPE_MONSTER_SAY)
    return false
end

resetChar:register()
 
I get these errors now, I also just realized that a player should be able to do it without being a staff member.
Lua:
[Error - mysql_real_query] Query: UPDATE `players` SET `level` = '8', `health` = '185', `healthmax` = '185', `experience` = '4200', `maglevel` = '0', `mana` = '90', `manamax` = '90', `manaspent` = '0', `cap` = '470', `skill_fist` = '10', `skill_fist_tries` = '0', `skill_club` = '10', `skil
Message: Unknown column 'Awkfark' in 'where clause'

Lua Script Error: [Scripts Interface]
/home/pi/forgottenserver/data/scripts/reschar.lua:callback
/home/pi/forgottenserver/data/scripts/reschar.lua:11: attempt to concatenate local 'target' (a userdata value)
stack traceback:
    [C]: in function '__concat'
    /home/pi/forgottenserver/data/scripts/reschar.lua:11: in function </home/pi/forgottenserver/data/scripts/reschar.lua:3>

Will this work for a player? like a player says /resChar that player will revert back to lvl 8 themselves, and they don't need a because they are doing it to themself
Lua:
local resetChar = TalkAction("/resChar")

function resetChar.onSay(player, words, param)
    local target = Player(param)
    target:remove()

    db.query("UPDATE `players` SET `level` = '8', `health` = '185', `healthmax` = '185', `experience` = '4200', `maglevel` = '0', `mana` = '90', `manamax` = '90', `manaspent` = '0', `cap` = '470', `skill_fist` = '10', `skill_fist_tries` = '0', `skill_club` = '10', `skill_club_tries` = '0', `skill_sword` = '10', `skill_sword_tries` = '0', `skill_axe` = '10', `skill_axe_tries` = '0', `skill_dist` = '10', `skill_dist_tries` = '0', `skill_shielding` = '10', `skill_shielding_tries` = '0', `skill_fishing` = '10', `skill_fishing_tries` = '0' WHERE `name` = " .. param)
    player:say("You have reverted " .. target .. " back to level 8!", TALKTYPE_MONSTER_SAY)
    return false
end

resetChar:register()
I've updated the previous script, try now
 
I've updated the previous script, try now

i don't get the db error anymore but I get this error
Lua:
Lua Script Error: [Scripts Interface]
/home/pi/forgottenserver/data/scripts/reschar.lua:callback
/home/pi/forgottenserver/data/scripts/reschar.lua:5: attempt to concatenate a nil value
stack traceback:
    [C]: in function '__concat'
    /home/pi/forgottenserver/data/scripts/reschar.lua:5: in function </home/pi/forgottenserver/data/scripts/reschar.lua:3>
 
i don't get the db error anymore but I get this error
Lua:
Lua Script Error: [Scripts Interface]
/home/pi/forgottenserver/data/scripts/reschar.lua:callback
/home/pi/forgottenserver/data/scripts/reschar.lua:5: attempt to concatenate a nil value
stack traceback:
    [C]: in function '__concat'
    /home/pi/forgottenserver/data/scripts/reschar.lua:5: in function </home/pi/forgottenserver/data/scripts/reschar.lua:3>
updated again, try
 
Hmm strange, now it just kicks the player, but then nothing happens when the player logs back in, he's still the same level and there are no errors.
try executing it directly on the phpmyadmin while the character is offline to see if the issue is the query or the script
 
try executing it directly on the phpmyadmin while the character is offline to see if the issue is the query or the script
The query seems to work, but I am not home right now and I tried logging into the account, now the characters move one square and freeze, I get a connection lost 10053 error. It also happens with every account I log in, so maybe the query is making the server bug?

Update: The query works, I just had no idea why there was a 10053 connection error because there were no bugs in the console, but the command still does not work.
 
then there is no way to use the command, only the query, it seems the problem is that the query is being executed while the character is still online (miliseconds difference) that is why it is not executing the query by the command
 
I just thought of an idea, instead of doing a query, what if I made a monster that when you die to it, you lose enough exp to go back to lvl 8, is that possible?
 
fixed tfs 1.3+ by using /resChar
place script into data/scripts, credits to Evil Puncker

Lua:
local resetChar = TalkAction("/resChar")

function resetChar.onSay(player, words, param)
    local playerId = player:getGuid()
    player:remove()  
    db.query("UPDATE `players` SET `level` = '8', `health` = '185', `healthmax` = '185', `experience` = '4200', `maglevel` = '0', `mana` = '90', `manamax` = '90', `manaspent` = '0', `cap` = '470', `skill_fist` = '10', `skill_fist_tries` = '0', `skill_club` = '10', `skill_club_tries` = '0', `skill_sword` = '10', `skill_sword_tries` = '0', `skill_axe` = '10', `skill_axe_tries` = '0', `skill_dist` = '10', `skill_dist_tries` = '0', `skill_shielding` = '10', `skill_shielding_tries` = '0', `skill_fishing` = '10', `skill_fishing_tries` = '0' WHERE `id` = " .. playerId)
    return false
end

resetChar:register()
 
Back
Top