• 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.X+ Double exp / Sabrehaven.com based on Nostalrius 7.7

Piifafa

Member
Joined
Apr 16, 2023
Messages
67
Reaction score
16
Please someone who is very experienced could help me create an item, ring or something that would give double experience or a percentage more on that basis? I tried several ways but nothing works.
 
You should find it easy with this example:

Simply instead of global storage (in data\events\scripts\player.lua at function Player:eek:nGainSkillTries(skill, tries)) make another IF to work on a player:getStorage. Then on item equip, or click item make a code to player:setStorage.
 
I tried to do it the following way, but then I double the exp for all players.

action:
Lua:
function onUse(player, item, fromPosition, itemEx, toPosition)
    local storageValue = player:getStorageValue(81100)
    if storageValue <= os.time() then
        player:setStorageValue(81100, os.time() + 2 * 60 * 60)
        item:remove()
        player:say("You have just activated 2 hours of Double Experience!", TALKTYPE_MONSTER_SAY)
    else
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have already used the daily bonus.")
    end
    return true
end

creaturescripts:
MonsterBoost
Lua:
function onKill(creature, target)
    local exp = target:getType():getExperience()

    -- Verifica se a criatura possui o bônus específico com o ID 81100
    if creature:getStorageValue(81100) == 1 then
        exp = exp + 300
    end

    creature:addExperience(exp, true)
    return true
end
em login.player
Lua:
function onLogin(player)
    local serverName = configManager.getString(configKeys.SERVER_NAME)
    local loginStr = "Welcome to " .. serverName .. "."
    if player:getLastLoginSaved() <= 0 then
        loginStr = loginStr .. " Please choose your outfit."
        player:sendOutfitWindow()
    else
        if loginStr ~= "" then
            player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
        end

        loginStr = string.format("Your last visit on ".. serverName ..": %s.", os.date("%a %b %d %X %Y", player:getLastLoginSaved()))
    end
    player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)

    -- Promotion
    if player:getVocation():getId() ~= 0 and player:getVocation():getId() < 5 and player:getStorageValue(30018) == 1 then
        player:setVocation(player:getVocation():getId() + 4)
    end

    if player:isPremium() then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "* You receiving 10% more experience.")
    end
    
    -- Outfits
    if not player:isPremium() then
        if player:getSex() == PLAYERSEX_FEMALE then
            local outfit = player:getOutfit()
            if outfit.lookType > 262 then
                player:setOutfit({lookType = 259, lookHead = 78, lookBody = 106, lookLegs = 58, lookFeet = 95})
            end
        else
            local outfit = player:getOutfit()
            if outfit.lookType > 233 then
                player:setOutfit({lookType = 230, lookHead = 78, lookBody = 106, lookLegs = 58, lookFeet = 95})
            end
        end
    end
    
    -- Premium system
    if player:isPremium() then
        player:setStorageValue(43434, 1)
    elseif player:getStorageValue(43434) == 1 then
        player:setStorageValue(43434, 0)
    end
    
    local taskStatus = player:getStorageValue(18000)
    if taskStatus > 0 then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "* Your currently task: " .. tasks[taskStatus].name .. ".")
    end
    
    local day = os.date("*t").wday

    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "* The daily monster: " .. DailyMonster .. " - Bonus ".. DailyBonus .."% of experience.")
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "* Your current experience stage: " .. decimalPlace(Game.getExperienceStage(player:getLevel())) .. "x")
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "* Official Discord Server: https://discord.gg/AedM8zA")
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "* To train use the !train command inside the temple")
    -- Events
    player:registerEvent("DailyMonster")
    player:registerEvent("PlayerDeath")
    player:registerEvent("kills")
    player:registerEvent("Reward")
    player:registerEvent("Spell")
    player:registerEvent("Task")
    player:registerEvent("MonsterBoost")
    return true
end
 
good morning everybody. I tried with the help of a friend to do it the following way, everything went very well but unfortunately there was no gain in experience, the rest works, time goes by right and storage is also ok.

doublexp.lua
Lua:
function onLogin(cid)
    local player = Player(cid)
    if not player then
        return false
    end
    
    local storageValue = player:getStorageValue(81100)
    local currentTime = os.time()

    if storageValue <= currentTime then
        local doubleExpDuration = 2 * 60 * 60 -- 2 hours in seconds
        local newExpEndTime = currentTime + doubleExpDuration
        player:setStorageValue(81100, newExpEndTime)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have received double experience for 2 hours!")
    else
        local remainingTime = storageValue - currentTime
        local hours = math.floor(remainingTime / 3600)
        local minutes = math.floor((remainingTime % 3600) / 60)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You still have " .. hours .. " hours and " .. minutes .. " minutes of double experience.")
    end

    return true
end
Code:
<event type="login" name="doublexp" script="doublexp.lua"/>

data/creaturescript/login.lua
Code:
registerCreatureEvent(cid, "doublexp")


