-- Area iterator by Colandus @ OpenLua.com
function mapArea(fromPos, toPos)
local x, y, z = fromPos.x, fromPos.y, fromPos.z
return function()
if (y < toPos.y) then
y = y+1
elseif (x < toPos.x) then
y = fromPos.y
x = x+1
else
x = fromPos.x
y = fromPos.y
z = z+1
end
if (x < toPos.x and y <= toPos.y or z < toPos.z) then
return x, y, z
end
end
end
local pos = getPlayerPosition(cid)
local fromPos = {x=pos.x-7, y=pos.y-5, z=pos.z}
local toPos = {x=pos.x+7, y=pos.y+5, z=pos.z}
for x, y, z in mapArea(fromPos, toPos) do
if (isCreature(getThingfromPos({x=x,y=y,z=z})) == 1) then
doPlayerSendTextMessage(cid, 22, "Creature!")
end
end
local npos = {x=34,y=45,z=345} -- Where shall you get tped to?
function onUse(cid)
local pos = getPlayerPosition(cid)
local fromPos = {x=pos.x-7, y=pos.y-5, z=pos.z}
local toPos = {x=pos.x+7, y=pos.y+5, z=pos.z}
for x, y, z in mapArea(fromPos, toPos) do
if (isCreature(getThingfromPos({x=x,y=y,z=z})) == 1) then
doTeleportThing(getThingfromPos({x=x,y=y,z=z})), npos, 1)
end
end
return 1
end