• 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.5 Reborn problem

jareczekjsp

Member
Joined
Jan 30, 2023
Messages
213
Reaction score
14
GitHub
Jarek123
Hello I use Revescripts

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

local config = {
    storageResets = 525000,
    backToLevel = 8,
    redskull = true,
    battle = true,
    pz = true,
    defaultGainMaxHealth = 0.3,
    defaultGainMaxMana = 0.3,
    resetCostItemId = 2157, -- Item ID required for reset
    resetCostAmount = 1, -- Amount of item required for reset
    stages = {
        {levelRequired = 2000, cost = 100, expBonus = 10.08, damageBonus = 10.08}, -- Reset 1 - 20
 
        -- 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

local maxHealth = player:getMaxHealth()
local maxMana = player:getMaxMana()
local newMaxHealth = 1150
local newMaxMana = 1135
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()


and I have problem when Player make reset dont have bonuses

Code:
 expBonus = 10.08, damageBonus = 10.08}, -- Reset 1 - 20
Help me please:(
 
and I have problem when Player make reset dont have bonuses
You want the damage bonus for each reset, right? Yes, it is possible. You need to implement the onHealthChange function in your reset system and register it in login.lua. For each reset, the damage bonus would be 10.08%. So, it can definitely be done using onHealthChange.
 
You want the damage bonus for each reset, right? Yes, it is possible. You need to implement the onHealthChange function in your reset system and register it in login.lua. For each reset, the damage bonus would be 10.08%. So, it can definitely be done using onHealthChange.
Can you help me please?because I dont Know how I can do it;

damage and more exp I would like bonus for reset
more exprience and more damage x %

sorry for my english
Post automatically merged:

1 reset
10%% more exp
damage+10%

2reset
20%% more exp
damage+20%

3reset
30% more exp
damage+30%
 
Last edited:
Can you help me please?
I'll definitely do it if no one does it for you... I can do it only when I get home, yes.
Post automatically merged:

I added onHealthChange to increase damage by 10% for each reset, first, and 20% for the second one, for both monsters and enemy players. Also, onGainExperience with a 10% increase in experience for the first reset and 20% for the second one. I tested it, and it's working. See the debugging regarding the successful damage increase and experience is also okay.
1718637855331.png

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 = 1, -- 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},
        -- 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 = attacker:getStorageValue(config.storageResets)
    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)

If it's damage against enemy players, you need to add this to your login.lua file. Go to data/creaturescript/login and include this.
Lua:
player:registerEvent("resetSys")

One more thing: this line 'eventCallback(-666)' is working perfectly fine on my TFS 1.4.3, but in your case, I'm not sure. Try testing it if it doesn't work against damage increase to monsters. For example, try putting "()" and if that doesn't work, try (1), and even then if it doesn't work, try "(-1)", and so on. It depends on your TFS 1.5.
 
Last edited:
I'll definitely do it if no one does it for you... I can do it only when I get home, yes.
Post automatically merged:

I added onHealthChange to increase damage by 10% for each reset, first, and 20% for the second one, for both monsters and enemy players. Also, onGainExperience with a 10% increase in experience for the first reset and 20% for the second one. I tested it, and it's working. See the debugging regarding the successful damage increase and experience is also okay.
View attachment 85553

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 = 1, -- 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},
        -- 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 = attacker:getStorageValue(config.storageResets)
    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)

If it's damage against enemy players, you need to add this to your login.lua file. Go to data/creaturescript/login and include this.
Lua:
player:registerEvent("resetSys")

One more thing: this line 'eventCallback(-666)' is working perfectly fine on my TFS 1.4.3, but in your case, I'm not sure. Try testing it if it doesn't work against damage increase to monsters. For example, try putting "()" and if that doesn't work, try (1), and even then if it doesn't work, try "(-1)", and so on. It depends on your TFS 1.5.
bro is error in console

Lua:
Lua Script Error: [Scripts Interface]
/home/ots/jarek/data/scripts/reborn.lua:callback
/home/ots/jarek/data/scripts/reborn.lua:112: attempt to call method 'getStorageValue' (a nil value)
stack traceback:
        [C]: in function 'getStorageValue'
        /home/ots/jarek/data/scripts/reborn.lua:112: in function </home/ots/jarek/data/scripts/reborn.lua:107
 
bro is error in console
I tested on the Nekiro TFS 1.5 8.6 and it's running normally without errors in the console. What's your TFS 1.5?


Try replacing only this part.
Lua:
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()
 
Last edited:
Back
Top