• 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+ xp boost

Mateus Robeerto

Excellent OT User
Joined
Jun 5, 2016
Messages
1,337
Solutions
71
Reaction score
697
Location
ლ(ಠ益ಠლ)
I got a script here.

And I've been updated to TFS 1.5 but half of 50% experience doesn't work. For example, I want a boost that increases the experience points your character gains from hunting by 50%! It lasts for 1 hour of hunting, being paused if the resistance drops below 14 hours. Is there a way to do this?

script:
Lua:
local boostStorage = 693690
local boostDuration = 3600

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local player = Player(cid)
    local currentBoostEnd = player:getStorageValue(boostStorage)
    local currentStamina = player:getStamina()

    if currentBoostEnd >= os.time() and currentStamina > 14 * 60 then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You already have double XP!")
        return true
    end

 
    local newBoostEnd = os.time() + boostDuration

 
    if currentStamina <= 14 * 60 then
        local remainingStaminaTime = currentStamina * 60
        newBoostEnd = os.time() + remainingStaminaTime
    end

    player:setStorageValue(boostStorage, newBoostEnd)
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Your 1-hour double XP has started!")
    item:remove(1)
    return true
end

function Player:onGainExperience(source, exp, rawExp)
    local boostEnd = self:getStorageValue(boostStorage)

    if boostEnd >= os.time() then
        exp = exp * 2
    end
    return exp
end
 
Last edited:
Solution
It solved it for me, it was just enabling from 0 to 1 in events.xml: ,

actions/scripts/name.lua
Lua:
local boostStorage = 693690
local boostDuration = 3600

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local player = Player(cid)
    local currentBoostEnd = player:getStorageValue(boostStorage)
    local currentStamina = player:getStamina()

    if currentBoostEnd >= os.time() and currentStamina > 14 * 60 then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You already have an XP boost active!")
        return true
    end

    local newBoostEnd = os.time() + boostDuration

    if currentStamina <= 14 * 60 then
        local remainingStaminaTime = currentStamina * 60
        newBoostEnd = os.time() +...
It solved it for me, it was just enabling from 0 to 1 in events.xml: ,

actions/scripts/name.lua
Lua:
local boostStorage = 693690
local boostDuration = 3600

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local player = Player(cid)
    local currentBoostEnd = player:getStorageValue(boostStorage)
    local currentStamina = player:getStamina()

    if currentBoostEnd >= os.time() and currentStamina > 14 * 60 then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You already have an XP boost active!")
        return true
    end

    local newBoostEnd = os.time() + boostDuration

    if currentStamina <= 14 * 60 then
        local remainingStaminaTime = currentStamina * 60
        newBoostEnd = os.time() + remainingStaminaTime
    end

    player:setStorageValue(boostStorage, newBoostEnd)
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Your 1-hour XP boost has started! You will gain 50% extra experience while hunting.")
    item:remove(1)
    return true
end

XML:
<event class="Player" method="onGainExperience" enabled="1" />

and then adding at the end.
events/player.lua
Lua:
function Player:onGainExperience(source, exp, rawExp)
    local thing = self:getStorageValue(693690)
    if thing > os.time() then
        return exp * 1.5 --- 50%
    end
    return exp
end
Post automatically merged:

@Error 502 I don't understand why you laughed?
 
Last edited:
Solution
Back
Top