function onCastSpell(cid, var)
return doCombat(cid, combat, var)
end
local areaPosition = {
topLeft = Position(1000, 1000, 7),
bottomRight = Position(1100, 1100, 7)
}
function onCastSpell(cid, var)
if isInRange(getCreaturePosition(cid), areaPosition.topLeft, areaPosition.bottomRight) then
doPlayerSendCancel(cid, "You can't cast magic wall runes inside a event area.")
return false
else
return doCombat(cid, combat, var)
end
end
Thanks, i will try it but what if i have like 3 events? and i need to unusable mwall with it, as i can see that there is one area only with your scriptShould be possible to check if the player is in a certain area.
Place the code inside the function onSpell in magic wall rune's script.
Code:function onCastSpell(cid, var) return doCombat(cid, combat, var) end
Maybe something like this (untested):
Code:local areaPosition = { topLeft = Position(1000, 1000, 7), bottomRight = Position(1100, 1100, 7) } function onCastSpell(cid, var) if isInRange(getCreaturePosition(cid), areaPosition.topLeft, areaPosition.bottomRight) then doPlayerSendCancel(cid, "You can't cast magic wall runes inside a event area.") return false else return doCombat(cid, combat, var) end end
local areas = {
{topLeft = Position(1000, 1000, 7), bottomRight = Position(1100, 1100, 7)},
{topLeft = Position(1000, 1000, 7), bottomRight = Position(1100, 1100, 7)},
{topLeft = Position(1000, 1000, 7), bottomRight = Position(1100, 1100, 7)},
}
function onCastSpell(cid, var)
for i = 1, #areas do
if isInRange(getCreaturePosition(cid), areas[i].topLeft, areas[i].bottomRight) then
doPlayerSendCancel(cid, "You can't cast magic wall runes inside a event area.")
return false
end
end
return doCombat(cid, combat, var)
end
that's what i found :Suntested
Code:local areas = { {topLeft = Position(1000, 1000, 7), bottomRight = Position(1100, 1100, 7)}, {topLeft = Position(1000, 1000, 7), bottomRight = Position(1100, 1100, 7)}, {topLeft = Position(1000, 1000, 7), bottomRight = Position(1100, 1100, 7)}, } function onCastSpell(cid, var) for i = 1, #areas do if isInRange(getCreaturePosition(cid), areas[i].topLeft, areas[i].bottomRight) then doPlayerSendCancel(cid, "You can't cast magic wall runes inside a event area.") return false end end return doCombat(cid, combat, var) end
[12/03/2016 17:41:28] [Error - Spell Interface]
[12/03/2016 17:41:28] data/spells/scripts/support/wild growth rune.lua
[12/03/2016 17:41:28] Description:
[12/03/2016 17:41:29] data/spells/scripts/support/wild growth rune.lua:5: attempt to call global 'Position' (a nil value)
[12/03/2016 17:41:29] [Warning - Event::loadScript] Cannot load script (data/spells/scripts/support/wild growth rune.lua)
[12/03/2016 17:41:29] data/spells/scripts/support/magic wall rune.lua:23: 'end' expected (to close 'function' at line 10) near '<eof>'
try adding
Code:local function Position(x, y, z) return {x = x, y = y, z = z} end
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_EARTH)
setCombatParam(combat, COMBAT_PARAM_CREATEITEM, 1499)
local areas = {
{topLeft = Position(1000, 1000, 7), bottomRight = Position(1100, 1100, 7)},
{topLeft = Position(1000, 1000, 7), bottomRight = Position(1100, 1100, 7)},
{topLeft = Position(1000, 1000, 7), bottomRight = Position(1100, 1100, 7)},
}
local function Position(x, y, z)
return {x = x, y = y, z = z}
end
function onCastSpell(cid, var)
for i = 1, #areas do
if isInRange(getCreaturePosition(cid), areas[i].topLeft, areas[i].bottomRight) then
doPlayerSendCancel(cid, "You can't cast magic wall runes inside a event area.")
return false
end
end
return doCombat(cid, combat, var)
end
[12/03/2016 18:00:40] [Error - Spell Interface]
[12/03/2016 18:00:40] data/spells/scripts/support/wild growth rune.lua
[12/03/2016 18:00:40] Description:
[12/03/2016 18:00:40] data/spells/scripts/support/wild growth rune.lua:5: attempt to call global 'Position' (a nil value)
[12/03/2016 18:00:40] [Warning - Event::loadScript] Cannot load script (data/spells/scripts/support/wild growth rune.lua)
[12/03/2016 18:00:40] data/spells/scripts/support/magic wall rune.lua:23: 'end' expected (to close 'function' at line 10) near '<eof>'