Obrigado por responder e desculpa a demora, peguei o seu script e modifiquei para ele fazer teleport radom, VLW pela ajuda REP+ , falta so arrumar as pessoas ele sempre teleporta todas indepentes se tem 1 so na sala.
__________________________________
local Config =
{
PosTPSpawn = {x=32991, y=32416, z=7}, -- pos que o tp vai manda
PosPlayerTP = {x=32962, y=32077, z=7}, -- pos que o tp irá aparecer
Tempo = 30, -- Tempo em segundos que o TP ficará no local até desaparecer e o tempo que irá teleportar os players da sala
templo = {x=32957, y=32076, z=7},
AreaDe = {x=32989, y=32415, z=7},
AreaAte = {x=32993, y=32419, z=7},
from = {x = 32989, y = 32405, z = 8}, -- Posicao da topo esquerdo
to = {x = 33003, y = 32419, z = 8}, -- posicao da base direita
}
function onThink(interval, lastExecution, thinkInterval)
doCreateTeleport(1387, Config.PosTPSpawn, Config.PosPlayerTP)
doBroadcastMessage("O portal para o evento foi aberto e se fexará em 30 segundos.")
addEvent(function() deleteTp() end, ((Config.Tempo * 1000)*1))
addEvent(function() mover() end, ((Config.Tempo * 1000)*1))
addEvent(function() doBroadcastMessage("O portal do evento foi fexado. Próximo evento em 1 horas.", 25) end, ((Config.Tempo * 1000)*1))
return true
end
function deleteTp()
local delete = getTileItemById(Config.PosPlayerTP, 1387)
doRemoveItem(delete.uid, 1)
doSendMagicEffect(positioni, CONST_ME_TELEPORT)
end
function mover()
local PlayersArea = RetornarPlayersArea(Config.AreaDe, Config.AreaAte)
local TpTemplo = false
if #PlayersArea > 3 then
TpTemplo = true
end
for i = 1, #PlayersArea do
if TpTemplo == true then
local p = {x = math.random(Config.from.x, Config.to.x), y = math.random(Config.from.y, Config.to.y), z = math.random(Config.from.z, Config.to.z)}
doTeleportThing(PlayersArea, p)
doSendMagicEffect(p, CONST_ME_TELEPORT)
doPlayerSendTextMessage(PlayersArea, MESSAGE_STATUS_WARNING, "Comecssssou!")
else
doTeleportThing(PlayersArea, config.templo)
doPlayerSendTextMessage(PlayersArea, MESSAGE_STATUS_WARNING, "sem Pessoas suficentes, menos que 3.")
end
end
return true
end
function RetornarPlayersArea(PosIn, PosFn)
playersInArea = {}
for _, pid in ipairs(getPlayersOnline()) do
local Pos = getCreaturePosition(pid)
if PosIn.x <= Pos.x and PosIn.y <= Pos.y and PosIn.z == Pos.z then
if PosFn.x >= Pos.x and PosFn.y >= Pos.y and PosFn.z == Pos.z then
table.insert(playersInArea, pid)
end
end
end
return playersInArea
end