This is my spell. When player says "charge" it should make him unable to move and start regenerating 40 mana per second. When charge is on and player says "charge" again it should make him able to move and stop mana regenerating and this is problem mana is still regenerating. Pls help me
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)
function regen(cid)
if isPlayer(cid) then
doCreatureAddMana(cid, 40)
end
end
function onCastSpell(cid, var)
if exhaustion.check(cid, 99998) then
doPlayerSendCancel(cid, "You are exhausted")
else
if (getCreatureStorage(cid, 99999) ~= 1) then
doCreatureSetNoMove(cid, true)
doCreatureSetStorage(cid, 99999, 1)
for i = 1, 3600 do
local ev = addEvent(regen, i * 1000, cid)
end
return doCombat(cid, combat, var)
else
doCreatureSetNoMove(cid, false)
doCreatureSetStorage(cid, 99999, 0)
exhaustion.set(cid, 99998, 1200000)
stopEvent(ev)
end
end
end
Last edited: