• 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:
Add this after the storage check:

player:setExperienceRate(cid, SKILL__LEVEL, config.rate)
And change this:

player:setStorageValue(80000, os.time() + 2 * 60 * 60)​

To this:

player:setStorageValue(config.storage, os.time() + config.time * 60 * 60)​
 
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local player = Player(cid)
       if player:getStorageValue(80000) <= os.time() then
         player:setExperienceRate(cid, SKILL__LEVEL, config.rate)
            player:setStorageValue(config.storage, os.time() + config.time * 60 * 60)
            Item(item.uid):remove(1)
            player:say("You have just activated 2 hours of Double Experience!", TALKTYPE_MONSTER_SAY)
       else
       player:sendTextMessage(MESSAGE_INFO_DESCR, "You still have extra experience time left.")
       end
return true
end

now error in console unexpected near Item line 17 which is Item(item.uid):remove(1)
 
Last edited by a moderator:
Change "80000" to config.storage.

There's nothing wrong with the part that removes the item. Check error message again. Paste it here, please.
 
Last edited:
Add this after the storage check:

player:setExperienceRate(cid, SKILL__LEVEL, config.rate)
And change this:

player:setStorageValue(80000, os.time() + 2 * 60 * 60)​

To this:

player:setStorageValue(config.storage, os.time() + config.time * 60 * 60)​
Their both the same thing if config.storage equals 80000
 
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local player = Player(cid)
       if player:getStorageValue(config.storage) <= os.time() then
         player:setExperienceRate(cid, SKILL__LEVEL, config.rate)
            player:setStorageValue(config.storage, os.time() + config.time * 60 * 60)
            Item(item.uid):remove(1)
            player:say("You have just activated 2 hours of Double Experience!", TALKTYPE_MONSTER_SAY)
       else
       player:sendTextMessage(MESSAGE_INFO_DESCR, "You still have extra experience time left.")
       end
return true
end

Still same error ;/ '=' expected near 'Item'

Have I added something in the wrong spot?
 
Last edited by a moderator:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local player = Player(cid)
if player:getStorageValue(config.storage) <= os.time() then
player:setExperienceRate(cid, SKILL__LEVEL, config.rate)
player:setStorageValue(config.storage, os.time() + config.time * 60 * 60)
Item(item.uid):remove(1)
player:say("You have just activated 2 hours of Double Experience!", TALKTYPE_MONSTER_SAY)
else
player:sendTextMessage(MESSAGE_INFO_DESCR, "You still have extra experience time left.")
end
return true
end

Still same error ;/ '=' expected near 'Item'

Have I added something in the wrong spot?
Code:
item:remove(1)
 
You guys are great help, the error isn't changing however. Still says the same thing on line 17 '=' expected near 'item'
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local player = Player(cid)
       if player:getStorageValue(config.storage) <= os.time() then
         player:setExperienceRate(cid, SKILL__LEVEL, config.rate)
            player:setStorageValue(config.storage, os.time() + config.time * 60 * 60)
            item:remove(1)
            player:say("You have just activated 2 hours of Double Experience!", TALKTYPE_MONSTER_SAY)
sorry for me being stupid this is probably an easier fix then i'm making it lol
EDIT added the 1 in your post and still same error ;/
 
Last edited by a moderator:
You guys are great help, the error isn't changing however. Still says the same thing on line 17 '=' expected near 'item'

function onUse(cid, item, fromPosition, itemEx, toPosition)
local player = Player(cid)
if player:getStorageValue(config.storage) <= os.time() then
player:setExperienceRate(cid, SKILL__LEVEL, config.rate)
player:setStorageValue(config.storage, os.time() + config.time * 60 * 60)
item:remove(1)
player:say("You have just activated 2 hours of Double Experience!", TALKTYPE_MONSTER_SAY)

sorry for me being stupid this is probably an easier fix then i'm making it lol
EDIT added the 1 in your post and still same error ;/

I've rewritten the code. You can view it here. Give it a shot and report back. ;)

<sarcasm> If this is a donation item, I want 5% of all sales. </sarcasm>
 
Thanks very much :) Here is the newest issue in my ongoing saga lol.
Lua Script Error: [Action Interface]
data/actions/scripts/other/expscroll.lua:eek:nUse
data/actions/scripts/other/expscroll.lua:20: attempt to call method 'setExperienceRate' (a nil value)
stack traceback:
[C]: in function 'setExperienceRate'
data/actions/scripts/other/expscroll.lua:20: in function <data/actions/scripts/other/expscroll.lua:13>
 
You need to make a function that changes the experience rate of the player. 'setExperienceRate' doesn't seem to exist in TFS 1.2.

Unfortunately, I'm unable to help you with that part. However, if you find someone to help you make it, I suggest making something that is able to change every type of rate [e.g. player:setRate(cid, ...)] - a function that works with all of them (magic, skills, etc.) and not only experience. It may come in handy later on. ;)

Good luck.
 
Last edited:
You can use the Player event onGainExperience to apply extra experience.

Code:
if self:getStorageValue(storageKey) >= os.time() then
    exp = exp * expRate
end
 
Is that something I'd add into player.lua or my exp scroll script? or possibly both?
Just player.lua, and remove the line where you trying to call the method Player.setExperienceRate from your action script.
 
Lua Script Error: [Main Interface]
in a timer event called from:
(Unknown scriptfile)
data/actions/scripts/other/expscroll.lua:8: attempt to index local 'player' (a nil value)
stack traceback:
[C]: in function '__index'
data/actions/scripts/other/expscroll.lua:8: in function <data/actions/scripts/other/expscroll.lua:7>
Code:
function Player:onGainExperience(source, exp, rawExp)
    if self:getStorageValue(storageKey) >= os.time() then
    exp = exp * 2
    end
    if not source or source:isPlayer() then
        return exp
    end
This is what I did to my player.lua and I removed that line you told me to remove, it allows me to use the item, gives me the message that I've recieved double exp but it doesn't work nor does the scroll go away..;/ Does this just not work for tfs 1,2?

Thanks !

Code:
local t = {
    originalRate = 3.0, -- rate that should return to
    rateTime = 2 * 60 * 60,
    storage = 200011
}
local function endRate(player, cid)
    player:setStorageValue(cid, t.storage, -1)
    player:setExperienceRate(cid, SKILL__LEVEL, t.originalRate)
    player:sendTextMessage(cid, MESSAGE_INFO_DESCR, "Your extra experience time has ended.")
end
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getStorageValue(t.storage) >= os.time() then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You still have extra experience time left.")
    else
        player:removeItem(item.uid)
        fromPosition:sendMagicEffect(CONST_ME_MAGIC_RED)
        player:setStorageValue(t.storage, (os.time() + t.rateTime))
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have activated " .. string.format("%.1d", tonumber(t.rateTime) / (60 * 60)) .. " hours of double experience!")
        addEvent(endRate, t.rateTime)
    end
    return true
end
 
Last edited by a moderator:
@Ninja u can help to add creaturescript when the player log off

you can help with 2 types of scroll exp . a case he log off , the bonus time runs . Example (he has 30 minutes if he gets 30 minutes off line , when he will have lost log . ) and another would be if he has 30 minutes , it is offline and then back still gets time
 
Back
Top