jeffaklumpen
Member
I have a scroll that when activated gives 2x xp for 2 hours.
I also have a event that triggers once every day and lasts for 1 hour that gives 2x XP:
I want the scroll to wear off once the event starts. The issue is that if a player has the scroll active before the event starts, once the event starts you only get 1x xp instead of the 2x that the event should give. I don't want the scroll to stack with the event.
Everything works fine when using them separate, the issue is when having a scroll active before the event starts.
Also noticed that when you relog with the XP scroll active the rates increase even more
Lua:
local config = {
rate = 2,
storage = 1000,
expstorage = 1100,
register = 1200,
time = 7200,
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerStorageValue(cid, config.storage) <= 0 and getStorage(3000) == -1 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")
elseif getStorage(3000) == 1 then
doCreatureSay(cid, "You cannot activate the experience tome during a double XP event.", TALKTYPE_ORANGE_1, true, cid)
else
doCreatureSay(cid, "You already have a experience tome active!", 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")
elseif getStorage(3000) == 1 then
doCreatureSay(cid, "As the double XP event activates the effecs from the experience scroll fades.", 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
I also have a event that triggers once every day and lasts for 1 hour that gives 2x XP:
Code:
local cyko = {
new_rate = 2,
old_rate = 1
}
function onTime()
if getStorage(3000) == -1 then
doSetStorage(3000, 1)
doBroadcastMessage("Double XP is now active for one hour!")
for _, on in ipairs(getPlayersOnline()) do
doPlayerSetRate(on, SKILL__LEVEL, cyko.new_rate)
end
else
doSetStorage(3000, -1)
doBroadcastMessage("The double XP event has ended.")
for _, off in ipairs(getPlayersOnline()) do
doPlayerSetRate(off, SKILL__LEVEL, cyko.old_rate)
end
end
return true
end
I want the scroll to wear off once the event starts. The issue is that if a player has the scroll active before the event starts, once the event starts you only get 1x xp instead of the 2x that the event should give. I don't want the scroll to stack with the event.
Everything works fine when using them separate, the issue is when having a scroll active before the event starts.
Post automatically merged:
Also noticed that when you relog with the XP scroll active the rates increase even more
Last edited: