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

Reborn problem tfs 1.3

jareczekjsp

Member
Joined
Jan 30, 2023
Messages
213
Reaction score
14
GitHub
Jarek123
Hello I have revescript reborn give damage and exp +10 all resets
and I have problem I would like when player make reset back to level 8 with hp150 and mana 35 with bonuses(damage and exp) can somebody help me ?please

My script

Lua:
local config = {
    talk = "!reset",
    storageResets = 525000,
    backToLevel = 8,
    redskull = true,
    battle = true,
    pz = true,
    defaultGainMaxHealth = 0.3,
    defaultGainMaxMana = 0.3,
    resetCostItemId = 2157, -- Item ID required for reset
    resetCostAmount = 100, -- Amount of item required for reset
    expBonus = 10, -- Initial experience bonus in percentage (10%)
    damageBonus = 10, -- Initial damage bonus in percentage (10%)
    stages = {
        {levelRequired = 2000, cost = 100},
        {levelRequired = 3000, cost = 100},
        {levelRequired = 4000, cost = 100},
        {levelRequired = 5000, cost = 100},
        -- 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

local resetSys = TalkAction(config.talk)
function resetSys.onSay(player, words, param)
    -- Check if the player meets reset conditions
    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 a protection zone to reset.")
        return false
    elseif config.battle and player:getCondition(CONDITION_INFIGHT) then
        player:sendCancelMessage("You need to be out of 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 ipairs(config.stages) do
        if playerResets < _stage.levelRequired then
            stage = _stage
            break
        end
    end

    if not stage then
        player:sendCancelMessage("Stage not found for your resets.")
        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 items to perform the reset
    if not player:removeItem(config.resetCostItemId, config.resetCostAmount) then
        player:sendCancelMessage("You need " .. config.resetCostAmount .. " 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))
 
    local maxHealth = player:getMaxHealth()
    local maxMana = player:getMaxMana()
    local newMaxHealth = maxHealth + math.ceil(maxHealth * config.defaultGainMaxHealth)
    local newMaxMana = maxMana + math.ceil(maxMana * config.defaultGainMaxMana)

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

local ec = EventCallback
ec.onGainExperience = function(self, source, exp, rawExp)
    if not source:isMonster() then
        return exp
    end

    local playerResets = math.max(0, self:getStorageValue(config.storageResets))
    local bonusPercent = playerResets * config.expBonus
    local percent = 1 + (bonusPercent / 100)

    exp = exp * percent
    
    return exp
end
ec:register()

local resetSysEvent = CreatureEvent("resetSys")
function resetSysEvent.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if not creature or not attacker then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end
    
    local playerResets = 0
    if attacker:isPlayer() then
        playerResets = attacker:getStorageValue(config.storageResets)
    end

    if playerResets == -1 then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end

    playerResets = math.max(0, playerResets)

    local bonusPercent = playerResets * config.damageBonus

    if bonusPercent > 0 then
        local bonusDamage = primaryDamage * bonusPercent / 100
        primaryDamage = primaryDamage + bonusDamage
        secondaryDamage = secondaryDamage + bonusDamage
    end

    return primaryDamage, primaryType, secondaryDamage, secondaryType
end
resetSysEvent:register()


local eventCallback = EventCallback
function eventCallback.onSpawn(creature, position, startup, artificial)
    if creature:isMonster() then
        creature:registerEvent("resetSys")
    end
    return true
end
eventCallback:register(-666)
 
test
Lua:
local config = {
    talk = "!reset",
    storageResets = 525000,
    backToLevel = 8,
    backToHealth = 150, -- Health after reset
    backToMana = 35, -- Mana after reset
    redskull = true,
    battle = true,
    pz = true,
    defaultGainMaxHealth = 0.3,
    defaultGainMaxMana = 0.3,
    resetCostItemId = 2157, -- Item ID required for reset
    resetCostAmount = 100, -- Amount of item required for reset
    expBonus = 10, -- Initial experience bonus in percentage (10%)
    damageBonus = 10, -- Initial damage bonus in percentage (10%)
    stages = {
        {levelRequired = 2000, cost = 100},
        {levelRequired = 3000, cost = 100},
        {levelRequired = 4000, cost = 100},
        {levelRequired = 5000, cost = 100},
        -- 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

local resetSys = TalkAction(config.talk)
function resetSys.onSay(player, words, param)
    -- Check if the player meets reset conditions
    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 a protection zone to reset.")
        return false
    elseif config.battle and player:getCondition(CONDITION_INFIGHT) then
        player:sendCancelMessage("You need to be out of 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 ipairs(config.stages) do
        if playerResets < _stage.levelRequired then
            stage = _stage
            break
        end
    end

    if not stage then
        player:sendCancelMessage("Stage not found for your resets.")
        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 items to perform the reset
    if not player:removeItem(config.resetCostItemId, config.resetCostAmount) then
        player:sendCancelMessage("You need " .. config.resetCostAmount .. " 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))
 
    -- Set new health and mana
    local newMaxHealth = config.backToHealth + math.ceil(config.backToHealth * config.defaultGainMaxHealth * playerResets)
    local newMaxMana = config.backToMana + math.ceil(config.backToMana * config.defaultGainMaxMana * playerResets)

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

local ec = EventCallback
ec.onGainExperience = function(self, source, exp, rawExp)
    if not source:isMonster() then
        return exp
    end

    local playerResets = math.max(0, self:getStorageValue(config.storageResets))
    local bonusPercent = playerResets * config.expBonus
    local percent = 1 + (bonusPercent / 100)

    exp = exp * percent
    
    return exp
end
ec:register()

local resetSysEvent = CreatureEvent("resetSys")
function resetSysEvent.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if not creature or not attacker then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end
    
    local playerResets = 0
    if attacker:isPlayer() then
        playerResets = attacker:getStorageValue(config.storageResets)
    end

    if playerResets == -1 then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end

    playerResets = math.max(0, playerResets)

    local bonusPercent = playerResets * config.damageBonus

    if bonusPercent > 0 then
        local bonusDamage = primaryDamage * bonusPercent / 100
        primaryDamage = primaryDamage + bonusDamage
        secondaryDamage = secondaryDamage + bonusDamage
    end

    return primaryDamage, primaryType, secondaryDamage, secondaryType
end
resetSysEvent:register()

local eventCallback = EventCallback
function eventCallback.onSpawn(creature, position, startup, artificial)
    if creature:isMonster() then
        creature:registerEvent("resetSys")
    end
    return true
end
eventCallback:register(-666)
 
test
Lua:
local config = {
    talk = "!reset",
    storageResets = 525000,
    backToLevel = 8,
    backToHealth = 150, -- Health after reset
    backToMana = 35, -- Mana after reset
    redskull = true,
    battle = true,
    pz = true,
    defaultGainMaxHealth = 0.3,
    defaultGainMaxMana = 0.3,
    resetCostItemId = 2157, -- Item ID required for reset
    resetCostAmount = 100, -- Amount of item required for reset
    expBonus = 10, -- Initial experience bonus in percentage (10%)
    damageBonus = 10, -- Initial damage bonus in percentage (10%)
    stages = {
        {levelRequired = 2000, cost = 100},
        {levelRequired = 3000, cost = 100},
        {levelRequired = 4000, cost = 100},
        {levelRequired = 5000, cost = 100},
        -- 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

local resetSys = TalkAction(config.talk)
function resetSys.onSay(player, words, param)
    -- Check if the player meets reset conditions
    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 a protection zone to reset.")
        return false
    elseif config.battle and player:getCondition(CONDITION_INFIGHT) then
        player:sendCancelMessage("You need to be out of 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 ipairs(config.stages) do
        if playerResets < _stage.levelRequired then
            stage = _stage
            break
        end
    end

    if not stage then
        player:sendCancelMessage("Stage not found for your resets.")
        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 items to perform the reset
    if not player:removeItem(config.resetCostItemId, config.resetCostAmount) then
        player:sendCancelMessage("You need " .. config.resetCostAmount .. " 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))
 
    -- Set new health and mana
    local newMaxHealth = config.backToHealth + math.ceil(config.backToHealth * config.defaultGainMaxHealth * playerResets)
    local newMaxMana = config.backToMana + math.ceil(config.backToMana * config.defaultGainMaxMana * playerResets)

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

local ec = EventCallback
ec.onGainExperience = function(self, source, exp, rawExp)
    if not source:isMonster() then
        return exp
    end

    local playerResets = math.max(0, self:getStorageValue(config.storageResets))
    local bonusPercent = playerResets * config.expBonus
    local percent = 1 + (bonusPercent / 100)

    exp = exp * percent
   
    return exp
end
ec:register()

local resetSysEvent = CreatureEvent("resetSys")
function resetSysEvent.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if not creature or not attacker then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end
   
    local playerResets = 0
    if attacker:isPlayer() then
        playerResets = attacker:getStorageValue(config.storageResets)
    end

    if playerResets == -1 then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end

    playerResets = math.max(0, playerResets)

    local bonusPercent = playerResets * config.damageBonus

    if bonusPercent > 0 then
        local bonusDamage = primaryDamage * bonusPercent / 100
        primaryDamage = primaryDamage + bonusDamage
        secondaryDamage = secondaryDamage + bonusDamage
    end

    return primaryDamage, primaryType, secondaryDamage, secondaryType
end
resetSysEvent:register()

local eventCallback = EventCallback
function eventCallback.onSpawn(creature, position, startup, artificial)
    if creature:isMonster() then
        creature:registerEvent("resetSys")
    end
    return true
end
eventCallback:register(-666)
Thank you bro for help ,sometime back to 1level and damage not working;/
Post automatically merged:

80% back to level 8 but sometime do 1lvl ,to 200 etc.
 
Last edited:
Thank you bro for help ,sometime back to 1level and damage not working;/
Post automatically merged:

80% back to level 8 but sometime do 1lvl ,to 200 etc.
I recommend using a database to reset the level. For example, resetting from level 2k back to level 8 with correct mana and life.

If you want, I can create another script that is better and more configurable. It will use the database for level, life, mana, etc.
 
I recommend using a database to reset the level. For example, resetting from level 2k back to level 8 with correct mana and life.

If you want, I can create another script that is better and more configurable. It will use the database for level, life, mana, etc.
Yes please bro , I love you
I would like
bonusses
exp +10 %
AND DAMAge +10%
Can be bonuse hp but no 1k hp but no 200k
player is buged and have 4milion hp ;D
Post automatically merged:

if you can ewhen players make reset back temple position 160 54 7
 
Last edited:
I set a 20% bonus for HP/MP, which brings it back to 150 HP and 35 + 20%. It works fine. If you want, you can change the percentage to your preference.

Lua:
local config = {
    talk = "!reset",
    resetCostItemId = 2157,
    newlevel = 8,
    redskull = true,
    battle = true,
    pz = true,
    healthPercent = 20, -- hp percentage (20%)
    manaPercent = 20,  -- mp percentage (20%)
    storageResets = 525000,
    expBonus = 10, --  experience bonus in percentage (10%)
    damageBonus = 10, -- damage bonus in percentage (10%)
    templePosition = Position(160, 54, 7),
    stages = {
        {levelRequired = 2000, cost = 100},
        {levelRequired = 3000, cost = 100},
        {levelRequired = 4000, cost = 100},
        {levelRequired = 5000, cost = 100},
        -- Add more stages as needed
    }
}

-- Function to get the current stage based on player's reset count
local function getCurrentStage(player)
    local currentResets = player:getStorageValue(config.storageResets)
    if currentResets < 0 then
        currentResets = 0
    end
    return config.stages[currentResets + 1]
end

-- Function to reset the player
local function resetPlayer(player)
    local currentStage = getCurrentStage(player)
    if not currentStage then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "No more reset stages available, please contact the administrator!")
        return false
    end

    local itemType = ItemType(config.resetCostItemId)
    local itemName = itemType:getName()
    
    if player:getItemCount(config.resetCostItemId) < currentStage.cost then
        player:sendCancelMessage("You need " .. currentStage.cost .. " " .. itemName .. "(s) to perform the reset.")
        return false
    end

    if config.battle and player:getCondition(CONDITION_INFIGHT) then
        player:sendCancelMessage("You need to be out of battle to reset.")
        return false
    end

    if config.pz then
        local tile = Tile(player:getPosition())
        if not tile or not tile:hasFlag(TILESTATE_PROTECTIONZONE) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You need to be in a protection zone to reset.")
            return false
        end
    end

    if config.redskull and player:getSkull() == SKULL_RED then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You need to be without red skull to reset.")
        return false
    end

    if player:getLevel() < currentStage.levelRequired then
        player:sendCancelMessage("You need to be level " .. currentStage.levelRequired .. " or higher to reset.")
        return false
    end

    player:removeItem(config.resetCostItemId, currentStage.cost)

    local currentResets = math.max(0, player:getStorageValue(config.storageResets))

    local baseHealth = 150
    local baseMana = 35

    local newHealthMax = baseHealth + (baseHealth * config.healthPercent / 100) * (currentResets + 1)
    local newManaMax = baseMana + (baseMana * config.manaPercent / 100) * (currentResets + 1)

    player:setMaxHealth(math.ceil(newHealthMax))
    player:setMaxMana(math.ceil(newManaMax))

    player:setStorageValue(config.storageResets, currentResets + 1)
    
    player:teleportTo(config.templePosition)
    config.templePosition:sendMagicEffect(CONST_ME_TELEPORT)

    local query = string.format("UPDATE players SET health = %d, healthmax = %d, mana = %d, manamax = %d, level = %d, experience = %d WHERE id = %d",
                                math.ceil(newHealthMax), math.ceil(newHealthMax), math.ceil(newManaMax), math.ceil(newManaMax), config.newlevel, 4200, player:getGuid())
    player:remove()
    db.query(query)
    
    return true
end

local talkaction = TalkAction(config.talk)
function talkaction.onSay(player, words, param, type)
    resetPlayer(player)
    return false
end
talkaction:separator(" ")
talkaction:register()

-- EventCallback to handle experience gain with bonus
local ec = EventCallback
ec.onGainExperience = function(self, source, exp, rawExp)
    if not source:isMonster() then
        return exp
    end

    local playerResets = math.max(0, self:getStorageValue(config.storageResets))
    local bonusPercent = playerResets * config.expBonus
    local percent = 1 + (bonusPercent / 100)

    exp = exp * percent
    
    return exp
end
ec:register()

-- CreatureEvent to handle damage bonus
local resetSysEvent = CreatureEvent("resetSys")
function resetSysEvent.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if not creature or not attacker then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end

    local playerResets = 0
    if attacker:isPlayer() then
        playerResets = attacker:getStorageValue(config.storageResets)
    end

    if playerResets == -1 then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end

    playerResets = math.max(0, playerResets)

    local bonusPercent = playerResets * config.damageBonus

    if bonusPercent > 0 then
        local bonusDamage = primaryDamage * bonusPercent / 100
        primaryDamage = primaryDamage + bonusDamage
        secondaryDamage = secondaryDamage + bonusDamage
    end

    return primaryDamage, primaryType, secondaryDamage, secondaryType
end
resetSysEvent:register()

-- EventCallback to register the resetSys event for monsters
local eventCallback = EventCallback
function eventCallback.onSpawn(creature, position, startup, artificial)
    if creature:isMonster() then
        creature:registerEvent("resetSys")
    end
    return true
end
eventCallback:register(-666)


Upvote the script I made for the solution! Don't forget, please!!
 
Solved
I set a 20% bonus for HP/MP, which brings it back to 150 HP and 35 + 20%. It works fine. If you want, you can change the percentage to your preference.

Lua:
local config = {
    talk = "!reset",
    resetCostItemId = 2157,
    newlevel = 8,
    redskull = true,
    battle = true,
    pz = true,
    healthPercent = 20, -- hp percentage (20%)
    manaPercent = 20,  -- mp percentage (20%)
    storageResets = 525000,
    expBonus = 10, --  experience bonus in percentage (10%)
    damageBonus = 10, -- damage bonus in percentage (10%)
    templePosition = Position(160, 54, 7),
    stages = {
        {levelRequired = 2000, cost = 100},
        {levelRequired = 3000, cost = 100},
        {levelRequired = 4000, cost = 100},
        {levelRequired = 5000, cost = 100},
        -- Add more stages as needed
    }
}

-- Function to get the current stage based on player's reset count
local function getCurrentStage(player)
    local currentResets = player:getStorageValue(config.storageResets)
    if currentResets < 0 then
        currentResets = 0
    end
    return config.stages[currentResets + 1]
end

-- Function to reset the player
local function resetPlayer(player)
    local currentStage = getCurrentStage(player)
    if not currentStage then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "No more reset stages available, please contact the administrator!")
        return false
    end

    local itemType = ItemType(config.resetCostItemId)
    local itemName = itemType:getName()
   
    if player:getItemCount(config.resetCostItemId) < currentStage.cost then
        player:sendCancelMessage("You need " .. currentStage.cost .. " " .. itemName .. "(s) to perform the reset.")
        return false
    end

    if config.battle and player:getCondition(CONDITION_INFIGHT) then
        player:sendCancelMessage("You need to be out of battle to reset.")
        return false
    end

    if config.pz then
        local tile = Tile(player:getPosition())
        if not tile or not tile:hasFlag(TILESTATE_PROTECTIONZONE) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You need to be in a protection zone to reset.")
            return false
        end
    end

    if config.redskull and player:getSkull() == SKULL_RED then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You need to be without red skull to reset.")
        return false
    end

    if player:getLevel() < currentStage.levelRequired then
        player:sendCancelMessage("You need to be level " .. currentStage.levelRequired .. " or higher to reset.")
        return false
    end

    player:removeItem(config.resetCostItemId, currentStage.cost)

    local currentResets = math.max(0, player:getStorageValue(config.storageResets))

    local baseHealth = 150
    local baseMana = 35

    local newHealthMax = baseHealth + (baseHealth * config.healthPercent / 100) * (currentResets + 1)
    local newManaMax = baseMana + (baseMana * config.manaPercent / 100) * (currentResets + 1)

    player:setMaxHealth(math.ceil(newHealthMax))
    player:setMaxMana(math.ceil(newManaMax))

    player:setStorageValue(config.storageResets, currentResets + 1)
   
    player:teleportTo(config.templePosition)
    config.templePosition:sendMagicEffect(CONST_ME_TELEPORT)

    local query = string.format("UPDATE players SET health = %d, healthmax = %d, mana = %d, manamax = %d, level = %d, experience = %d WHERE id = %d",
                                math.ceil(newHealthMax), math.ceil(newHealthMax), math.ceil(newManaMax), math.ceil(newManaMax), config.newlevel, 4200, player:getGuid())
    player:remove()
    db.query(query)
   
    return true
end

local talkaction = TalkAction(config.talk)
function talkaction.onSay(player, words, param, type)
    resetPlayer(player)
    return false
end
talkaction:separator(" ")
talkaction:register()

-- EventCallback to handle experience gain with bonus
local ec = EventCallback
ec.onGainExperience = function(self, source, exp, rawExp)
    if not source:isMonster() then
        return exp
    end

    local playerResets = math.max(0, self:getStorageValue(config.storageResets))
    local bonusPercent = playerResets * config.expBonus
    local percent = 1 + (bonusPercent / 100)

    exp = exp * percent
   
    return exp
end
ec:register()

-- CreatureEvent to handle damage bonus
local resetSysEvent = CreatureEvent("resetSys")
function resetSysEvent.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if not creature or not attacker then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end

    local playerResets = 0
    if attacker:isPlayer() then
        playerResets = attacker:getStorageValue(config.storageResets)
    end

    if playerResets == -1 then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end

    playerResets = math.max(0, playerResets)

    local bonusPercent = playerResets * config.damageBonus

    if bonusPercent > 0 then
        local bonusDamage = primaryDamage * bonusPercent / 100
        primaryDamage = primaryDamage + bonusDamage
        secondaryDamage = secondaryDamage + bonusDamage
    end

    return primaryDamage, primaryType, secondaryDamage, secondaryType
end
resetSysEvent:register()

-- EventCallback to register the resetSys event for monsters
local eventCallback = EventCallback
function eventCallback.onSpawn(creature, position, startup, artificial)
    if creature:isMonster() then
        creature:registerEvent("resetSys")
    end
    return true
end
eventCallback:register(-666)


Upvote the script I made for the solution! Don't forget, please!!
solved, thank you guys for help pervect
Post automatically merged:

Is possible add reborn on website to high scores and rank?
 
Back
Top