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

Scroll that boosts exp for x time

  • Thread starter Deleted member 49793
  • Start date
D

Deleted member 49793

Guest
Looking for a script for 1.1 TFS that boosts a players exp for X minutes, (example 2 hours)

Anyone have one made or can put one together?
 
Here you go =)

Tested with TFS 1.1

Double exp will last 24 hours. Can be changed here

Lua:
player:setStorageValue(1234, os.time() + 86400)

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local player = Player(cid)
    if player:getStorageValue(1234) >= os.time() then
        player:say('You already have double exp!', TALKTYPE_MONSTER_SAY)
        return true
    end

    player:setStorageValue(1234, os.time() + 86400)
    Item(item.uid):remove(1)
    player:say('Your 24 hours of double XP has started!', TALKTYPE_MONSTER_SAY)
    return true
end

function Player:onGainExperience(source, exp, rawExp)
    if self:getStorageValue(1234) >= os.time() then
        exp = exp * 2
    end
    return exp
end
 
Hmmm just tester this, added to actions.xml like so
Code:
    <action itemid="1948" script="custom/expboost.lua"/>
When using the item, it works, says the 2x exp is added, when i try and use another says it's already active, however I'm still receiving 1x exp.
@beastn
 
Hmmm just tester this, added to actions.xml like so
Code:
    <action itemid="1948" script="custom/expboost.lua"/>
When using the item, it works, says the 2x exp is added, when i try and use another says it's already active, however I'm still receiving 1x exp.
@beastn
You using tfs 1.1 or 1.2?
 
mmm that script was 100% working with 1.1... when you start your server up see what version it is i know i was using 1.2 without knowing hahaha anyways. Try this.

/data/actions/script.lua
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local player = Player(cid)
    if player:getStorageValue(1234) >= os.time() then
        player:say('You already have double exp!', TALKTYPE_MONSTER_SAY)
        return true
    end
  
    player:setStorageValue(1234, os.time() + 86400)
    Item(item.uid):remove(1)
    player:say('Your 24 hours of double XP has started!', TALKTYPE_MONSTER_SAY)
    return true
end

data/events/scripts/player.lua

Add this
Code:
     if self:getStorageValue(1234) >= os.time() then
        exp = exp * 2
    end

after
Code:
    -- Stamina modifier
    if configManager.getBoolean(configKeys.STAMINA_SYSTEM) then
        useStamina(self)

        local staminaMinutes = self:getStamina()
        if staminaMinutes > 2400 and self:isPremium() then
            exp = exp * 1.5
        elseif staminaMinutes <= 840 then
            exp = exp * 0.5
        end
    end
 
Make sure that function is enabled in Events.xml:

Code:
<event class="Player" method="onGainExperience" enabled="1" />
 
mmm that script was 100% working with 1.1... when you start your server up see what version it is i know i was using 1.2 without knowing hahaha anyways. Try this.

/data/actions/script.lua
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local player = Player(cid)
    if player:getStorageValue(1234) >= os.time() then
        player:say('You already have double exp!', TALKTYPE_MONSTER_SAY)
        return true
    end

    player:setStorageValue(1234, os.time() + 86400)
    Item(item.uid):remove(1)
    player:say('Your 24 hours of double XP has started!', TALKTYPE_MONSTER_SAY)
    return true
end

data/events/scripts/player.lua

Add this
Code:
     if self:getStorageValue(1234) >= os.time() then
        exp = exp * 2
    end

after
Code:
    -- Stamina modifier
    if configManager.getBoolean(configKeys.STAMINA_SYSTEM) then
        useStamina(self)

        local staminaMinutes = self:getStamina()
        if staminaMinutes > 2400 and self:isPremium() then
            exp = exp * 1.5
        elseif staminaMinutes <= 840 then
            exp = exp * 0.5
        end
    end

Getting the error data/events/scripts/player.lua attempt to index global 'self' <a nil value>
Line 184 in main chunk - Could not load player.lua


This is how I added it to player.lua
Code:
     if self:getStorageValue(1234) >= os.time() then
        exp = exp * 2
    end
   
        -- Stamina modifier
    if configManager.getBoolean(configKeys.STAMINA_SYSTEM) then
        useStamina(self)

        local staminaMinutes = self:getStamina()
        if staminaMinutes > 2400 and self:isPremium() then
            exp = exp * 1.5
        elseif staminaMinutes <= 840 then
            exp = exp * 0.5
        end
    end
 
Getting the error data/events/scripts/player.lua attempt to index global 'self' <a nil value>
Line 184 in main chunk - Could not load player.lua


This is how I added it to player.lua
Code:
     if self:getStorageValue(1234) >= os.time() then
        exp = exp * 2
    end
  
        -- Stamina modifier
    if configManager.getBoolean(configKeys.STAMINA_SYSTEM) then
        useStamina(self)

        local staminaMinutes = self:getStamina()
        if staminaMinutes > 2400 and self:isPremium() then
            exp = exp * 1.5
        elseif staminaMinutes <= 840 then
            exp = exp * 0.5
        end
    end

Could you copy & paste your whole player.lua file here: http://pastebin.com/ and send us the link.
 
Still getting same amount of exp before and after using scroll D:

Are you testing on a non-god char? Double check that you enabled it in events.xml as well and make sure you /reload events

Code:
<event class="Player" method="onGainExperience" enabled="1" />
 
Are you testing on a non-god char? Double check that you enabled it in events.xml as well and make sure you /reload events

Code:
<event class="Player" method="onGainExperience" enabled="1" />
Yes I am, that is exactly what I have an I restarted the server when I tested

Are you using exp stages?

Yep

For some odd reason before I added these scripts, I was getting the stages exp, since adding them, I get normal tibia exp (5 for a rat)
 
mmm that script was 100% working with 1.1... when you start your server up see what version it is i know i was using 1.2 without knowing hahaha anyways. Try this.

/data/actions/script.lua
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local player = Player(cid)
    if player:getStorageValue(1234) >= os.time() then
        player:say('You already have double exp!', TALKTYPE_MONSTER_SAY)
        return true
    end
 
    player:setStorageValue(1234, os.time() + 86400)
    Item(item.uid):remove(1)
    player:say('Your 24 hours of double XP has started!', TALKTYPE_MONSTER_SAY)
    return true
end

data/events/scripts/player.lua

Add this
Code:
     if self:getStorageValue(1234) >= os.time() then
        exp = exp * 2
    end

after
Code:
    -- Stamina modifier
    if configManager.getBoolean(configKeys.STAMINA_SYSTEM) then
        useStamina(self)

        local staminaMinutes = self:getStamina()
        if staminaMinutes > 2400 and self:isPremium() then
            exp = exp * 1.5
        elseif staminaMinutes <= 840 then
            exp = exp * 0.5
        end
    end


hello sir i really want to test this ot. but im not sure where to add all of these codes
 
hello sir i really want to test this ot. but im not sure where to add all of these codes
Hey :D its just like he said in the reply to me. The script works great. I asked for this long long ago, but i use it everyday on my server. If you need help installing it just pm me
 
Back
Top