• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.
Resource icon

Simple boss lever + cooldown + checks 1.0

No permission to download

Joriku

Working in the mines, need something?
Joined
Jul 16, 2016
Messages
1,175
Solutions
17
Reaction score
481
Location
Sweden
Joriku submitted a new resource:

Simple boss lever + cooldown + checks - Simple bosslever

This script allows you to create a simple boss room, where the cooldown is checked, player is kicked and monster is removed from the room once time is up.

This script also makes sure that the player has to stand on the player tiles, checks if a player on the tiles has a cooldown or not.

Github
View attachment 85052[ATTACH type="full" align="right"...

Read more about this resource...
 
Hello, my friend... I'm using your script on TFS 1.5 downgrade Nekiro 8.0.


It works well, but the check monster function creates a loop and ends up crashing the server... I need some help to make this remove monster function more optimized so it doesn't cause server crashes.


Besides that, I made a few small modifications... In the same script, I managed to set up multiple bosses with different levers and different positions on the map. Everything is working perfectly, except for the part where I recently changed the remove monster function. Now it doesn't crash the server, but it also doesn't remove the monsters... When someone enters and dies, the next team entering the boss fight will face two bosses instead of one...



local action = Action()

-- Configurações dos quatro bosses, com suas respectivas posições e propriedades
local config = {
boss1 = {
name = "King Zelus",
position = Position(198, 26, 15),
teleportTimer = 600, -- Tempo de teleporte em segundos (15 minutos)
cooldownTimer = 20 * 60 * 60, -- 2 horas em segundos
storage = 10010, -- Armazenamento único para controle do cooldown
playerPositions = { -- Posições específicas para cada boss
{ pos = Position(154, 27, 15), teleport = Position(192, 21, 15) },
{ pos = Position(154, 28, 15), teleport = Position(192, 21, 15) },
{ pos = Position(154, 29, 15), teleport = Position(192, 21, 15) },
{ pos = Position(154, 30, 15), teleport = Position(192, 21, 15) }
},
specPos = {
from = Position(192, 21, 15),
to = Position(205, 31, 15)
}
},
boss2 = {
name = "Black Behemoth",
position = Position(237, 29, 15),
teleportTimer = 600,
cooldownTimer = 0 * 60 * 60,
storage = 10011,
playerPositions = {
{ pos = Position(158, 27, 15), teleport = Position(229, 20, 15) },
{ pos = Position(158, 28, 15), teleport = Position(230, 20, 15) },
{ pos = Position(158, 29, 15), teleport = Position(231, 20, 15) },
{ pos = Position(158, 30, 15), teleport = Position(232, 20, 15) }
},
specPos = {
from = Position(227, 20, 15),
to = Position(242, 32, 15)
}
},
boss3 = {
name = "Morshabaal",
position = Position(199, 54, 15),
teleportTimer = 600,
cooldownTimer = 20 * 60 * 60,
storage = 10012,
playerPositions = {
{ pos = Position(162, 27, 15), teleport = Position(192, 50, 15) },
{ pos = Position(162, 28, 15), teleport = Position(193, 50, 15) },
{ pos = Position(162, 29, 15), teleport = Position(194, 50, 15) },
{ pos = Position(162, 30, 15), teleport = Position(195, 50, 15) }
},
specPos = {
from = Position(192, 50, 15),
to = Position(205, 60, 15)
}
},
boss4 = { -- Novo boss adicionado
name = "Latrel",
position = Position(239, 58, 15),
teleportTimer = 600, -- Tempo de teleporte em segundos (10 minutos)
cooldownTimer = 20 * 60 * 60,
storage = 10013,
playerPositions = {
{ pos = Position(166, 27, 15), teleport = Position(230, 50, 15) },
{ pos = Position(166, 28, 15), teleport = Position(231, 50, 15) },
{ pos = Position(166, 29, 15), teleport = Position(232, 50, 15) },
{ pos = Position(166, 30, 15), teleport = Position(233, 50, 15) }
},
specPos = {
from = Position(230, 50, 15),
to = Position(243, 60, 15)
}
}
}

local function removeMonsterFromArea(fromPos, toPos)
local exitPosition = Position(160, 30, 15)

for _x = fromPos.x, toPos.x do
for _y = fromPos.y, toPos.y do
local pos = Position(_x, _y, fromPos.z) -- Reutilizando a posição

local tile = Tile(pos)
if tile then
for _, creature in ipairs(tile:getCreatures()) do
if creature:isMonster() then
creature:remove()
elseif creature:isPlayer() then
creature:teleportTo(exitPosition)
end
end
end
end
end
end

function isPositionEqual(pos1, pos2)
return pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z
end

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
local bossConfig = nil

-- Verificar qual boss foi acionado pelo actionID
if item.actionid == 2600 then
bossConfig = config.boss1
elseif item.actionid == 2601 then
bossConfig = config.boss2
elseif item.actionid == 2602 then
bossConfig = config.boss3
elseif item.actionid == 2603 then -- Ação para o novo boss
bossConfig = config.boss4
else
return false
end

if player:getStorageValue(bossConfig.storage) > os.time() then
local remainingCooldown = player:getStorageValue(bossConfig.storage) - os.time()
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Você ainda tem um tempo de espera. Tempo restante: " .. os.date("!%X", remainingCooldown))
return true
end

local playerOnTile = false
for _, positionData in ipairs(bossConfig.playerPositions) do
if isPositionEqual(player:getPosition(), positionData.pos) then
playerOnTile = true
break
end
end

if not playerOnTile then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Você precisa estar em um dos pontos de entrada para usar a alavanca.")
return false
end

local cooldownPlayerOnTile = false
-- Verifica se algum jogador já está com cooldown ativo
for _, positionData in ipairs(bossConfig.playerPositions) do
local tile = Tile(positionData.pos)
for _, creature in ipairs(tile:getCreatures()) do
if creature:isPlayer() and creature:getStorageValue(bossConfig.storage) > os.time() then
cooldownPlayerOnTile = true
break
end
end
end

if cooldownPlayerOnTile then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Algum jogador nos pontos de entrada ainda está com tempo de espera ativo. Tente novamente mais tarde.")
return true
end

if item.itemid == 1946 then
player:say("Cling..", TALKTYPE_MONSTER_SAY)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Desculpe, esta sala está em uso. Volte mais tarde.")
return true
end

if item.itemid == 1945 then
item:transform(1946)
Game.createMonster(bossConfig.name, bossConfig.position, 1)

-- Teleportar jogadores que estiverem nos pontos de entrada
for _, positionData in ipairs(bossConfig.playerPositions) do
local posTile = Tile(positionData.pos)
local newTeleportPos = positionData.teleport

local creatures = posTile:getCreatures()
if creatures then
for _, creature in ipairs(creatures) do
if creature:isPlayer() then
local playerName = creature:getName()

print("Teleportando jogador para a sala do boss:", playerName)
creature:teleportTo(newTeleportPos, true)
newTeleportPos:sendMagicEffect(CONST_ME_TELEPORT)

creature:setStorageValue(bossConfig.storage, os.time() + bossConfig.cooldownTimer)

creature:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Você tem " .. bossConfig.teleportTimer .. " segundos para derrotar o boss antes de ser teleportado para fora.")
end
end
end
end

addEvent(function()
item:transform(1945)
-- Usar a área de remoção específica para o boss
removeMonsterFromArea(bossConfig.specPos.from, bossConfig.specPos.to)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "O tempo acabou, boa sorte na próxima!")
end, bossConfig.teleportTimer * 1000)
end
return true
end

action:aid(2600)
action:aid(2601)
action:aid(2602)
action:aid(2603) -- Adicionando a nova actionID para o novo boss
action:register()
 
Back
Top