Se não funcionar para você, tenho esse que fica na área.
Essa será a área
From = {x = 1069, y = 1027, z = 6}, -- Area Left
To = {x = 1071, y = 1030, z = 7}, -- Area Corner
local c = {
limit = 5, -- Limit players
msgCancel = "Nao pode entrar mais.",
area = {
From = {x = 1069, y = 1027, z = 6}, -- Area Left
To = {x = 1071, y = 1030, z = 7}, -- Area Corner
},
pos = {x = 1070, y = 1030, z = 7}, -- TPS Players
}
local function getPlayersInArea(fromPos, toPos)
local t = {}
for _, cid in ipairs(getPlayersOnline()) do
if isInRange(getThingPos(cid), fromPos, toPos) then
table.insert(t, cid)
end
end
return t
end
function onStepIn(cid, item, fromPos, toPos)
if isPlayer(cid) then
if table.getn(getPlayersInArea(c.area.From, c.area.To)) < c.limit then
doSendMagicEffect(fromPos, CONST_ME_TELEPORT)
doTeleportThing(cid, c.pos)
doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
else
doPlayerSendCancel(cid, c.msgCancel)
doTeleportThing(cid, toPos, false)
end
end
return true
end