• 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!

Lua Edit magic to teleport .

julhinhuu

New Member
Joined
Jul 16, 2011
Messages
35
Reaction score
0
Put teleport script to not pass through walls, rivers , etc , only used when 3 free spaces .
Code:
local times = 3
function isWalkable(pos, creature, proj, pz)-- by Nord
  if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end
  if getTopCreature(pos).uid > 0 and creature then return false end
  if getTileInfo(pos).protection and pz then return false, true end
  local n = not proj and 1 or 1
  for i = 0, 255 do
  pos.stackpos = i
  local tile = getTileThingByPos(pos)
  if tile.itemid ~= 0 and not isCreature(tile.uid) then
  if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
  return false
  end
  end
  end
  return true
end
function onCastSpell(cid)
  local playerPos = getCreaturePosition(cid)
  local toPos = {
  [0] = {x = playerPos.x, y = playerPos.y - times, z = playerPos.z},
  [1] = {x = playerPos.x + times, y = playerPos.y, z = playerPos.z},
  [2] = {x = playerPos.x, y = playerPos.y + times, z = playerPos.z},
  [3] = {x = playerPos.x - times, y = playerPos.y, z = playerPos.z}
  }
  
  local spellToPos = toPos[getPlayerLookDir(cid)]
  if isWalkable(spellToPos) then
  doTeleportThing(cid, spellToPos)
  else
  doPlayerSendCancel(cid, "Sorry, destination not possible.")
  end
  return true
end
 
Back
Top