function onStatsChange(cid, attacker, type, combat, value)
if exhaustion.check(cid, 40902) then
return false
end
return true
end
<event type="statschange" name="BlockEffect" event="script" value="blockeffectspell.lua"/>
registerCreatureEvent(cid, "BlockEffect")
local c = {
storage = 40902,
time = 4
}
local cfg = {
fromPosition = {x = 32346, y = 32347, z = 13}, -- top left cornor of the playground
toPosition = {x = 32445, y = 32431, z = 13}, -- bottom right cornor of the playground
}
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH)
local function doBlockEffect(cid)
doSendAnimatedText(getPlayerPosition(cid), "Immune!", COLOR_GREY)
return doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_RED)
end
function onCastSpell(cid, var)
if isInRange(getPlayerPosition(cid), cfg.fromPosition, cfg.toPosition) then
return doPlayerSendCancel(cid, "You can't use this spell in event.")
end
local target = getTopCreature(variantToPosition(var)).uid
if not isPlayer(target) then
doPlayerSendCancel(cid, "Target has to be a player.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
return false
end
if exhaustion.check(target, c.storage) then
local n = target == cid and "You are" or getPlayerName(target).." is"
doPlayerSendCancel(cid, n.." already blocking attacks.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
return false
end
exhaustion.set(target, c.storage, c.time)
doSendAnimatedText(getPlayerPosition(cid), "Immune!", COLOR_YELLOW)
doCombat(cid, combat, var)
for x = 1, c.time do
addEvent(doBlockEffect, x * 1000, target)
end
return true
end
<instant name="protect me" words="Bonte" lvl="350" mana="200" prem="1" aggressive="0" blocktype="solid" soul="20" event="script" value="blockdamgspell.lua">
<vocation id="12"/>
<vocation id="10"/>
<vocation id="9"/>
<vocation id="11"/>
</instant>
Working perfectly but when i am using it, i can't use spells or potions :< is there a way to make it work with healing?in creaturescripts
Code:function onStatsChange(cid, attacker, type, combat, value) if exhaustion.check(cid, 40902) then return false end return true end
creaturescript.xml
Code:<event type="statschange" name="BlockEffect" event="script" value="blockeffectspell.lua"/>
in login.lua add
Code:registerCreatureEvent(cid, "BlockEffect")
spells
Code:local c = { storage = 40902, time = 4 } local cfg = { fromPosition = {x = 32346, y = 32347, z = 13}, -- top left cornor of the playground toPosition = {x = 32445, y = 32431, z = 13}, -- bottom right cornor of the playground } local combat = createCombatObject() setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED) setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH) local function doBlockEffect(cid) doSendAnimatedText(getPlayerPosition(cid), "Immune!", COLOR_GREY) return doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_RED) end function onCastSpell(cid, var) if isInRange(getPlayerPosition(cid), cfg.fromPosition, cfg.toPosition) then return doPlayerSendCancel(cid, "You can't use this spell in event.") end local target = getTopCreature(variantToPosition(var)).uid if not isPlayer(target) then doPlayerSendCancel(cid, "Target has to be a player.") doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF) return false end if exhaustion.check(target, c.storage) then local n = target == cid and "You are" or getPlayerName(target).." is" doPlayerSendCancel(cid, n.." already blocking attacks.") doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF) return false end exhaustion.set(target, c.storage, c.time) doSendAnimatedText(getPlayerPosition(cid), "Immune!", COLOR_YELLOW) doCombat(cid, combat, var) for x = 1, c.time do addEvent(doBlockEffect, x * 1000, target) end return true end
Code:<instant name="protect me" words="Bonte" lvl="350" mana="200" prem="1" aggressive="0" blocktype="solid" soul="20" event="script" value="blockdamgspell.lua"> <vocation id="12"/> <vocation id="10"/> <vocation id="9"/> <vocation id="11"/> </instant>
Working perfectly but when i am using it, i can't use spells or potions :< is there a way to make it work with healing?