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

RevScripts Reset system talkaction

Joined
Mar 7, 2017
Messages
46
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 =...
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
 
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
 
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).
 
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.
 
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
 
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
 
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
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?
 
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
 
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()


me da error ami en la base tfs 1.5

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

local config = {
    storageResets = 525,
    backToLevel = 8,
    redskull = true,
    battle = true,
    pz = false,
    defaultGainMaxHealth = 0.3,
    defaultGainMaxMana = 0.3,
    resetCostItemId = 2160, -- Item ID required for reset
    resetCostAmount = 1, -- Amount of item required for reset
    stages = {
        {levelRequired = 20, cost = 1, expBonus = 0.10, damageBonus = 0.10}, -- Reset 1 - 20
        {levelRequired = 25, cost = 2, expBonus = 0.20, damageBonus = 0.20}, -- Reset 21 - 40
        {levelRequired = 30, cost = 3, expBonus = 0.30, damageBonus = 0.30}, -- Reset 41 - 60
        -- Add more stages as needed
    }
}

-- Function to get experience required for a specific level
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)
    -- Check if the player meets reset conditions
    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

    -- Find the appropriate stage based on player's resets
    local playerResets = math.max(0, player:getStorageValue(config.storageResets))
    local stage = nil
    for _, _stage in pairs(config.stages) do
        if playerResets < _stage.levelRequired then
            stage = _stage
            break
        end
    end

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

    -- Check if the player has the required level
    local playerLevel = player:getLevel()
    if playerLevel < stage.levelRequired then
        player:sendCancelMessage("You need to be level " .. stage.levelRequired .. " or higher to reset.")
        return false
    end

    -- Check if the player has enough money to perform the reset
    if not player:removeItem(config.resetCostItemId, stage.cost) then
        player:sendCancelMessage("You need " .. stage.cost .. " of item " .. config.resetCostItemId .. " to perform the reset.")
        return false
    end

    -- Perform the reset
    playerResets = playerResets + 1
    player:setStorageValue(config.storageResets, playerResets)
    player:removeExperience(getExperienceForLevel(playerLevel) - getExperienceForLevel(config.backToLevel))
   
    -- Apply bonuses
    local expBonus = stage.expBonus
    local damageBonus = stage.damageBonus
    -- Apply bonuses here as needed

    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()
 

Attachments

me da error ami en la base tfs 1.5

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

local config = {
    storageResets = 525,
    backToLevel = 8,
    redskull = true,
    battle = true,
    pz = false,
    defaultGainMaxHealth = 0.3,
    defaultGainMaxMana = 0.3,
    resetCostItemId = 2160, -- Item ID required for reset
    resetCostAmount = 1, -- Amount of item required for reset
    stages = {
        {levelRequired = 20, cost = 1, expBonus = 0.10, damageBonus = 0.10}, -- Reset 1 - 20
        {levelRequired = 25, cost = 2, expBonus = 0.20, damageBonus = 0.20}, -- Reset 21 - 40
        {levelRequired = 30, cost = 3, expBonus = 0.30, damageBonus = 0.30}, -- Reset 41 - 60
        -- Add more stages as needed
    }
}

-- Function to get experience required for a specific level
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)
    -- Check if the player meets reset conditions
    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

    -- Find the appropriate stage based on player's resets
    local playerResets = math.max(0, player:getStorageValue(config.storageResets))
    local stage = nil
    for _, _stage in pairs(config.stages) do
        if playerResets < _stage.levelRequired then
            stage = _stage
            break
        end
    end

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

    -- Check if the player has the required level
    local playerLevel = player:getLevel()
    if playerLevel < stage.levelRequired then
        player:sendCancelMessage("You need to be level " .. stage.levelRequired .. " or higher to reset.")
        return false
    end

    -- Check if the player has enough money to perform the reset
    if not player:removeItem(config.resetCostItemId, stage.cost) then
        player:sendCancelMessage("You need " .. stage.cost .. " of item " .. config.resetCostItemId .. " to perform the reset.")
        return false
    end

    -- Perform the reset
    playerResets = playerResets + 1
    player:setStorageValue(config.storageResets, playerResets)
    player:removeExperience(getExperienceForLevel(playerLevel) - getExperienceForLevel(config.backToLevel))
 
    -- Apply bonuses
    local expBonus = stage.expBonus
    local damageBonus = stage.damageBonus
    -- Apply bonuses here as needed

    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()
