amoeba13
New Member
- Joined
- Jan 7, 2011
- Messages
- 10
- Reaction score
- 2
Hello guys, today I made a very useful function and decided to post it here. It's name is getPlayersInArea, what it does? It gets the players in an area...
@@EDIT - Sorry guys, when I first posted it, there was an error. Now its fixed.
How to use it? Here is an example:
Hope u enjoy it.
@@EDIT - Sorry guys, when I first posted it, there was an error. Now its fixed.
Code:
function getPlayersInArea(fromPos, toPos) -- function by amoeba13
playersInArea = {}
for x = fromPos.x, toPos.x do
for y = fromPos.y, toPos.y do
for z = fromPos.z, toPos.z do
totalArea = {x=x, y=y, z=z}
playerz = getTopCreature(totalArea)
ifisPlayer(playerz.uid) then
table.insert(playersInArea, playerz.uid)
end
end
end
end
return playersInArea
end
How to use it? Here is an example:
Code:
function onSay(cid, words, param, channel)
local area = getPlayersInArea({x = 153, y = 50, z = 7}, {x = 156, y = 53, z = 7})if area then
for i = 1, (#area) do
doTeleportThing(area[i], {x = 160, y = 51, z = 7}, false)end
end
returntrue
end
Hope u enjoy it.
Last edited: