Caio Cesar
Member
Code:
local config = {
cooldown = 5, -- tempo entre uma magia e outra
tempo = 20, -- tempo em segundos que ficará healando
percent = 2, --- porcentagem da vida que cura
storage = 45382
}
function onCastSpell(cid, var)
local p = Creature(cid)
if os.time() - p:getStorageValue(cid, config.storage) >= config.cooldown then
for i = 1, config.tempo do
addEvent(function()
local lifedraw = math.ceil(p:getMaxHealth() * (config.percent)/100)
local pos = p:getPosition()
p:addHealth(cid, lifedraw, 1)
pos:sendMagicEffect(13)
end, 1000*i)
end
p:setStorageValue(cid, config.storage, os.time())
else
p:sendCancelMessage(cid, "Your Mass Healing is at cooldown, you must wait "..(config.cooldown - (os.time() - p:getStorageValue(cid, config.storage))).." seconds.")
end
return true
end
I did this spell , a heal over time, but if the player logout while the effect is on, my server crash.
How i can cancel a effect/event/etc over time if a player logout??
Last edited: