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

Lua How Add/AUTO REBIRTH IS AUTOMATIC!

Gaber Zen

Active Member
Joined
Apr 22, 2023
Messages
200
Reaction score
46
Location
Egypt
How do I turn on the Restore Personal Receipt
Player Used Spells like !reset From talkactions, But in Automatic
Because every 1000 levels you need a new appointment
Because the players gain experience above the appointment
i want AUTO REBIRTH IS AUTOMATIC!
Is there someone help me
function onSay(cid, words, param, channel)
if (param:lower() == "info") then
local message = "~~~~~~~~~~Reset Infos ~~~~~~~~~~\n"
local resetsCount = ResetSystem:getCount(cid)
message = message .. "\nNْmero de Resets: " .. resetsCount .. "."

local level = getPlayerLevel(cid)
local vocationInfo = getVocationInfo(getPlayerVocation(cid))
local baseHealth, extraHealth
local baseMana, extraMana
local resetBonus = ResetSystem:getCurrentBonus(cid)
if (resetBonus and vocationInfo) then
baseHealth = vocationInfo.healthGain * level
extraHealth = getCreatureMaxHealth(cid) - baseHealth
baseMana = vocationInfo.manaGain * level
extraMana = getCreatureMaxMana(cid) - baseMana
else
baseHealth, extraHealth = getCreatureMaxHealth(cid), 0
baseMana, extraMana = getCreatureMaxMana(cid), 0
end

message = message .. "\nVida normal: " .. baseHealth .. " + " .. extraHealth .. "."
message = message .. "\nMana normal: " .. baseMana .. " + " .. extraMana .. "."
message = message .. "\nExp Stage Bonْs: " .. getExperienceStage(level) .. "x + " .. ((resetBonus and resetBonus.experiencePercent) or "0") .. "%."
message = message .. "\nDamage Bonْs: " .. ((resetBonus and resetBonus.damagePercent) or "0") .. "%."
message = message .. "\nProximo Reset: Lv" .. (resetsCount < ResetSystem.max_count and ((resetsCount + 1) * ResetSystem.needed_level_per_reset) or "0") .. "."
doShowTextDialog(cid, 8983, message)
else

local resetsCount = ResetSystem:getCount(cid)
if (resetsCount >= ResetSystem.max_count) then
doPlayerSendCancel(cid, "Você jل atingiu o nيvel mلximo de resets.")
return true
end

local levelNeeded = (resetsCount + 1) * ResetSystem.needed_level_per_reset
if (levelNeeded > getPlayerLevel(cid)) then
doPlayerSendCancel(cid, "Você precisa ser level " .. levelNeeded .. " ou maior.")
return true
end

ResetSystem:execute(cid)
end
return true
end
 
Last edited:
Just looking at the talkaction, no idea of your resetsystem though:

Lua:
function onAdvance(player, skill, oldLevel, newLevel)
    if newLevel > 999 then
        ResetSystem:execute(player)
    end
end
Edit: Not recommending this, doesnt sound like a good thing to have on your server. But according to your post it might do it
 
Last edited:
I sent in page 1
Lua:
local config = {
heal = true,
save = true,
effect = false,
save_exhaust_time = 10, -- in minutes
hp_increase = 10, -- amount of max health increase on level up
mp_increase = 10 -- amount of max mana increase on level up
}

save_exhaust = save_exhaust or {}

function onAdvance(player, skill, oldLevel, newLevel)
if skill ~= SKILL_LEVEL or newLevel <= oldLevel then
return true
end

if config.effect then
    player:getPosition():sendMagicEffect(math.random(CONST_ME_FIREWORK_YELLOW, CONST_ME_FIREWORK_BLUE))
    player:say('LEVEL UP!', TALKTYPE_MONSTER_SAY)
end

if config.heal then
    player:addHealth(player:getMaxHealth())
    player:addMana(player:getMaxMana())
end

if config.save then
    local time = os.date()
    if not save_exhaust[player.uid] or save_exhaust[player.uid] <= time then
        player:save()
        save_exhaust[player.uid] = time + (config.save_exhaust_time * 60)
    end
end

if newLevel >= 1000 then
    player:setLevel(1)
    player:setMaxHealth(player:getMaxHealth() + config.hp_increase)
    player:setMaxMana(player:getMaxMana() + config.mp_increase)
end

return true
end
 
Just looking at the talkaction, no idea of your resetsystem though:

Lua:
function onAdvance(player, skill, oldLevel, newLevel)
    if newLevel > 999 then
        ResetSystem:execute(player)
    end
end
Edit: Not recommending this, doesnt sound like a good thing to have on your server. But according to your post it might do it
Your solution should work, but I believe he didn't register it to login.lua, so here's an easy revscript that should work.
Lua:
local autoReset = CreatureEvent("autoReset")

function autoReset.onAdvance(player, skill, oldLevel, newLevel)
    local resetsCount = ResetSystem:getCount(player)
    local levelNeeded = (resetsCount + 1) * ResetSystem.needed_level_per_reset

    if skill ~= SKILL_LEVEL or newLevel <= oldLevel then
        return true
    end

    if (resetsCount >= ResetSystem.max_count) then
        player:sendCancelMessage("You have already reached the maximum resets.")
        return true
    end

    if newLevel > levelNeeded then
        ResetSystem:execute(player)
    end
    return true
end

autoReset:register()

local autoResetsLogin = CreatureEvent("autoResetsLogin")

function autoResetsLogin.onLogin(player)
    player:registerEvent("autoReset")
    return true
end

autoResetsLogin:register()
I sent in page 1
Lua:
local config = {
heal = true,
save = true,
effect = false,
save_exhaust_time = 10, -- in minutes
hp_increase = 10, -- amount of max health increase on level up
mp_increase = 10 -- amount of max mana increase on level up
}

