• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

RevScripts Reset system talkaction

Joined
Mar 7, 2017
Messages
45
Solutions
1
Reaction score
6
I have this revscript, it works perfectly but the problem is that for each reset it doubles life and mana, can you help me so that it only gives you a percentage of life and mana per reset? or that only 100 more points of life and mana

By doubling the life I mean that if the character has 50k of life, when doing a reset he keeps those 50k and when he reaches the required level of reset he would already have 100k and when doing a reset he would keep those 100k

Lua:
local resetSys = TalkAction("!reset")

local config = {
    backToLevel = 8,
    redskull = true, -- need to be without redskull to reset?
    battle = true, -- need to be without battle to reset?
    pz = false, -- need to be in protect zone to reset?
    stages = {
        {resets = 4, level = 3500, premium = 3500},
        {resets = 9, level = 3600, premium = 3600},
        {resets = 14, level = 3700, premium = 3700},
        {resets = 19, level = 3800, premium = 3800},
        {resets = 24, level = 3900, premium = 3900},
        {resets = 29, level = 4000, premium = 4000},
        {resets = 34, level = 4100, premium = 4100},
        {resets = 39, level = 4200, premium = 4200},
        {resets = 44, level = 4300, premium = 4300},
        {resets = 49, level = 4400, premium = 4400},
        {resets = 54, level = 4500, premium = 4500},
        {resets = 59, level = 4600, premium = 4600},
        {resets = 64, level = 4700, premium = 4700},
        {resets = 69, level = 4800, premium = 4800},
        {resets = 74, level = 4900, premium = 4900},
        {resets = 79, level = 5000, premium = 5000},
        {resets = 84, level = 5100, premium = 5100},
        {resets = 89, level = 5200, premium = 5200},
        {resets = 94, level = 5300, premium = 5300},
        {resets = 2^1024, level = 5400, premium = 5400}
    }
}

function resetSys.onSay(player, words, param)
    local function getExperienceForLevel(lv)
        lv = lv - 1
        return ((50 * lv * lv * lv) - (150 * lv * lv) + (400 * lv)) / 3
    end
    local function getPlayerResets()
        local resets = player:getStorageValue(500)
        return resets < 0 and 0 or resets
    end
  
    local function doPlayerAddResets(count)
        player:setStorageValue(500, getPlayerResets() + count)
    end
  
    if config.redskull and player:getSkull() == 4 then
        player:sendCancelMessage("You need to be without red skull to reset.")
        return false
    elseif config.pz and not getTilePzInfo(player:getPosition()) then
        player:sendCancelMessage("You need to be in protection zone to reset.")
        return false
    elseif config.battle and player:getCondition(CONDITION_INFIGHT) then
        player:sendCancelMessage("You need to be without battle to reset.")
        return false
    end
  
    local resetLevel = 0
    for x, y in ipairs(config.stages) do
        if getPlayerResets() <= y.resets then
            resetLevel = player:isPremium() and y.premium or y.level
            break
        end
    end
  
    if getPlayerLevel(player) < resetLevel then
        player:sendCancelMessage("You need level " .. resetLevel .. " or more to reset.")
        return false
    end
  
    doPlayerAddResets(1)
    local healthMax, manaMax, health, mana = player:getMaxHealth(), player:getMaxMana(), player:getHealth(), player:getMana()
    player:removeExperience(getExperienceForLevel(player:getLevel()) - getExperienceForLevel(config.backToLevel))
    player:setMaxHealth(MaxHealth)
    player:setMaxMana(MaxMana)
    player:addHealth(health)
    player:addMana(mana)
    player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_RED)
    player:sendTextMessage(MESSAGE_INFO_DESCR, "Now you have " .. getPlayerResets() .. " " .. (getPlayerResets() == 1 and "reset" or "resets") .. ".")
    return false
end

resetSys:register()
 
Solution
I haven't tried it but it should work fine.

data/scripts/resetSys.lua
Lua:
local resetSys = TalkAction("!reset")

