I have this script and it only teleports the person that is in PlayerPosition. I would like it to teleport more players than configured in PlayerPosition2, PlayerPosition3 and so on.
Lua:
local Config = {
bossName = 'Rat', -- boss name
PlayerPosition = Position(32715, 31644, 7), -- Where the player should be.
newPosition = Position(32715, 31625, 7), -- Position to teleport
bossPosition = Position(32715, 31616, 7), -- Boss Position
centerPosition = Position(32715, 31616, 7), -- Center Room
exitPosition = Position(32715, 31640, 7), -- Exit Position
rangeX = 13,
rangeY = 13,
time = 1, -- time in minutes to remove the player
}
local function roomIsOccupied(centerPosition, rangeX, rangeY)
local spectators = Game.getSpectators(centerPosition, false, false, rangeX, rangeX, rangeY, rangeY)
if #spectators ~= 0 then
return true
end
return false
end
function clearBossRoom(playerId, centerPosition, rangeX, rangeY, exitPosition)
local spectators, spectator = Game.getSpectators(centerPosition, false, false, rangeX, rangeX, rangeY, rangeY)
for i = 1, #spectators do
spectator = spectators[i]
if spectator:isPlayer() and spectator.uid == playerId then
spectator:teleportTo(exitPosition)
exitPosition:sendMagicEffect(CONST_ME_TELEPORT)
end
if spectator:isMonster() then
spectator:remove()
end
end
end
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if item.itemid == 9825 or 9826 then
local creature = Tile(Config.PlayerPosition):getTopCreature()
if not creature or not creature:isPlayer() then
return true
end
if roomIsOccupied(Config.centerPosition, Config.rangeX, Config.rangeY) then
player:sendCancelMessage("There is someone in the room.")
return true
end
local monster = Game.createMonster(Config.bossName, Config.bossPosition)
if not monster then
return true
end
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have entered an ancient demon prison cell!')
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have fifteen minutes to kill and loot this boss, else you will lose that chance.')
addEvent(clearBossRoom, 60 * Config.time * 1000, player:getId(), Config.centerPosition, Config.rangeX, Config.rangeY, Config.exitPosition)
player:teleportTo(Config.newPosition)
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
end
item:transform(item.itemid == 9825 and 9826 or 9825)
return true
end
Last edited: