global.lua
Code:
function mapArea(fromPos, toPos, stack)
-- Area iterator by Colandus @ ******.net
local pos = {x=fromPos.x, y=fromPos.y-1, z=fromPos.z}
return function()
if (pos.y < toPos.y) then
pos.y = pos.y+1
elseif (pos.x <= toPos.x) then
pos.y = fromPos.y
pos.x = pos.x+1
else
pos.x = fromPos.x
pos.y = fromPos.y
pos.z = pos.z+1
end
if (pos.x <= toPos.x and pos.y <= toPos.y or pos.z < toPos.z) then
if (stack == nil) then
return pos
else
pos.stackpos = stack
return pos, getThingfromPos(pos)
end
end
end
end
If you want to make it teleport all players in the area, then you should need onAdvance, else, just an example of onUse:
Code:
function onUse(cid, item, position)
fromPos = {x = 10, y = 15, z = 5}
toPos = {x = 20, y = 30, z = 7}
newPos = {x = 50, y = 30, z = 10}
for pos, uid in mapArea(fromPos, toPos, 253) do
if isPlayer(thing) == TRUE then
doTeleportThing(thing, newPos, 0)
end
end
end