local config = {
    storageResets = 500,
    backToLevel = 8,
    redskull = true, -- need to be without redskull to reset?
    battle = true, -- need to be without battle to reset?
    pz = false, -- need to be in protect zone to reset?
    defaultGainMaxHealth = 0.1, -- If the stage don't have gainMaxHealth, use this value
    defaultGainMaxMana = 0.1, -- If the stage don't have gainMaxMana, use this value
    stages = {
        --[[ You can extra properties to each stage
            Example:
                {..., gainMaxHealth = 0.25 gainMaxMana = 0.25 }
        ]]--
        {resets = 4, level = 3500, premium =...
OP
OP
A
Joined
Mar 7, 2017
Messages
45
Solutions
1
Reaction score
6
So he has 50k levels and as example 300k health and after reset he has 600k?
if you have 50k of life and you resetm you keep those 50k of life, then when you go up to the level required for the next reset you would have 50k of life plus the accumulated life let's suppose another 50k, then when you reset you would already have 100k
 

Levi999x

AoT
Joined
Dec 14, 2017
Messages
2,091
Solutions
53
Reaction score
1,350
Location
Germany
if you have 50k of life and you resetm you keep those 50k of life, then when you go up to the level required for the next reset you would have 50k of life plus the accumulated life let's suppose another 50k, then when you reset you would already have 100k

I think its not possible to block it without source changes

or you change the system how people gain health and mana
Instead of XML we use LUA aka we use function onAdvance to give players health&mana like on vocation.xml
in the function we will block their gain of health and mana after first reset
If you want it, let me know
 

margoh

{{ user.title }}
Joined
Apr 1, 2013
Messages
799
Solutions
18
Reaction score
335
Lua:
player:setMaxHealth(MaxHealth)
player:setMaxMana(MaxMana)
If it resets players to lvl 8 and health/mp is the same for that lvl on every vocation, then just make calculation here.
Example for health 250 + (100 * resets).
 

Extrodus

|| Blazera.net ||
Premium User
Joined
Dec 22, 2008
Messages
2,585
Solutions
7
Reaction score
424
Location
Canada
Code:
player:setMaxHealth(185)
player:setMaxMana(35)

This would reset the players health to level 8 values; simply change them to what youd prefer if you want to say offer an extra (50hp/50mp) for resets just set 235/85 so players have small advantage when reseting.
 
OP
OP
A
Joined
Mar 7, 2017
Messages
45
Solutions
1
Reaction score
6
Code:
player:setMaxHealth(185)
player:setMaxMana(35)

This would reset the players health to level 8 values; simply change them to what youd prefer if you want to say offer an extra (50hp/50mp) for resets just set 235/85 so players have small advantage when reseting.
yes I do, but when doing resets it no longer accumulates, that is, each reset will remain in the same hp and mp that I put there instead of increasing the amount of hp and mp for each reset
Post automatically merged:

Lua:
player:setMaxHealth(MaxHealth)
player:setMaxMana(MaxMana)
If it resets players to lvl 8 and health/mp is the same for that lvl on every vocation, then just make calculation here.
Example for health 250 + (100 * resets).
yes I do, but when doing resets it no longer accumulates, that is, each reset will remain in the same hp and mp that I put there instead of increasing the amount of hp and mp for each reset
 

Levi999x

AoT
Joined
Dec 14, 2017
Messages
2,091
Solutions
53
Reaction score
1,350
Location
Germany
Margohs way or mine

Mine works simple

Instead of reseting people health to low amount back we keep their max health from first reborn and we will increase their max health
 

Sarah Wesker

ค∂vαηcε รүηтαx ❤
Support Team
Joined
Mar 16, 2017
Messages
1,185
Solutions
129
Reaction score
1,454
Location
London
GitHub
MillhioreBT
Twitch
millhiore_bt
I haven't tried it but it should work fine.

data/scripts/resetSys.lua
Lua:
local resetSys = TalkAction("!reset")

local config = {
    storageResets = 500,
    backToLevel = 8,
    redskull = true, -- need to be without redskull to reset?
    battle = true, -- need to be without battle to reset?
    pz = false, -- need to be in protect zone to reset?
    defaultGainMaxHealth = 0.1, -- If the stage don't have gainMaxHealth, use this value
    defaultGainMaxMana = 0.1, -- If the stage don't have gainMaxMana, use this value
    stages = {
        --[[ You can extra properties to each stage
            Example:
                {..., gainMaxHealth = 0.25 gainMaxMana = 0.25 }
        ]]--
        {resets = 4, level = 3500, premium = 3500},
        {resets = 9, level = 3600, premium = 3600},
        {resets = 14, level = 3700, premium = 3700},
        {resets = 19, level = 3800, premium = 3800},
        {resets = 24, level = 3900, premium = 3900},
        {resets = 29, level = 4000, premium = 4000},
        {resets = 34, level = 4100, premium = 4100},
        {resets = 39, level = 4200, premium = 4200},
        {resets = 44, level = 4300, premium = 4300},
        {resets = 49, level = 4400, premium = 4400},
        {resets = 54, level = 4500, premium = 4500},
        {resets = 59, level = 4600, premium = 4600},
        {resets = 64, level = 4700, premium = 4700},
        {resets = 69, level = 4800, premium = 4800},
        {resets = 74, level = 4900, premium = 4900},
        {resets = 79, level = 5000, premium = 5000},
        {resets = 84, level = 5100, premium = 5100},
        {resets = 89, level = 5200, premium = 5200},
        {resets = 94, level = 5300, premium = 5300},
        {resets = math.huge, level = 5400, premium = 5400}
    }
}

local function getExperienceForLevel(lv)
    lv = lv - 1
    return ((50 * lv * lv * lv) - (150 * lv * lv) + (400 * lv)) / 3
end

function resetSys.onSay(player, words, param) 
    if config.redskull and player:getSkull() == 4 then
        player:sendCancelMessage("You need to be without red skull to reset.")
        return false
    elseif config.pz and not getTilePzInfo(player:getPosition()) then
        player:sendCancelMessage("You need to be in protection zone to reset.")
        return false
    elseif config.battle and player:getCondition(CONDITION_INFIGHT) then
        player:sendCancelMessage("You need to be without battle to reset.")
        return false
    end

    local playerResets = math.max(0, player:getStorageValue(config.storageResets))
    local stage = nil
    for _, _stage in pairs(config.stages) do
        if playerResets <= _stage.resets then
            stage = _stage
            break
        end
    end

    if not stage then
        print("[Warning - ResetSystem::onSay] Stage not found for player: " .. player:getName())
        return false
    end

    local resetLevel = player:isPremium() and stage.premium or stage.level
    local playerLevel = player:getLevel()
    if playerLevel < resetLevel then
        player:sendCancelMessage("You need level " .. resetLevel .. " or more to reset.")
        return false
    end

    playerResets = playerResets + 1
    player:setStorageValue(config.storageResets, playerResets)
    player:removeExperience(getExperienceForLevel(playerLevel) - getExperienceForLevel(config.backToLevel))
    local maxHealth = player:getMaxHealth()
    local maxMana = player:getMaxMana()
    local newMaxHealth = 0
    local newMaxMana = 0
    if stage.gainMaxHealth then
        newMaxHealth = maxHealth + math.ceil(maxHealth * stage.gainMaxHealth)
    else
        newMaxHealth = maxHealth + math.ceil(maxHealth * config.defaultGainMaxHealth)
    end

    if stage.gainMaxMana then
        newMaxMana = maxMana + math.ceil(maxMana * stage.gainMaxMana)
    else
        newMaxMana = maxMana + math.ceil(maxMana * config.defaultGainMaxMana)
    end

    player:setMaxHealth(newMaxHealth)
    player:setMaxMana(newMaxMana)
    player:addHealth(newMaxHealth)
    player:addMana(newMaxMana)
    player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_RED)
    player:sendTextMessage(MESSAGE_INFO_DESCR, "Now you have " .. playerResets .. " " .. (playerResets == 1 and "reset" or "resets") .. ".")
    return false
end

resetSys:register()
 
Last edited:
Solution
OP
OP
A
Joined
Mar 7, 2017
Messages
45
Solutions
1
Reaction score
6
I haven't tried it but it should work fine.

data/scripts/resetSys.lua
Lua:
local resetSys = TalkAction("!reset")

local config = {
    storageResets = 500,
    backToLevel = 8,
    redskull = true, -- need to be without redskull to reset?
    battle = true, -- need to be without battle to reset?
    pz = false, -- need to be in protect zone to reset?
    defaultGainMaxHealth = 0.1, -- If the stage don't have gainMaxHealth, use this value
    defaultGainMaxMana = 0.1, -- If the stage don't have gainMaxMana, use this value
    stages = {
        --[[ You can extra properties to each stage
            Example:
                {..., gainMaxHealth = 0.25 gainMaxMana = 0.25 }
        ]]--
        {resets = 4, level = 3500, premium = 3500},
        {resets = 9, level = 3600, premium = 3600},
        {resets = 14, level = 3700, premium = 3700},
        {resets = 19, level = 3800, premium = 3800},
        {resets = 24, level = 3900, premium = 3900},
        {resets = 29, level = 4000, premium = 4000},
        {resets = 34, level = 4100, premium = 4100},
        {resets = 39, level = 4200, premium = 4200},
        {resets = 44, level = 4300, premium = 4300},
        {resets = 49, level = 4400, premium = 4400},
        {resets = 54, level = 4500, premium = 4500},
        {resets = 59, level = 4600, premium = 4600},
        {resets = 64, level = 4700, premium = 4700},
        {resets = 69, level = 4800, premium = 4800},
        {resets = 74, level = 4900, premium = 4900},
        {resets = 79, level = 5000, premium = 5000},
        {resets = 84, level = 5100, premium = 5100},
        {resets = 89, level = 5200, premium = 5200},
        {resets = 94, level = 5300, premium = 5300},
        {resets = math.huge, level = 5400, premium = 5400}
    }
}

local function getExperienceForLevel(lv)
    lv = lv - 1
    return ((50 * lv * lv * lv) - (150 * lv * lv) + (400 * lv)) / 3
end

function resetSys.onSay(player, words, param) 
    if config.redskull and player:getSkull() == 4 then
        player:sendCancelMessage("You need to be without red skull to reset.")
        return false
    elseif config.pz and not getTilePzInfo(player:getPosition()) then
        player:sendCancelMessage("You need to be in protection zone to reset.")
        return false
    elseif config.battle and player:getCondition(CONDITION_INFIGHT) then
        player:sendCancelMessage("You need to be without battle to reset.")
        return false
    end
 
    local playerResets = math.max(0, player:getStorageValue(config.storageResets))
    local stage = nil
    for _, _stage in pairs(config.stages) do
        if playerResets <= _stage.resets then
            stage = _stage
            break
        end
    end

    if not stage then
        print("[Warning - ResetSystem::onSay] Stage not found for player: " .. player:getName())
        return false
    end
 
    local resetLevel = player:isPremium() and stage.premium or stage.level
    local playerLevel = player:getLevel()
    if playerLevel < resetLevel then
        player:sendCancelMessage("You need level " .. resetLevel .. " or more to reset.")
        return false
    end
 
    playerResets = playerResets + 1
    player:setStorageValue(config.storageResets, playerResets)
    player:removeExperience(getExperienceForLevel(playerLevel) - getExperienceForLevel(config.backToLevel))
    local maxHealth = player:getMaxHealth()
    local maxMana = player:getMaxMana()
    local newMaxHealth = maxHealth * config.defaultGainMaxHealth
    local newMaxMana = maxMana * config.defaultGainMaxMana
    if stage.gainMaxHealth then
        newMaxHealth = maxHealth * stage.gainMaxHealth
    end
    if stage.gainMaxMana then
        newMaxMana = maxMana * stage.gainMaxMana
    end
    player:setMaxHealth(newMaxHealth)
    player:setMaxMana(newMaxMana)
    player:addHealth(newMaxHealth)
    player:addMana(newMaxMana)
    player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_RED)
    player:sendTextMessage(MESSAGE_INFO_DESCR, "Now you have " .. playerResets .. " " .. (playerResets == 1 and "reset" or "resets") .. ".")
    return false
end

resetSys:register()
It did not work, at the first reset 3500 I returned to level 8 with 5 life and 2 mana, at the second reset I returned with 2 life and 0 mana and at the third reset I returned to 1 life and 0 mana, do i need to configure anything else?
 

Sarah Wesker

ค∂vαηcε รүηтαx ❤
Support Team
Joined
Mar 16, 2017
Messages
1,185
Solutions
129
Reaction score
1,454
Location
London
GitHub
MillhioreBT
Twitch
millhiore_bt
It did not work, at the first reset 3500 I returned to level 8 with 5 life and 2 mana, at the second reset I returned with 2 life and 0 mana and at the third reset I returned to 1 life and 0 mana, do i need to configure anything else?
Recopy the code I posted, I forget to add the sum of the maxHealth + newMaxHealth
 
Top