You are missing the most important part of the script she wrote......
Lua:
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
 
Te perdiendo la parte más importante del guión que ella escribió...
[CÓDIGO=lua]maxHealthlocal = jugador:getMaxHealth()
maxMana local = jugador:getMaxMana()
local nuevoMaxHealth = 0
local nuevoMaxMana = 0
si stage.gainMaxHealth entonces
newMaxHealth = maxHealth + math.ceil(maxHealth * stage.gainMaxHealth)
demás
newMaxHealth = maxHealth + math.ceil(maxHealth * config.defaultGainMaxHealth)
aleta

si stage.gainMaxMana entonces
nuevoMaxMana = maxMana + math.ceil(maxMana * stage.gainMaxMana)
demás
newMaxMana = maxMana + math.ceil(maxMana * config.defaultGainMaxMana)
fin[/CÓDIGO]

sigue dando el error


Lua:
restablecimiento localSys = TalkAction("!reset")

configuración local = {
    reinicios de almacenamiento = 520,
    volver al nivel = 8,
    cráneo rojo = verdadero,
    batalla = verdadero,
    pz = falso,
    defaultGainMaxHealth = 0,3,
    defaultGainMaxMana = 0,3,
    resetCostItemId = 2160, -- Se requiere ID de artículo para restablecer
    resetCostAmount = 1, -- Cantidad de artículo requerido para restablecer
    etapas = {
        {nivelRequerido = 10, costo = 1, bonificación de exp = 0,10, bonificación de daño = 0,10}, - Restablecer 1 - 20
        {levelRequired = 15, costo = 2, expBonus = 0,20, DamageBonus = 0,20}, - Restablecer 21 - 40
        {levelRequired = 20, costo = 3, expBonus = 0,30, DamageBonus = 0,30}, - Restablecer 41 - 60
        -- Agregue más etapas según sea necesario
    }
}

- Función para obtener la experiencia requerida para un nivel específico.
función local getExperienceForLevel(lv)
    nivel = nivel - 1
    retorno ((50 * lv * lv * lv) - (150 * lv * lv) + (400 * lv)) / 3
fin

función resetSys.onSay(jugador, palabras, parámetro)
    -- Verifique si el reproductor cumple con las condiciones de reinicio
    si config.redskull y player:getSkull() == 4 entonces
        player:sendCancelMessage("Debes no tener la calavera roja para reiniciar.")
        falso retorno
    elseif config.pz y no getTilePzInfo(player:getPosition()) entonces
        player:sendCancelMessage("Debes estar en la zona de protección para reiniciar.")
        falso retorno
    elseif config.battle y player:getCondition(CONDITION_INFIGHT) entonces
        player:sendCancelMessage("Debes estar sin batalla para reiniciar.")
        falso retorno
    fin

    - Encuentra la etapa apropiada según los reinicios del jugador.
    playerResets local = math.max(0, jugador:getStorageValue(config.storageResets))
    etapa local = nula
    para _, _stage en pares (config.stages) hacer
        si playerResets < _stage.levelRequired entonces
            etapa = _etapa
            romper
        fin
    fin

    Si no es escenario entonces
        print("[Advertencia - ResetSystem::onSay] Etapa no encontrada para el reproductor: " .. player:getName())
        falso retorno
    fin

    -- Comprueba si el jugador tiene el nivel requerido.
    nivel de jugador local = jugador:getLevel()
    si playerLevel < stage.levelRequired entonces
        player:sendCancelMessage("Debes tener el nivel " .. stage.levelRequired .. " o superior para restablecer".)
        falso retorno
    fin

    -- Comprueba si el jugador tiene suficiente dinero para realizar el reinicio.
    si no es jugador: removeItem(config.resetCostItemId, stage.cost) entonces
        player:sendCancelMessage("Necesita " .. stage.cost .. " del elemento " .. config.resetCostItemId .. " para realizar el reinicio.")
        falso retorno
    fin

    -- Realizar el reinicio
    reinicios de jugador = reinicios de jugador + 1
    jugador:setStorageValue(config.storageResets, playerResets)
    jugador:removeExperience(getExperienceForLevel(playerLevel) - getExperienceForLevel(config.backToLevel))
    
    - Aplicar bonificaciones
    expBonus local = etapa.expBonus
    Bonus de daño local = stage.damageBonus
    maxHealth local = jugador:getMaxHealth()
    maxMana local = jugador:getMaxMana()
    local nuevoMaxHealth = 2
    local nuevoMaxMana = 2
    si stage.gainMaxHealth entonces
        newMaxHealth = maxHealth + math.ceil(maxHealth * stage.gainMaxHealth)
    demás
        newMaxHealth = maxHealth + math.ceil(maxHealth * config.defaultGainMaxHealth)
    fin

    si stage.gainMaxMana entonces
        nuevoMaxMana = maxMana + math.ceil(maxMana * stage.gainMaxMana)
    demás
        newMaxMana = maxMana + math.ceil(maxMana * config.defaultGainMaxMana)
    fin
    - Aplicar bonificaciones aquí según sea necesario

    jugador:setMaxHealth(nuevoMaxHealth)
    jugador:setMaxMana(nuevoMaxMana)
    jugador:addHealth(newMaxHealth)
    jugador: agregarMana (nuevoMaxMana)
    jugador:getPosition():sendMagicEffect(CONST_ME_FIREWORK_RED)
    player:sendTextMessage(MESSAGE_INFO_DESCR, "Ahora tienes " .. playerResets .. " " .. (playerResets == 1 y "reset" o "resets") .. ".")
    falso retorno