action
Lua:
function onUse(player, item, fromPosition, itemEx, toPosition)
    local storageValue = player:getStorageValue(81100)
    if storageValue <= os.time() then
        local doubleExpDuration = 2 * 60 * 60 -- 2 hours in seconds
        local newExpEndTime = os.time() + doubleExpDuration
        player:setStorageValue(81100, newExpEndTime)
        item:remove()
        player:say("You have just activated 2 hours of Double Experience!", TALKTYPE_MONSTER_SAY)
    else
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have already used the daily bonus.")
    end
    return true
end

Please could someone help me?
 
if creature:getStorageValue(81100) == 1 then
exp = exp + 300
end

this seems like should never be equal to 1. Try to make creature:getStorageValue(81100) > os.time()
 
if creature:getStorageValue(81100) == 1 then
exp = exp + 300
end

this seems like should never be equal to 1. Try to make creature:getStorageValue(81100) > os.time()
it seems that it worked for me, but I have some problems related to the experience gain that I get very high
 
Thank the Lord for trying to help me!
I'll try to show what I did currently what happened.


/data/actions/scripts
Code:
<action itemid="3660" script="expboost.lua"/>
expboost.lua
Lua:
function onUse(player, item, fromPosition, itemEx, toPosition)
    local storageValue = player:getStorageValue(81100)
    if storageValue <= os.time() then
        local doubleExpDuration = 2 * 60 * 60 -- 2 hours in seconds
        local newExpEndTime = os.time() + doubleExpDuration
        player:setStorageValue(81100, newExpEndTime)
        item:remove()
        player:say("You have just activated 2 hours of Double Experience!", TALKTYPE_MONSTER_SAY)
    else
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have already used the daily bonus.")
    end
    return true
end

/data/creaturescripts/scripts
Code:
<event type="kill" name="MonsterBoost" script="boosteexp.lua" />
boosteexp.lua
Lua:
function onKill(creature, target)
    local exp = target:getType():getExperience()

    if target:isPlayer() then
        -- Se o alvo for um jogador, não há bônus de experiência
    elseif creature:getStorageValue(81100) > os.time() then
        -- Se o atacante tiver o bônus ativo, adiciona 300 de experiência
        exp = exp + 100
    end

    creature:addExperience(exp, true)
    return true
end

/data/creaturescripts/scripts


login.lua
add: player:registerEvent("MonsterBoost")

Lua:
function onLogin(player)
    local serverName = configManager.getString(configKeys.SERVER_NAME)
    local loginStr = "Welcome to " .. serverName .. "."
    if player:getLastLoginSaved() <= 0 then
        loginStr = loginStr .. " Please choose your outfit."
        player:sendOutfitWindow()
    else
        if loginStr ~= "" then
            player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
        end

        loginStr = string.format("Your last visit on ".. serverName ..": %s.", os.date("%a %b %d %X %Y", player:getLastLoginSaved()))
    end
    player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)

    -- Promotion
    if player:getVocation():getId() ~= 0 and player:getVocation():getId() < 5 and player:getStorageValue(30018) == 1 then
        player:setVocation(player:getVocation():getId() + 4)
    end

    if player:isPremium() then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "* You receiving 10% more experience.")
    end
    
    -- Outfits
    if not player:isPremium() then
        if player:getSex() == PLAYERSEX_FEMALE then
            local outfit = player:getOutfit()
            if outfit.lookType > 262 then
                player:setOutfit({lookType = 259, lookHead = 78, lookBody = 106, lookLegs = 58, lookFeet = 95})
            end
        else
            local outfit = player:getOutfit()
            if outfit.lookType > 233 then
                player:setOutfit({lookType = 230, lookHead = 78, lookBody = 106, lookLegs = 58, lookFeet = 95})
            end
        end
    end
    
    -- Premium system
    if player:isPremium() then
        player:setStorageValue(43434, 1)
    elseif player:getStorageValue(43434) == 1 then
        player:setStorageValue(43434, 0)
    end
    
    local taskStatus = player:getStorageValue(18000)
    if taskStatus > 0 then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "* Your currently task: " .. tasks[taskStatus].name .. ".")
    end
    
    local day = os.date("*t").wday

    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "* The daily monster: " .. DailyMonster .. " - Bonus ".. DailyBonus .."% of experience.")
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "* Your current experience stage: " .. decimalPlace(Game.getExperienceStage(player:getLevel())) .. "x")
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "* Official Discord Server: https://discord.gg/AedM8zA")
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "* To train use the !train command inside the temple")
    -- Events
    player:registerEvent("DailyMonster")
    player:registerEvent("PlayerDeath")
    player:registerEvent("kills")
    player:registerEvent("Reward")
    player:registerEvent("Spell")
    player:registerEvent("Task")
    player:registerEvent("MonsterBoost")
    return true
end

now see how it goes.
Animação.gif

Database when using teim.

Screenshot_1.png
 
Back
Top