• 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

alcapone

Member
Joined
Jan 13, 2021
Messages
246
Reaction score
19
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?
    stages = {
        {resets = 1, level = 1000, premium = 1000},
        {resets = 2, level = 2000, premium = 2000},
        {resets = 3, level = 3000, premium = 3000},
        {resets = 4, level = 4000, premium = 4000}
        
    }
}

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 newMaxHealth = 185
local newMaxMana = 90
 

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


I found this script on the forum I would like to modify it so if the player is level 2000, he gets 2 reset points if he is level 1000 1 reset point
 
I'm not an expert but I would do something like this, use a gold coin as an example.

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?
    stages = {
        {resets = 1, level = 1000, premium = 1000},
        {resets = 2, level = 2000, premium = 2000},
        {resets = 3, level = 3000, premium = 3000},
        {resets = 4, level = 4000, premium = 4000}
        
    }
}

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
    
    if player:getLevel >= 1000 then
        player:addItem(2148, 1) -- this id is for gold coin you can change it anytime
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You recieve 1 reset point") -- here just add a msg
    elseif player:getLevel >= 2000 then
        player:addItem(2148, 2)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You recieve 2 reset point")
    end
    
    playerResets = playerResets + 1
    player:setStorageValue(config.storageResets, playerResets)
    player:removeExperience(getExperienceForLevel(playerLevel) - getExperienceForLevel(config.backToLevel))
 

local newMaxHealth = 185
local newMaxMana = 90
 

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