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

exp potion

thefrancis

New Member
Joined
Apr 16, 2010
Messages
22
Reaction score
1
By chance someone has a potion, which double experience revscripts?... It is so that players can buy it apart from the TC.
 
Changed this to Revscripts, Try it.
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

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)
    return true
end

local experiencepotion = Action()

local storage1 = 200000
local storage2 = 200001

local scrollDecayTimeAlways = 1110 -- 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 experiencepotion.onUse(player, item, fromPos, target, toPos, 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

experiencepotion:id(1110, 1111)
experiencepotion:register()

local ec = EventCallback

function ec.onGainExperience(source, exp, rawExp)
    if not source or source:isPlayer() then
        return exp
    end

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

ec:register(666)

local login = CreatureEvent("experience_potion")

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

login:register()
It is so that players can buy it apart from the TC.
I think you've to add it as a market item to buy it for TC?
Anyway try this.
 
Last edited:
Changed this to Revscripts, Try it.
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

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)
    return true
end

local experiencepotion = Action()

local storage1 = 200000
local storage2 = 200001

local scrollDecayTimeAlways = 1110 -- 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 experiencepotion.onUse(player, item, fromPos, target, toPos, 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

experiencepotion:id(1110, 1111)
experiencepotion:register()

local ec = EventCallback

function ec.onGainExperience(source, exp, rawExp)
    if not source or source:isPlayer() then
        return exp
    end

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

ec:register(666)

local login = CreatureEvent("experience_potion")

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

login:register()

I think you've to add it as a market item to buy it for TC?
Anyway try this.
How do I put the item?
 
I just wrote random item ids 1110 and 1111 you should change them to the ones you want, no aid or uid.
 
I just wrote random item ids 1110 and 1111 you should change them to the ones you want, no aid or uid.
C:\Users\Usuaio\Desktop\forgottenserver-otclientv8\forgottenserver-otclientv8\data\scripts\dobleexp.lua
...tv8\forgottenserver-otclientv8\data\scripts\dobleexp.lua:87: attempt to index local 'ec' (a nil value)
stack traceback:
[C]: in function '__newindex'
...tv8\forgottenserver-otclientv8\data\scripts\dobleexp.lua:87: in main chunk

it throws me this error
 
Changed this to Revscripts, Try it.
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

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)
    return true
end

local experiencepotion = Action()

local storage1 = 200000
local storage2 = 200001

local scrollDecayTimeAlways = 1110 -- 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 experiencepotion.onUse(player, item, fromPos, target, toPos, 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

experiencepotion:id(1110, 1111)
experiencepotion:register()

local ec = EventCallback

function ec.onGainExperience(source, exp, rawExp)
    if not source or source:isPlayer() then
        return exp
    end

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

ec:register(666)

local login = CreatureEvent("experience_potion")

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

login:register()

I think you've to add it as a market item to buy it for TC?
Anyway try this.

I put this script in my tfs 1.5 but it didn't work, instead of gaining double the exp my character didn't gain any exp ;d
 
Back
Top