Hi,
I have an exp scroll that increases rate by 1.5x but it deducts time when players are offline. Can someone help me add a feature so it only deducts time when the player is logged in. I'm not very good at coding so I can't tell if this script does that, if so then it doesn't work
XML Script:
Lua Script:
I have an exp scroll that increases rate by 1.5x but it deducts time when players are offline. Can someone help me add a feature so it only deducts time when the player is logged in. I'm not very good at coding so I can't tell if this script does that, if so then it doesn't work
XML Script:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Experience Stages Scroll" version="1.0" enabled="yes">
<action itemid="7722" event="script" value="2hour 1.5x expscroll.lua"/>
<creatureevent type="think" name="ExpStage" event="script" value="2hour 1.5x expscroll.lua"/>
<creatureevent type="login" name="ExpStageLogin" event="script" value="2hour 1.5x expscroll.lua"/>
<creatureevent type="death" name="Expdeath" event="script" value="2hour 1.5x expscroll.lua"/>
</mod>
Lua Script:
Code:
local config = {
rate = 1.5,
storage = 1000,
expstorage = 1100,
register = 1200,
time = 3600,
}
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 == 7724
doCreatureSay(cid, "Additional experience activated! You're now getting " .. config.rate .. "x your current 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 are already using an Experience Scroll, wait until it expires to use another.", 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, "The 1.5x Experience bonus has now expired.", 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, "You Have experience bonus active, and this multiplied by " .. config.rate .. "x.", 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
function onDeath(cid, corpse, deathList)
if(getPlayerStorageValue(cid, config.storage) == 1) then
doPlayerSetStorageValue(uid, config.storage, -1)
unregisterCreatureEvent(cid, "Expdeath")
end
return true
end
Last edited: