Olá meu lindo amigo tudo bem?
Vamos resolver
Use esse código:
local config = {
bossName = "Maxxenius",
bossName2 = "Glooth-Generator",
bossName3 = "Glooth-Generator",
bossName4 = "Glooth-Generator",
summonName = "Rift Invader",
bossPos = Position{x = 31983, y = 31982, z = 15},
horror = Position{x = 31982, y = 31984, z = 15},
phobia = Position{x = 31989, y = 31984, z = 15},
fear = Position{x = 31984, y = 31987, z = 15},
centerRoom = Position{x = 31984, y = 31985, z = 15}, -- Center Room
exitPosition = Position{x = 32001, y = 31984, z = 15}, -- Exit Position
newPos = Position{x = 31984, y = 31990, z = 15}, -- Player Position on room
playerPositions = {
Position{x = 32003, y = 31980, z = 15},
Position{x = 32003, y = 31981, z = 15},
Position{x = 32003, y = 31982, z = 15},
Position{x = 32003, y = 31983, z = 15},
Position{x = 32003, y = 31984, z = 15}
},
range = 30,
time = 30, -- time in minutes to remove the player
}
local function clearFerumbrasRoom()
local spectators = Game.getSpectators(config.bossPos, false, false, 10, 10, 10, 10)
for i = 2, #spectators do
local spectator = spectators[i]
if spectator:isPlayer() then
spectator:teleportTo(config.exitPosition)
spectator:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
spectator:say('Time out! You were teleported out by strange forces.', TALKTYPE_MONSTER_SAY)
elseif spectator:isMonster() then
spectator:remove()
end
end
end
local ferumbrasAscendantLever = Action()
function ferumbrasAscendantLever.onUse(player, item, fromPosition, target, toPosition, isHotkey)
if item.itemid == 9825 then
if player:getPosition() ~= Position{x = 32003, y = 31980, z = 15} then
return true
end
for x = 32003, 32003 do
for y = 31980, 31984 do
local playerTile = Tile(Position(x, y, 15)):getTopCreature()
if playerTile and playerTile:isPlayer() then
if playerTile:getStorageValue(421516177) > os.time() then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You or a member in your team have to wait 20 hours to face Boss again!")
item:transform(9826)
return true
end
end
end
end
local specs, spec = Game.getSpectators(config.centerRoom, false, false, 15, 15, 15, 15)
for i = 1, #specs do
spec = specs[i]
if spec:isPlayer() then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "There's someone fighting with Boss.")
return true
end
end
local spectators = Game.getSpectators(config.bossPos, false, false, 15, 15, 15, 15)
for i = 1, #spectators do
local spectator = spectators[i]
if spectator:isMonster() then
spectator:remove()
end
end
for x = 32003, 32003 do
for y = 31980, 31984 do
local playerTile = Tile(Position(x, y, 15)):getTopCreature()
if playerTile and playerTile:isPlayer() then
playerTile:getPosition():sendMagicEffect(CONST_ME_POFF)
playerTile:teleportTo(config.newPos)
playerTile:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
playerTile:setStorageValue(421516177, os.time() + 20 * 60 * 60) -- 14 days
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have 30 minutes to kill and loot this boss. Otherwise you will lose that chance and will be kicked out.")
addEvent(clearFerumbrasRoom, 60 * config.time * 1000, player:getId(), config.centerRoom, config.range, config.range, config.exitPosition)
item:transform(9826)
end
end
end
Game.createMonster(config.bossName, config.bossPos, true, true)
Game.createMonster(config.bossName2, config.horror, true, true)
Game.createMonster(config.bossName3, config.phobia, true, true)
Game.createMonster(config.bossName4, config.fear, true, true)
elseif item.itemid == 9826 then
item:transform(9825)
return true
end
end
ferumbrasAscendantLever:aid(30014)
ferumbrasAscendantLever:register()
Motivo do erro:
Quando você usa um for neste caso deste script ele vai executar tudo que está dentro do for repetindo a quantidade de players,
se for 1 player será 1 repetição, 2 players 2 repetições, 3 players 3 repetições e assim por diante.
agora removi de dentro do for e os monstros nascerão apenas 1 de cada como está no arquivo.