fin

resetSys:registro()

[/CÓDIGO]
Post automatically merged:

se podria hacer que sea por vocation dependiendo la vocation te de mas vida o mana


intente con ayuda del chatgp pero no jala no da la vida ni la mana


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

local CONFIG = {
    STORAGE_RESETS = 530,
    BACK_TO_LEVEL = 8,
    REDSKULL = true,
    BATTLE = true,
    PZ = false,
    DEFAULT_GAIN_MAX_HEALTH = 0.1,
    DEFAULT_GAIN_MAX_MANA = 0.1,
    STAGES = {
        {resets = 5, level = 10, premium = 14, storage = 101},
        {resets = 10, level = 15, premium = 19, storage = 201},
        {resets = 15, level = 20, premium = 29, storage = 301},
        {resets = 20, level = 30, premium = 39, storage = 401},
        {resets = 30, level = 40, premium = 49, storage = 501},
        {resets = math.huge, level = 40, premium = 50, storage = 601}
    }
}

local function getExperienceForLevel(level)
    return ((50 * (level - 1) ^ 3) - (150 * (level - 1) ^ 2) + (400 * (level - 1))) / 3
end

local function canResetPlayer(player)
    if CONFIG.REDSKULL and player:getSkull() == SKULL_RED 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
    return true
end

function RESET_SYS.onSay(player, words, param)
    if not canResetPlayer(player) then
        return false
    end

    local playerResets = math.max(0, player:getStorageValue(CONFIG.STORAGE_RESETS))
    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.STORAGE_RESETS, playerResets)
    player:removeExperience(getExperienceForLevel(playerLevel) - getExperienceForLevel(CONFIG.BACK_TO_LEVEL))
    
    local maxHealth = player:getMaxHealth()
    local maxMana = player:getMaxMana()
    local newMaxHealth = stage.gainMaxHealth or (maxHealth * (1 + CONFIG.DEFAULT_GAIN_MAX_HEALTH))
    local newMaxMana = stage.gainMaxMana or (maxMana * (1 + CONFIG.DEFAULT_GAIN_MAX_MANA))

    -- Determinar el aumento de HP y MP según la vocación del jugador
    local vocHealthBonus = 0
    local vocManaBonus = 0
    local playerVocation = player:getVocation():getId()
    if playerVocation == 3 or playerVocation == 4 then -- Paladin or Knight
        vocHealthBonus = 50
        vocManaBonus = 30
    elseif playerVocation == 1 or playerVocation == 2 then -- Sorcerer or Druid
        vocHealthBonus = 30
        vocManaBonus = 50
    end

    player:setMaxHealth(maxHealth + newMaxHealth + vocHealthBonus)
    player:setMaxMana(maxMana + newMaxMana + vocManaBonus)
    player:addHealth(newMaxHealth + vocHealthBonus)
    player:addMana(newMaxMana + vocManaBonus)
    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

RESET_SYS:register()
 

Attachments

Last edited:
Back
Top