I made a spell that you summon a fire totem. And i want it to disappear after 5 sec.. how can i do it?
Code:
function onCastSpell(cid, var)
local pos = getThingPos(cid)
if(getTilePzInfo(getCreaturePosition(cid)) == true) then
doCreatureSay(cid, "You cannot summon in PZ!", TALKTYPE_ORANGE_1)
doSendMagicEffect(pos, CONST_ME_POFF)
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
return true
end
if table.maxn(getCreatureSummons(cid)) > 0 then
doPlayerSendCancel(cid, "You can't summon more than one.")
doSendMagicEffect(pos, CONST_ME_POFF)
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
else
doConvinceCreature(cid, doCreateMonster("Fire Totem", pos))
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
doPlayerSendCancel(cid, "You put out your fire totem.")
setPlayerStorageValue(cid, 21981)
end
config = {
formula = (getCreatureMaxHealth(cid) / 100) * 5,
form = (getCreatureMaxHealth(cid) / 100) * 1,
}
function onKill(cid, target, damage, flags)
if getPlayerStorageValue(cid, 151015) == 1 then
doCreatureAddHealth(cid, config.formula)
else
doCreatureAddHealth(cid, config.form)
end
return true
end
end