xYzPrototype
Just a standard member
Hey guys,
This exp scroll I found works great, but when the time runs out on the character I get this error:
The script works fine, its just once a player has used a scroll, they cannot use it again?
Could anyone help me solve this please? I have my script right here:
This exp scroll I found works great, but when the time runs out on the character I get this error:
Code:
[04/04/2015 11:10:05] [Error - CreatureScript Interface]
[04/04/2015 11:10:05] mods/scripts/2hour triple expscroll.lua:onThink
[04/04/2015 11:10:05] Description:
[04/04/2015 11:10:05] mods/scripts/2hour triple expscroll.lua:34: attempt to call global 'unregisterCreatureEvent' (a nil value)
[04/04/2015 11:10:05] stack traceback:
[04/04/2015 11:10:05] mods/scripts/2hour triple expscroll.lua:34: in function <mods/scripts/2hour triple expscroll.lua:26>
The script works fine, its just once a player has used a scroll, they cannot use it again?
Could anyone help me solve this please? I have my script right here:
Code:
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 then
local rates = getPlayerRates(cid)
setPlayerStorageValue(cid, config.expstorage, rates[SKILL__LEVEL])
setPlayerStorageValue(cid, config.register, 1)
itemEx=itemid == 7727
doCreatureSay(cid, "Additional experience activated! You're now getting 3x you're 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 3x experience bonus rate 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 bonus experience active, this is giving you triple exp", 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: