Ecstacy
Mothafuckaaa
Hey,
I'm having a problem with a looping event, and is caused when the player logs out, since the player can't be found anymore by the game and the script adds a certain percentage of hp&mana per second.
The exact error is (luaGetCreatureStorage) creature not found. and as stated above, I know why it is caused,
But I would like to know if there is any way to avoid this error (maybe C++ coding?) since I wouldn't want this error to be spammed i.e. when 20 players log out at the same time.
The script in case you might need it.
script:
I'm having a problem with a looping event, and is caused when the player logs out, since the player can't be found anymore by the game and the script adds a certain percentage of hp&mana per second.
The exact error is (luaGetCreatureStorage) creature not found. and as stated above, I know why it is caused,
But I would like to know if there is any way to avoid this error (maybe C++ coding?) since I wouldn't want this error to be spammed i.e. when 20 players log out at the same time.
The script in case you might need it.
script:
Lua:
local configs = {
percent = 1.5, -- percent of max mana that will be added
interval = 1*1000, -- time to add mana again
storage = 12002
}
local function addMana(cid, interval, storage, perc)
if(getPlayerStorageValue(cid,storage) == 1)then
if (getCreatureMana(cid) < getCreatureMaxMana(cid)) then
doCreatureAddMana(cid, getCreatureMaxMana(cid)/100*perc)
end
if (getCreatureHealth(cid) < getCreatureMaxHealth(cid)) then
doCreatureAddHealth(cid, getCreatureMaxHealth(cid)/100*perc)
doSendMagicEffect(getThingPos(cid),CONST_ME_TELEPORT)
end
addEvent(addMana, interval, cid, interval,storage,perc)
end
return true
end
function onEquip(cid, item, slot)
setPlayerStorageValue(cid,configs.storage,1)
addEvent(addMana, 0, cid, configs.interval,configs.storage,configs.percent)
return true
end
function onDeEquip(cid, item, slot)
stopEvent(addMana)
setPlayerStorageValue(cid,configs.storage,0)
return false
end