• 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 amendment/ Full Script Resets distinct

Gaber Zen

Well-Known Member
Joined
Apr 22, 2023
Messages
225
Reaction score
52
Location
Egypt
Hello, otland
Did he completely modify the system without errors, like ice-war Reborn
My Script system Everytime you Up level 1000+ Can Reset Your Self
But I want To Change it to be distinct Like gradually Start Reset level 1000 Next 1500,1800,2000,2300,2500,2800,3000,3150,3300,3500 as follows
otx-860
Full Lib
Lua:
ResetSystem = {
    storage = 14335,

    back_to_level = 100,
    needed_level_per_reset = 1000,
    max_count = 1000,

    bonus_per_reset = {
        experiencePercent = 10,
        damagePercent = 2.5,
        healthAndManaGainPercent = 5
    }
}

function ResetSystem:getCount(pid)
    return math.max(0, (tonumber(getCreatureStorage(pid, self.storage)) or 0))
end

function ResetSystem:setCount(pid, count)
    doCreatureSetStorage(pid, self.storage, count)
    db.executeQuery("UPDATE `players` SET `reset` = '"..count.."' WHERE  `id` = '"..getPlayerGUID(pid).."';")
end

function ResetSystem:addCount(pid)
    db.executeQuery("UPDATE `players` SET `reset` = '".. (self:getCount(pid) + 1) .."' WHERE  `id` = '"..getPlayerGUID(pid).."';")
    self:setCount(pid, self:getCount(pid) + 1)
end

function ResetSystem:getCurrentBonus(pid)
    local resets = math.min(self:getCount(pid), self.max_count)
    if (resets > 0) then
        local currentBonus = {}
        for bonus, value in pairs(self.bonus_per_reset) do
            currentBonus[bonus] = value * resets
        end
        return currentBonus
    end
    return nil
end

function ResetSystem:applyBonuses(pid)
    local bonus = self:getCurrentBonus(pid)
    if (bonus and bonus.damagePercent) then
        setPlayerDamageMultiplier(pid, 1.0 + (bonus.damagePercent / 100.0))
    else
        setPlayerDamageMultiplier(pid, 1.0)
    end
end

function ResetSystem:updateHealthAndMana(pid)
    local bonus = self:getCurrentBonus(pid)
    if (bonus and bonus.healthAndManaGainPercent) then
        local vocationInfo = getVocationInfo(getPlayerVocation(pid))
        if (vocationInfo) then
            local oldMaxHealth = getCreatureMaxHealth(pid)
            local oldMaxMana = getCreatureMaxMana(pid)
            
            local level = getPlayerLevel(pid)
            local totalHealth = (vocationInfo.healthGain * level)
            local totalMana = (vocationInfo.manaGain * level)
            
            local newMaxHealth = math.floor(totalHealth + (totalHealth * (bonus.healthAndManaGainPercent / 100)))
            local newMaxMana = math.floor(totalMana + (totalMana * (bonus.healthAndManaGainPercent / 100)))
            setCreatureMaxHealth(pid, newMaxHealth)
            setCreatureMaxMana(pid, newMaxMana)

            if (newMaxHealth > oldMaxHealth) then
                doCreatureAddHealth(pid, newMaxHealth - oldMaxHealth)
            elseif (newMaxHealth < oldMaxHealth) then
                doCreatureAddHealth(pid, 1) -- evita barra bugada
            end

            if (newMaxMana > oldMaxMana) then
                doCreatureAddMana(pid, newMaxMana - oldMaxMana)
            elseif (newMaxMana < oldMaxMana) then
                doCreatureAddMana(pid, 1)
            end
        end
    end
end

function ResetSystem:execute(pid)
    self:addCount(pid)
    local playerLevel = getPlayerLevel(pid)
    if (playerLevel > self.back_to_level) then
        doPlayerAddExperience(pid, getExperienceForLevel(self.back_to_level) - getPlayerExperience(pid))
        playerLevel = self.back_to_level
    end

    self:applyBonuses(pid)
    self:updateHealthAndMana(pid)
    local bonus = self:getCurrentBonus(pid)
    if (bonus) then
        local message = "Você efetuou seu " .. self:getCount(pid) .. "° reset."
        if (bonus.damagePercent) then
            message = message .. "\n+" .. bonus.damagePercent .. "% de dano"
        end

        if (bonus.healthAndManaGainPercent) then
            message = message .. "\n+" .. bonus.healthAndManaGainPercent .. "% de vida e mana"
            local vocationInfo = getVocationInfo(getPlayerVocation(pid))
            if (vocationInfo) then
                local healthAndManaMultiplier = 1.0 + (bonus.healthAndManaGainPercent / 100.0)
                local healthBonusSum = (vocationInfo.healthGain * playerLevel) * healthAndManaMultiplier
                local manaBonusSum = (vocationInfo.manaGain * playerLevel) * healthAndManaMultiplier
                setCreatureMaxHealth(pid, healthBonusSum)
                setCreatureMaxMana(pid, manaBonusSum)
                doCreatureAddHealth(pid, healthBonusSum)
                doCreatureAddMana(pid, manaBonusSum)
            end
        end

        if (bonus.experiencePercent) then
            message = message .. "\n+" .. bonus.experiencePercent .. "% de EXP"
        end

        doPlayerSendTextMessage(pid, MESSAGE_EVENT_ADVANCE, message)
    end
end
Code:
if not resys then
    resys = {
 
        ['boolean'] = {pz = false, teleport = false},
      
        btlevel = 1000,
        exhaust = 20,
      
        stages = {
 
            {need = {resets = 01, level = 2000}},
            {need = {resets = 02, level = 4000}},
            {need = {resets = 03, level = 6000}},
            {need = {resets = 04, level = 8000}},
            {need = {resets = 05, level = 10000}},
            {need = {resets = 06, level = 12000}},
            {need = {resets = 07, level = 14000}},
            {need = {resets = 08, level = 16000}},
            {need = {resets = 09, level = 18000}},
            {need = {resets = 10, level = 20000}},
            {need = {resets = 11, level = 22000}},
            {need = {resets = 12, level = 24000}},
            {need = {resets = 13, level = 26000}},
            {need = {resets = 14, level = 28000}},
            {need = {resets = 15, level = 30000}},
            {need = {resets = 16, level = 32000}},
            {need = {resets = 17, level = 34000}},
            {need = {resets = 18, level = 36000}},
            {need = {resets = 19, level = 38000}},
            {need = {resets = 20, level = 40000}},
            {need = {resets = 21, level = 42000}},
            {need = {resets = 22, level = 44000}},
            {need = {resets = 23, level = 46000}},
            {need = {resets = 24, level = 48000}},
            {need = {resets = 25, level = 50000}},
            {need = {resets = 26, level = 52000}},
            {need = {resets = 27, level = 54000}},
            {need = {resets = 28, level = 56000}},
            {need = {resets = 29, level = 58000}},
            {need = {resets = 30, level = 60000}},
            {need = {resets = 31, level = 62000}},
            {need = {resets = 32, level = 64000}},
            {need = {resets = 33, level = 66000}},
            {need = {resets = 34, level = 68000}},
            {need = {resets = 35, level = 70000}},
            {need = {resets = 36, level = 72000}},
            {need = {resets = 37, level = 74000}},
            {need = {resets = 38, level = 76000}},
            {need = {resets = 39, level = 78000}},
            {need = {resets = 40, level = 80000}},
            {need = {resets = 41, level = 82000}},
            {need = {resets = 42, level = 84000}},
            {need = {resets = 43, level = 86000}},
            {need = {resets = 44, level = 88000}},
            {need = {resets = 45, level = 90000}},
            {need = {resets = 46, level = 92000}},
            {need = {resets = 47, level = 94000}},
            {need = {resets = 48, level = 96000}},
            {need = {resets = 49, level = 98000}},
            {need = {resets = 50, level = 100000}},
            {need = {resets = 51, level = 120000}},
            {need = {resets = 52, level = 140000}},
            {need = {resets = 53, level = 160000}},
            {need = {resets = 54, level = 180000}},
            {need = {resets = 55, level = 300000}},
            {need = {resets = 56, level = 320000}},
            {need = {resets = 57, level = 340000}},
            {need = {resets = 58, level = 360000}},
            {need = {resets = 59, level = 380000}},
            {need = {resets = 60, level = 400000}},
            
        }
 
    }
 
  
    function resys:exhaustion(cid, sec)
        if not sec then
            return getPlayerStorageValue(cid, 421221) - os.time()
        end
 
        setPlayerStorageValue(cid, 421221, os.time() + sec)
    end
 
    function resys:getReset(name)
        local result = db.getResult(('SELECT reset FROM players WHERE id = %d'):format(getPlayerGUIDByName(name)))
 
        local reset = 0
        if result:getID() ~= -1 then
            reset = result:getDataInt('reset')
            result:free()
        end
 
        return reset
    end
 
    function resys:doReset(cid)
        if getPlayerLevel(cid) < self:need(cid).level then
            return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, ('Faltam %d niveis para voce resetar.'):format(self:need(cid).level - getPlayerLevel(cid)))
        end
 
        if self['boolean'].pz and not getTilePzInfo(getCreaturePosition(cid)) then
            return doPlayerSendCancel(cid, 'Voce precisa estar em protection zone para resetar.')
        end
 
        local name = getPlayerName(cid)
        local id = getPlayerGUIDByName(name)
        local player = getPlayerGUID(cid)
 
        self:exhaustion(cid, self.exhaust)
 
        if self['boolean'].teleport then
            doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
        end
      
        local inc = self:getReset(name) + 1
        doRemoveCreature(cid)
      
        db.query(('UPDATE players SET level = %d, experience = 0, description = " [Resets: %d]", reset = %d  WHERE id = %d'):format(self.btlevel, inc, inc, id))
        db.query("UPDATE `players` SET `cap` = 4200 WHERE `id` = "..player)
        return true
    end
 
    function resys:need(cid)
        local index = {}
 
        for _, v in ipairs(self.stages) do
            if self:getReset(getPlayerName(cid)) >= v.need.resets then
                table.insert(index, v.need)
            end
        end
 
        return #index > 0 and index[#index] or self.stages[1].need
    end
  
    function getPlayerResets(cid) -- função global para não precisar mexer nos arquivos que a contém.
        return resys:getReset(getPlayerName(cid))
    end
end
 
Back
Top