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

Solved EXP scroll not working TFS 1.2

jimmydunphy

New Member
Joined
Aug 9, 2007
Messages
68
Reaction score
3
Location
Nova Scotia Canada
When I use the exp scroll I get 50% less exp instead of double exp?

This is the script I've used and im using tfs 1.2
Code:
local config = {
    time = 2,
    storage = 200011
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getStorageValue(config.storage) >= os.time() then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You still have extra experience time left.")
        return true
    end

    player:setStorageValue(config.storage, os.time() + config.time * 3600)
    player:sendTextMessage(MESSAGE_INFO_DESCR, string.format("You have activated %d hour%s of double experience.", config.time, config.time ~= 1 and "s" or ""))
    item:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
    item:remove(1)
    return true
end

This is the updated and working copy of the exp scroll for tfs 1.2 that I'm using. Credits to @Ninja for re-writing this whole thing for me and thanks to @J.Dre and @Codex NG for their help aswell!

Happy New Year!
 
Last edited:
For older clients (772) for example but still using tfs 1.2 I would just remove the stamina and soul part and it should work?

your are not supposed to change your player.lua with that, just add the:

Lua:
if self:getStorageValue(storageKey) >= os.time() then
    exp = exp * expRate
end

before the return exp
 
Action
Lua:
local storage1 = 200000
local storage2 = 200001

local scrollDecayTimeAlways = 1111 -- Exp time on scroll always runs even if player is offline --
local scrollDecayTimeOnline = 1111 -- Exp time on scroll only goes down if player is online --

local expTime = 2 * 60 * 60 -- 2 hours --

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == scrollDecayTimeAlways then
        if player:getStorageValue(storage1) < os.time() then
            player:setStorageValue(storage1, os.time() + expTime)
        else
            player:setStorageValue(storage1, player:getStorageValue(storage1) + expTime)
        end
        
        item:remove(1)
        fromPosition:sendMagicEffect(CONST_ME_MAGIC_RED)
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You now have "..convertTimeToText(player:getStorageValue(storage1) - os.time()).." of double exp time. This time will decay even if you are logged out.")
        return true
    elseif item.itemid == scrollDecayTimeOnline then
        if player:getStorageValue(storage2) <= 0 then
            player:setStorageValue(storage2, expTime)
        else
            player:setStorageValue(storage2, player:getStorageValue(storage2) + expTime)
        end
        
        item:remove(1)
        fromPosition:sendMagicEffect(CONST_ME_MAGIC_RED)
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You now have "..convertTimeToText(player:getStorageValue(storage1) - os.time()).." of double exp time. This time will only decay if you are logged in.")
    end
return true
end

global.lua add
Lua:
function convertTimeToText(time)
    local hours = 0
    local minutes = 0
    local seconds = 0
    
    while time >= 3600 do
        hours = hours + 1
        time = time - 3600
    end
    
    while time >= 60 do
        minutes = minutes + 1
        time = time - 60
    end
    
    while time >= 1 do
        seconds = seconds + 1
        time = time - 1
    end
    
    local text = "[Hours]: "..hours.." [Minutes]: "..minutes.." [Seconds]: "..seconds
return text
end

player.lua (data/events/scripts)
Lua:
if self:getStorageValue(200000) >= os.time() then
        exp = exp * 2
    end
    if self:getStorageValue(200001) > 0 then
        exp = exp * 2
    end

login.lua
Lua:
function onLogin(player)
    addEvent(decayExpScroll, 60 * 1000, player:getName())
return true
end

function decayExpScroll(name)
    local player = Player(name)
    if not player then return true end
    
    player:setStorageValue(200001, player:getStorageValue(200001) - 60)
    addEvent(decayExpScroll, 60 * 1000, name)
end
 
data/events/scripts/player.lua - Player:onGainExperience
Lua Script Error: [Event Interface]
data/events/scripts/player.lua:player@onGainExperience
data/events/scripts/player.lua:232: attempt to perform arithmetic on a nil value

stack traceback:
[C]: in function '__sub'
data/events/scripts/player.lua:232: in function 'useStamina'
data/events/scripts/player.lua:275: in function <data/events/scripts/pla
yer.lua:251>

this error in console after clicking and trying to kill a monster this happens
 
unless you pasted the code inside useStamina function , that error seems to be unrelated
 
unless you pasted the code inside useStamina function , that error seems to be unrelated
function Player:eek:nGainExperience(source, exp, rawExp)
if not source or source:isPlayer() then
return exp
end

if self:getStorageValue(200000) >= os.time() then
exp = exp * 0.50
end
if self:getStorageValue(200001) > 0 then
exp = exp * 0.50
end

-- Soul regeneration
local vocation = self:getVocation()
if self:getSoul() < vocation:getMaxSoul() and exp >= self:getLevel() then
soulCondition:setParameter(CONDITION_PARAM_SOULTICKS, vocation:getSoulGainTicks() * 1000)
self:addCondition(soulCondition)
end

-- Apply experience stage multiplier
exp = exp * Game.getExperienceStage(self:getLevel())

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

return exp
end



So I have it, is it ok?
Post automatically merged:

up
 
Last edited:
Back
Top