• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved Magic/grav

imback1

Unknown member
Joined
Jul 11, 2013
Messages
785
Solutions
1
Reaction score
46
How can i do magicwall/grav vita unusable at some areas? like events.
TFS 0.4
 
Should 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
 
Should 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
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 script
 
untested

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
 
untested

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
that's what i found :S
Code:
[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
Code:
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
Code:
[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>'
@Shawak
 
Last edited:
Back
Top