save_exhaust = save_exhaust or {}

function onAdvance(player, skill, oldLevel, newLevel)
if skill ~= SKILL_LEVEL or newLevel <= oldLevel then
return true
end

if config.effect then
    player:getPosition():sendMagicEffect(math.random(CONST_ME_FIREWORK_YELLOW, CONST_ME_FIREWORK_BLUE))
    player:say('LEVEL UP!', TALKTYPE_MONSTER_SAY)
end

if config.heal then
    player:addHealth(player:getMaxHealth())
    player:addMana(player:getMaxMana())
end

if config.save then
    local time = os.date()
    if not save_exhaust[player.uid] or save_exhaust[player.uid] <= time then
        player:save()
        save_exhaust[player.uid] = time + (config.save_exhaust_time * 60)
    end
end

if newLevel >= 1000 then
    player:setLevel(1)
    player:setMaxHealth(player:getMaxHealth() + config.hp_increase)
    player:setMaxMana(player:getMaxMana() + config.mp_increase)
end

return true
end
He already has a rebirth system, Why would you add setMaxHealth/setMaxMana/player:setLevel? That might not work well with his already existing system.
 
Last edited:
It's a revscript, you should add it to data/scripts
Just name it Whateveryouwant.lua and place it there.
 
Erro
<event type="login" name="AutoReset" event="script" value="resets.lua" />
local autoReset = CreatureEvent("autoReset")

function autoReset.onAdvance(player, skill, oldLevel, newLevel)
local resetsCount = ResetSystem:getCount(player)
local levelNeeded = (resetsCount + 1) * ResetSystem.needed_level_per_reset

if skill ~= SKILL_LEVEL or newLevel <= oldLevel then
return true
end

if (resetsCount >= ResetSystem.max_count) then
player:sendCancelMessage("You have already reached the maximum resets.")
return true
end

if newLevel > levelNeeded then
ResetSystem:execute(player)
end
return true
end

autoReset:register()

local autoResetsLogin = CreatureEvent("autoResetsLogin")

function autoResetsLogin.onLogin(player)
player:registerEvent("autoReset")
return true
end

autoResetsLogin:register()
 

Attachments

It's a revscript, you should add it to data/scripts
Just name it Whateveryouwant.lua and place it there.
Read this again; I never said anything about data/creaturescripts/scripts

Do you even have revscripts? If not, then add it like this without revscripts.
In data/creaturescripts/scripts add this resets.lua
Lua:
function onAdvance(player, skill, oldLevel, newLevel)
    local resetsCount = ResetSystem:getCount(player)
    local levelNeeded = (resetsCount + 1) * ResetSystem.needed_level_per_reset

    if skill ~= SKILL_LEVEL or newLevel <= oldLevel then
        return true
    end

    if (resetsCount >= ResetSystem.max_count) then
        player:sendCancelMessage("You have already reached the maximum resets.")
        return true
    end

    if newLevel > levelNeeded then
        ResetSystem:execute(player)
    end
    return true
end
and in data/creaturescripts/creaturescripts.xml add this
XML:
<event type="advance" name="autoReset" script="resets.lua" />
Then in data/creaturescripts/scripts/login.lua register it at the end like this player:registerEvent("autoReset")
 
Last edited:
code no Erro But nothing change, player no get resets
you can Test Code
Every time I exceed 1000 levels, you take a reset
i add in login/ registerCreatureEvent(cid, "autoReset")
 

Attachments

Last edited:
Add this one, and show me what it prints to console.
Lua:
function onAdvance(player, skill, oldLevel, newLevel)
    if skill ~= SKILL_LEVEL or newLevel <= oldLevel then
        return true
    end
    print("Script added correctly")

    local resetsCount = ResetSystem:getCount(player)
    local neededLevelPerReset = ResetSystem.needed_level_per_reset
    local levelNeeded = (resetsCount + 1) * ResetSystem.needed_level_per_reset

    if resetsCount then
        print(resetsCount)
    else
        print("Not reaching resets count")
    end

    if neededLevelPerReset then
        print(neededLevelPerReset)
    else
        print("Not reaching level needed")
    end

    if levelNeeded then
        print(levelNeeded)
    else
        print("Not reaching level needed for the next reset")
    end

    if (resetsCount >= ResetSystem.max_count) then
        print("Maximum resets reached")
        player:sendCancelMessage("You have already reached the maximum resets.")
        return true
    end

    print("Last check")
    if newLevel > levelNeeded then
        print("Should execute")
        ResetSystem:execute(player)
    end
    return true
end
 
Add this one, and show me what it prints to console.
Lua:
function onAdvance(player, skill, oldLevel, newLevel)
    if skill ~= SKILL_LEVEL or newLevel <= oldLevel then
        return true
    end
    print("Script added correctly")

    local resetsCount = ResetSystem:getCount(player)
    local neededLevelPerReset = ResetSystem.needed_level_per_reset
    local levelNeeded = (resetsCount + 1) * ResetSystem.needed_level_per_reset

    if resetsCount then
        print(resetsCount)
    else
        print("Not reaching resets count")
    end

    if neededLevelPerReset then
        print(neededLevelPerReset)
    else
        print("Not reaching level needed")
    end

    if levelNeeded then
        print(levelNeeded)
    else
        print("Not reaching level needed for the next reset")
    end

    if (resetsCount >= ResetSystem.max_count) then
        print("Maximum resets reached")
        player:sendCancelMessage("You have already reached the maximum resets.")
        return true
    end

    print("Last check")
    if newLevel > levelNeeded then
        print("Should execute")
        ResetSystem:execute(player)
    end
    return true
end
Boku no hero
 
Back
Top