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

Daniel Kopeć

Member
Joined
Dec 8, 2018
Messages
125
Solutions
4
Reaction score
12
Location
Poland
After using the exp scroll, it adds 2x experience.
But after relogging, it adds 1x more.

How to fix it? so that he does not give 1x more after relogging?

Here are my scripts:

mods/expscroll.xml

XML:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Experience Stages Scroll" version="1.0" author="TomCrusher" contact="otland.net" enabled="yes">
    <action itemid="9004" event="script" value="expstagescroll.lua"/>
    <creatureevent type="think" name="ExpStage" event="script" value="expstagescroll.lua"/>
    <creatureevent type="login" name="ExpStageLogin" event="script" value="expstagescroll.lua"/>
</mod>

mods/scripts/expstagescroll.lua

Lua:
local config = {
    rate = 2,
    storage = 1000,
    expstorage = 1100,
    register = 1200,
    time = 120,
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, config.storage) <= 0 then
        local rates = getPlayerRates(cid)
        setPlayerStorageValue(cid, config.expstorage, rates[SKILL__LEVEL])
        setPlayerStorageValue(cid, config.register, 1)
        itemEx=itemid == 9004
        doCreatureSay(cid, "Your extra experience rate has been activated! It now is: " .. config.rate .. "x added to your former experience rate.", TALKTYPE_ORANGE_1, true, cid)
        setPlayerStorageValue(cid, config.storage, os.time()+config.time)
        doPlayerSetExperienceRate(cid, rates[SKILL__LEVEL]*config.rate)
        doRemoveItem(item.uid,1)
        registerCreatureEvent(cid, "ExpStage")
    else
        doCreatureSay(cid, "You must finish first exp condition to start other exp condition !", TALKTYPE_ORANGE_1, true, cid)
    end
return true
end
function onThink(cid, interval)
    if getPlayerStorageValue(cid, config.register) == 1 then
        if getPlayerStorageValue(cid, config.storage) <= os.time() then
            doCreatureSay(cid, "Your extra experience rate has finished! It is now normaly experience rate.", TALKTYPE_ORANGE_1, true, cid)
            setPlayerStorageValue(cid, config.storage, 0)
            setPlayerStorageValue(cid, config.register, 0)
            local oldexp = getPlayerStorageValue(cid, config.expstorage)
            doPlayerSetExperienceRate(cid, oldexp)
            unregisterCreatureEvent(cid, "ExpStage")
        end
    end
return true
end
function onLogin(cid)
    if getPlayerStorageValue(cid, config.register) == 1 then
        registerCreatureEvent(cid, "ExpStage")
        local rates = getPlayerRates(cid)
        doCreatureSay(cid, "Your extra experience rate is still here! It is: " .. config.rate .. "x added to your former experience rate.", TALKTYPE_ORANGE_1, true, cid)
        if getPlayerStorageValue(cid, config.storage) > os.time() then
        local oldexp = getPlayerStorageValue(cid, config.expstorage)
        doPlayerSetExperienceRate(cid, oldexp+config.rate)
        end
    end 
return true
end
 
Solution
I understand that I have to create this lua script in the actions / scripts folder and call it expscroll.lua?


And what script is referencing this line in creaturescripts?
XML:
<creatureevent type="login" name="extraExperienceScroll" event="script" value="extraExperienceScroll.lua"/>
Sorry, i forgot, here extraexperiencescroll.lua

Lua:
local storage = 20014

local function endExpRate(cid)
    if isPlayer(cid) then
        doPlayerSetRate(cid, SKILL__LEVEL, 1) -- config.lua rate
        setPlayerStorageValue(cid, storage, -1)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Your extra experience time has ended.")
    end
end

function onLogin(cid)
    local storageValue = getPlayerStorageValue(cid, storage)...

potinho

Active Member
Joined
Oct 11, 2009
Messages
529
Solutions
14
Reaction score
43
Location
Brazil
I recommend use this:

lua
Lua:
local config = {
    rate = 2,
    time = 2 * 60 * 60, -- (2 hours) in seconds
    storage = 20014
}

local function endExpRate(cid)
    if isPlayer(cid) == TRUE then
        doPlayerSetRate(cid, SKILL__LEVEL, 1) -- config.lua rate
        setPlayerStorageValue(cid, config.storage, -1)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Your extra experience time has ended.")
    end
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, config.storage) < os.time() then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have experience rate x2 It will last for ".. (config.time / 3600) .." hours.")
        doPlayerSetRate(cid, SKILL__LEVEL, config.rate)
        setPlayerStorageValue(cid, config.storage, os.time() + config.time)
        addEvent(endExpRate, config.time * 1000, cid)
        doRemoveItem(item.uid, 1)
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You still have " .. (os.date('!%H:%M:%S', getPlayerStorageValue(cid, config.storage) - os.time())) .. " extra experience time left.")
    end
    return true
end

action xml

XML:
    <action itemid="item_id" event="script" value="expscroll.lua"/>

creaturescripts.xml
XML:
    <creatureevent type="login" name="extraExperienceScroll" event="script" value="extraExperienceScroll.lua"/>

And on login.lue:

registerCreatureEvent(cid, "extraExperienceScroll")
Post automatically merged:

U can see at board:

 
OP
OP
Daniel Kopeć

Daniel Kopeć

Member
Joined
Dec 8, 2018
Messages
125
Solutions
4
Reaction score
12
Location
Poland
I recommend use this:

lua
Lua:
local config = {
    rate = 2,
    time = 2 * 60 * 60, -- (2 hours) in seconds
    storage = 20014
}

local function endExpRate(cid)
    if isPlayer(cid) == TRUE then
        doPlayerSetRate(cid, SKILL__LEVEL, 1) -- config.lua rate
        setPlayerStorageValue(cid, config.storage, -1)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Your extra experience time has ended.")
    end
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, config.storage) < os.time() then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have experience rate x2 It will last for ".. (config.time / 3600) .." hours.")
        doPlayerSetRate(cid, SKILL__LEVEL, config.rate)
        setPlayerStorageValue(cid, config.storage, os.time() + config.time)
        addEvent(endExpRate, config.time * 1000, cid)
        doRemoveItem(item.uid, 1)
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You still have " .. (os.date('!%H:%M:%S', getPlayerStorageValue(cid, config.storage) - os.time())) .. " extra experience time left.")
    end
    return true
end

action xml

XML:
    <action itemid="item_id" event="script" value="expscroll.lua"/>

creaturescripts.xml
XML:
    <creatureevent type="login" name="extraExperienceScroll" event="script" value="extraExperienceScroll.lua"/>

And on login.lue:

registerCreatureEvent(cid, "extraExperienceScroll")
Post automatically merged:

U can see at board:


I understand that I have to create this lua script in the actions / scripts folder and call it expscroll.lua?


And what script is referencing this line in creaturescripts?
XML:
<creatureevent type="login" name="extraExperienceScroll" event="script" value="extraExperienceScroll.lua"/>
 

potinho

Active Member
Joined
Oct 11, 2009
Messages
529
Solutions
14
Reaction score
43
Location
Brazil
I understand that I have to create this lua script in the actions / scripts folder and call it expscroll.lua?


And what script is referencing this line in creaturescripts?
XML:
<creatureevent type="login" name="extraExperienceScroll" event="script" value="extraExperienceScroll.lua"/>
Sorry, i forgot, here extraexperiencescroll.lua

Lua:
local storage = 20014

local function endExpRate(cid)
    if isPlayer(cid) then
        doPlayerSetRate(cid, SKILL__LEVEL, 1) -- config.lua rate
        setPlayerStorageValue(cid, storage, -1)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Your extra experience time has ended.")
    end
end

function onLogin(cid)
    local storageValue = getPlayerStorageValue(cid, storage)
    local timeLeft = storageValue - os.time()
    if storageValue > os.time() then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Extra experience rate is now: 2.0x than normal. It will last for " .. (math.ceil(timeLeft/60)) .. " minutes.")
        doPlayerSetRate(cid, SKILL__LEVEL, 2.0)
        addEvent(endExpRate, timeLeft * 1000, cid)
    else
        doPlayerSetRate(cid, SKILL__LEVEL, 1.0)
    end
    return true
end
 
Solution
OP
OP
Daniel Kopeć

Daniel Kopeć

Member
Joined
Dec 8, 2018
Messages
125
Solutions
4
Reaction score
12
Location
Poland
Sorry, i forgot, here extraexperiencescroll.lua

Lua:
local storage = 20014

local function endExpRate(cid)
    if isPlayer(cid) then
        doPlayerSetRate(cid, SKILL__LEVEL, 1) -- config.lua rate
        setPlayerStorageValue(cid, storage, -1)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Your extra experience time has ended.")
    end
end

function onLogin(cid)
    local storageValue = getPlayerStorageValue(cid, storage)
    local timeLeft = storageValue - os.time()
    if storageValue > os.time() then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Extra experience rate is now: 2.0x than normal. It will last for " .. (math.ceil(timeLeft/60)) .. " minutes.")
        doPlayerSetRate(cid, SKILL__LEVEL, 2.0)
        addEvent(endExpRate, timeLeft * 1000, cid)
    else
        doPlayerSetRate(cid, SKILL__LEVEL, 1.0)
    end
    return true
end
Thank you very much. I'll do it and test it right away :)
Post automatically merged:

Sorry, i forgot, here extraexperiencescroll.lua

Lua:
local storage = 20014

local function endExpRate(cid)
    if isPlayer(cid) then
        doPlayerSetRate(cid, SKILL__LEVEL, 1) -- config.lua rate
        setPlayerStorageValue(cid, storage, -1)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Your extra experience time has ended.")
    end
end

function onLogin(cid)
    local storageValue = getPlayerStorageValue(cid, storage)
    local timeLeft = storageValue - os.time()
    if storageValue > os.time() then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Extra experience rate is now: 2.0x than normal. It will last for " .. (math.ceil(timeLeft/60)) .. " minutes.")
        doPlayerSetRate(cid, SKILL__LEVEL, 2.0)
        addEvent(endExpRate, timeLeft * 1000, cid)
    else
        doPlayerSetRate(cid, SKILL__LEVEL, 1.0)
    end
    return true
end
Works elegant. Thank you very much :) REP+
 
Last edited:

VagosClubTM

Member
Joined
Aug 16, 2019
Messages
37
Reaction score
11
Location
Chile
Sorry, i forgot, here extraexperiencescroll.lua

Lua:
local storage = 20014

local function endExpRate(cid)
    if isPlayer(cid) then
        doPlayerSetRate(cid, SKILL__LEVEL, 1) -- config.lua rate
        setPlayerStorageValue(cid, storage, -1)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Your extra experience time has ended.")
    end
end

function onLogin(cid)
    local storageValue = getPlayerStorageValue(cid, storage)
    local timeLeft = storageValue - os.time()
    if storageValue > os.time() then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Extra experience rate is now: 2.0x than normal. It will last for " .. (math.ceil(timeLeft/60)) .. " minutes.")
        doPlayerSetRate(cid, SKILL__LEVEL, 2.0)
        addEvent(endExpRate, timeLeft * 1000, cid)
    else
        doPlayerSetRate(cid, SKILL__LEVEL, 1.0)
    end
    return true
end


I am at this moment testifying
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,672
Solutions
405
Reaction score
3,785
I recommend use this:

lua
Lua:
local config = {
    rate = 2,
    time = 2 * 60 * 60, -- (2 hours) in seconds
    storage = 20014
}

local function endExpRate(cid)
    if isPlayer(cid) == TRUE then
        doPlayerSetRate(cid, SKILL__LEVEL, 1) -- config.lua rate
        setPlayerStorageValue(cid, config.storage, -1)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Your extra experience time has ended.")
    end
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, config.storage) < os.time() then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have experience rate x2 It will last for ".. (config.time / 3600) .." hours.")
        doPlayerSetRate(cid, SKILL__LEVEL, config.rate)
        setPlayerStorageValue(cid, config.storage, os.time() + config.time)
        addEvent(endExpRate, config.time * 1000, cid)
        doRemoveItem(item.uid, 1)
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You still have " .. (os.date('!%H:%M:%S', getPlayerStorageValue(cid, config.storage) - os.time())) .. " extra experience time left.")
    end
    return true
end

action xml

XML:
    <action itemid="item_id" event="script" value="expscroll.lua"/>

creaturescripts.xml
XML:
    <creatureevent type="login" name="extraExperienceScroll" event="script" value="extraExperienceScroll.lua"/>

And on login.lue:

registerCreatureEvent(cid, "extraExperienceScroll")
Post automatically merged:

U can see at board:

Ah. It's so nice to see someone grow in front of my eyes.

Keep up the good work.
 
Top