• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

[TFS 1.3] Small Boss Room

Sarah Wesker

ƐƖєgαηт Sуηтαx ❤
Support Team
Joined
Mar 16, 2017
Messages
1,302
Solutions
141
Reaction score
1,654
Location
London
GitHub
MillhioreBT
Twitch
millhiore_bt
data/scripts/bossroom.lua
Lua:
local config = {
    actionId = 5900, -- ActionID to use in the lever
    bossName = "Demon",
    bossPosition = Position(3111, 1846, 7), -- Position where the boss will appear
    bossArea = {
        fromPos = Position(3101, 1845, 7), -- Upper left corner of the room
        toPos = Position(3120, 1855, 7), -- Lower right corner of the room
        entrancePos = Position(3119, 1845, 7), -- Position where players will be teleported when they enter
        exitPosition = Position(3118, 1842, 7) -- If the participants take too long they will be kicked from the room to this position
    },
    allowedAnyParticipantsCount = true, -- allow any valid number of participants to enter. example: 1,2,3 or 4
    participantsPos = {
        Position(3117, 1842, 7), -- Player 1, this player should be the one to pull the lever
        Position(3118, 1842, 7), -- Player 2
        Position(3119, 1842, 7), -- Player 3
        Position(3120, 1842, 7) -- Player 4
    },
    attempts = {
        level = 200, -- Level required to enter
        storage = 20000, -- Storage where we keep the waiting time
        seconds = 72000 -- 20 hours
    },
    createTeleportPos = Position(3112, 1845, 7), -- Position where the teleport is created when the boss dies
    teleportToPosition = Position(3122, 1845, 7), -- Position where the teleport created by the boss will take you when you die
    teleportRemoveSeconds = 10, -- seconds
    kickParticipantAfterSeconds = 60 * 15, -- 15 minutes
    leverIds = {1945, 1946} -- Lever animation, on/off
}

local function getSpectators(onlyPlayers)
    if not config.centerPosition then
        config.diffX = math.ceil((config.bossArea.toPos.x - config.bossArea.fromPos.x) / 2)
        config.diffY = math.ceil((config.bossArea.toPos.y - config.bossArea.fromPos.y) / 2)
        config.centerPosition = config.bossArea.fromPos + Position(config.diffX, config.diffY, 0)
    end
    return Game.getSpectators(config.centerPosition, false, onlyPlayers, config.diffX, config.diffX, config.diffY, config.diffY)
end

local action = Action()

function action.onUse(player, item, fromPos, target, toPos, isHotkey)
    local participants = {}
    for index, pos in pairs(config.participantsPos) do
        local tile = Tile(pos)
        if not tile then error("[Warning - Tile not found]") end
        local participant = tile:getTopVisibleCreature(player)
        if participant and participant:isPlayer() then
            if index == 1 and participant ~= player then
                player:sendCancelMessage("Only the first participant can pull the lever.")
                return true
            end

            if participant:getStorageValue(config.attempts.storage) >= os.time() then
                player:sendCancelMessage(string.format("The player %s must wait a while before being able to enter again.", participant:getName()))
            elseif participant:getLevel() < config.attempts.level then
                player:sendCancelMessage(string.format("The player %s is not level %d.", participant:getName(), config.attempts.level))
            else
                participants[#participants +1] = participant
            end
        end
    end

    if #participants == 0 then
        player:sendCancelMessage("You need at least one participant.")
        return true
    elseif not config.allowedAnyParticipantsCount and #participants ~= #config.participantsPos then
        player:sendCancelMessage("You need all participants.")
        return true
    end

    if #getSpectators(true) > 0 then
        player:sendCancelMessage("At this time the room is occupied, please try again later.")
        return true
    end

    stopEvent(config.kickEventId)

    for _, monsterSpectator in pairs(getSpectators()) do
        monsterSpectator:remove()
    end

    local boss = Game.createMonster(config.bossName, config.bossPosition)
    if not boss then
        player:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
        return true
    end

    boss:registerEvent("bossSystemDeath")

    for index, participant in pairs(participants) do
        participant:getPosition():sendMagicEffect(CONST_ME_POFF)
        participant:teleportTo(config.bossArea.entrancePos, false)
        participant:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
        participant:setStorageValue(config.attempts.storage, os.time() + config.attempts.seconds)
    end

    config.kickEventId = addEvent(function ()
        for _, spectator in pairs(getSpectators()) do
            if spectator:isPlayer() then
                spectator:getPosition():sendMagicEffect(CONST_ME_POFF)
                spectator:teleportTo(config.bossArea.exitPosition, false)
                spectator:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
                spectator:sendTextMessage(MESSAGE_EVENT_ADVANCE, "It's been a long time and you haven't managed to defeat the boss.")
            else
                spectator:remove()
            end
        end
    end, config.kickParticipantAfterSeconds * 1000)
    item:transform(item:getId() == config.leverIds[1] and config.leverIds[2] or config.leverIds[1])
    return true
end

action:aid(config.actionId)
action:register()

local creatureEvent = CreatureEvent("bossSystemDeath")

function creatureEvent.onDeath()
    stopEvent(config.kickEventId)
    local teleport = Game.createItem(1387, 1, config.createTeleportPos)
    if teleport then
        teleport:setDestination(config.teleportToPosition)
        addEvent(function ()
            local tile = Tile(config.createTeleportPos)
            if tile then
                local teleport = tile:getItemById(1387)
                if teleport then
                    teleport:remove()
                    config.teleportToPosition:sendMagicEffect(CONST_ME_POFF)
                end
            end

            for _, spectator in pairs(getSpectators()) do
                if spectator:isPlayer() then
                    spectator:getPosition():sendMagicEffect(CONST_ME_POFF)
                    spectator:teleportTo(config.teleportToPosition, false)
                    spectator:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
                else
                    spectator:remove()
                end
            end
        end, config.teleportRemoveSeconds * 1000)
    end
    return true
end

creatureEvent:register()

example configuring positions:
Screenshot_2.png
 
Last edited:

Evil Puncker

I know nothing
TFS Developer
Joined
May 30, 2009
Messages
8,535
Solutions
260
Reaction score
4,526
nice, finally a decent boss script room for people to have a base to work on, thanks for this
 

Silba

is stephany, the josh wife
Joined
Aug 22, 2013
Messages
442
Solutions
9
Reaction score
359
Right after I finished my Frankenstein boss room scripts haha. Thanks for sharing :)
 

Evil Puncker

I know nothing
TFS Developer
Joined
May 30, 2009
Messages
8,535
Solutions
260
Reaction score
4,526
any idea or just doubling the check?
since this script uses getSpectators function you can just adjust the optional parameters to work on multifloor

Lua:
Game.getSpectators(position[, multifloor = false[, onlyPlayer = false[, minRangeX = 0[, maxRangeX = 0[, minRangeY = 0[, maxRangeY = 0]]]]]])
 

naroxx

New Member
Joined
Sep 10, 2013
Messages
22
Reaction score
2
can you help me with modify this script? When you die you really die i need to put commend to teleport player out in moment when he die without loosing bless exp
 

yosoyjuanx

New Member
Joined
Mar 12, 2012
Messages
8
Reaction score
0
yes it works, but how can I make it possible to enter from 1 player to 5 players, when I configure it only the 5 players can enter, not just one, I need any player from 1 player to 2 or 3 or 4 to 5... Sryy im use traductor :c
 

Lbtg

Intermediate OT User
Joined
Nov 22, 2008
Messages
2,190
Reaction score
106
data/scripts/bossroom.lua
Lua:
local config = {
    actionId = 5900, -- ActionID to use in the lever
    bossName = "Demon",
    bossPosition = Position(3111, 1846, 7), -- Position where the boss will appear
    bossArea = {
        fromPos = Position(3101, 1845, 7), -- Upper left corner of the room
        toPos = Position(3120, 1855, 7), -- Lower right corner of the room
        entrancePos = Position(3119, 1845, 7), -- Position where players will be teleported when they enter
        exitPosition = Position(3118, 1842, 7) -- If the participants take too long they will be kicked from the room to this position
    },
    participantsAllowAnyCount = true, -- allow any valid number of participants to enter. example: 1,2,3 or 4
    participantsPos = {
        Position(3117, 1842, 7), -- Player 1, this player should be the one to pull the lever
        Position(3118, 1842, 7), -- Player 2
        Position(3119, 1842, 7), -- Player 3
        Position(3120, 1842, 7) -- Player 4
    },
    attempts = {
        level = 200, -- Level required to enter
        storage = 20000, -- Storage where we keep the waiting time
        seconds = 72000 -- 20 hours
    },
    createTeleportPos = Position(3112, 1845, 7), -- Position where the teleport is created when the boss dies
    teleportToPosition = Position(3122, 1845, 7), -- Position where the teleport created by the boss will take you when you die
    teleportRemoveSeconds = 10, -- seconds
    kickParticipantAfterSeconds = 60 * 15, -- 15 minutes
    leverIds = {1945, 1946} -- Lever animation, on/off
}

local function getSpectators()
    if not config.centerPosition then
        config.diffX = math.ceil((config.bossArea.toPos.x - config.bossArea.fromPos.x) / 2)
        config.diffY = math.ceil((config.bossArea.toPos.y - config.bossArea.fromPos.y) / 2)
        config.centerPosition = config.bossArea.fromPos + Position(config.diffX, config.diffY, 0)
    end
    return Game.getSpectators(config.centerPosition, false, false, config.diffX, config.diffX, config.diffY, config.diffY)
end

local action = Action()

function action.onUse(player, item, fromPos, target, toPos, isHotkey)
    local participants = {}
    for index, pos in pairs(config.participantsPos) do
        local tile = Tile(pos)
        if not tile then error("[Warning - Tile not found]") end
        local participant = tile:getTopVisibleCreature(player)
        if participant and participant:isPlayer() then
            if index == 1 and participant ~= player then
                player:sendCancelMessage("Only the first participant can pull the lever.")
                return true
            end

            if participant:getStorageValue(config.attempts.storage) >= os.time() then
                player:sendCancelMessage(string.format("The player %s must wait a while before being able to enter again.", participant:getName()))
                return true
            elseif participant:getLevel() < config.attempts.level then
                player:sendCancelMessage(string.format("The player %s is not level %d.", participant:getName(), config.attempts.level))
                return true
            end

            participants[#participants +1] = participant
        elseif not participantsAllowAnyCount then
            player:sendCancelMessage("Participants are missing.")
            return true
        end
    end

    local spectators = getSpectators()
    for _, spectator in pairs(spectators) do
        if spectator:isPlayer() then
            player:sendCancelMessage("At this time the room is occupied, please try again later.")
            return true
        end
    end

    for _, spectator in pairs(spectators) do spectator:remove() end
    local boss = Game.createMonster(config.bossName, config.bossPosition)
    if not boss then error(Game.getReturnMessage(RETURNVALUE_NOTENOUGHROOM)) end
    boss:registerEvent("bossSystemDeath")
    for index, participant in pairs(participants) do
        config.participantsPos[index]:sendMagicEffect(CONST_ME_POFF)
        participant:teleportTo(config.bossArea.entrancePos, false)
        config.bossArea.entrancePos:sendMagicEffect(CONST_ME_TELEPORT)
        participant:setStorageValue(config.attempts.storage, os.time() + config.attempts.seconds)
    end

    config.kickEventId = addEvent(function ()
        for _, spectator in pairs(getSpectators()) do
            if spectator:isPlayer() then
                spectator:getPosition():sendMagicEffect(CONST_ME_POFF)
                spectator:teleportTo(config.bossArea.exitPosition, false)
                config.bossArea.exitPosition:sendMagicEffect(CONST_ME_TELEPORT)
                spectator:sendTextMessage(MESSAGE_EVENT_ADVANCE, "It's been a long time and you haven't managed to defeat the boss.")
            else
                spectator:remove()
            end
        end
    end, config.kickParticipantAfterSeconds * 1000)

    item:transform(item:getId() == config.leverIds[1] and config.leverIds[2] or config.leverIds[1])
    return true
end

action:aid(config.actionId)
action:register()

local creatureEvent = CreatureEvent("bossSystemDeath")

function creatureEvent.onDeath()
    stopEvent(config.kickEventId)
    local teleport = Game.createItem(1387, 1, config.createTeleportPos)
    if teleport then
        teleport:setDestination(config.teleportToPosition)
        addEvent(function ()
            local tile = Tile(config.createTeleportPos)
            if tile then
                local teleport = tile:getItemById(1387)
                if teleport then
                    teleport:remove()
                    config.teleportToPosition:sendMagicEffect(CONST_ME_POFF)
                end
            end

            for _, spectator in pairs(getSpectators()) do
                if spectator:isPlayer() then
                    spectator:getPosition():sendMagicEffect(CONST_ME_POFF)
                    spectator:teleportTo(config.teleportToPosition, false)
                    config.teleportToPosition:sendMagicEffect(CONST_ME_TELEPORT)
                end
            end
        end, config.teleportRemoveSeconds * 1000)
    end
    return true
end

creatureEvent:register()

example configuring positions:
View attachment 62089
Hello , thanks for script and explanations.

Can you please tell me how i can manipulate time on the script for player to repeat the boss, cant find :D unless its this ??
Lua:
    kickParticipantAfterSeconds = 60 * 15, -- 15 minutes

aswell it seems i dont have any effect on this line
Lua:
participantsAllowAnyCount = true, -- allow any valid number of participants to enter. example: 1,2,3 or 4

if i try false or true, both ways i anyway need 4 players it seems.

And i think i got tped on 4 players out of room automatic within 10 sec +- so this works tp out player sec/min ?
Lua:
teleportRemoveSeconds = 10, -- seconds
 

alejandro762

Member
Joined
Sep 6, 2021
Messages
135
Reaction score
24
yes it works, but how can I make it possible to enter from 1 player to 5 players, when I configure it only the 5 players can enter, not just one, I need any player from 1 player to 2 or 3 or 4 to 5... Sryy im use traductor :c
Remove this, because isn't working true or false in AllowPlayersCount,
Then it will teleport, 1, 2, 3 or how many players positions you add.

Lua:
elseif not participantsAllowAnyCount then
            player:sendCancelMessage("Participants are missing.")
            return true
        end
 

Rallelele

New Member
Joined
Jun 11, 2017
Messages
51
Reaction score
4
I am using TFS 1.4. It all worked very well for me, until I added my 5th boss room, for some reason now the teleport that's supposed to be created after the boss died doesnt appear on some of the boss rooms, even tho I havent changed anything in their code since it worked.
This is the only error I get in my console.

eheh.png
Lua:
local config = {
    actionId = 6001, -- ActionID to use in the lever
    bossName = "Captain Barbossa",
    bossPosition = Position(1031, 836, 6), -- Position where the boss will appear
    bossArea = {
        fromPos = Position(1022, 830, 6), -- Upper left corner of the room
        toPos = Position(1031, 836, 6), -- Lower right corner of the room
        entrancePos = Position(1022, 830, 6), -- Position where players will be teleported when they enter
        exitPosition = Position(1000, 1000, 7) -- If the participants take too long they will be kicked from the room to this position
    },
    participantsAllowAnyCount = true, -- allow any valid number of participants to enter. example: 1,2,3 or 4
    participantsPos = {
        Position(1020, 832, 6), -- Player 1, this player should be the one to pull the lever
        Position(1020, 833, 6), -- Player 2
        Position(1020, 834, 6), -- Player 3
        Position(1020, 835, 6) -- Player 4
    },
    attempts = {
        level = 450, -- Level required to enter
        storage = 25002, -- Storage where we keep the waiting time
        seconds = 72000 -- 20 hours
    },
    createTeleportPos = Position(1031, 833, 6), -- Position where the teleport is created when the boss dies
    teleportToPosition = Position(1033, 835, 6), -- Position where the teleport created by the boss will take you when you die
    teleportRemoveSeconds = 30, -- seconds
    kickParticipantAfterSeconds = 60 * 15, -- 15 minutes
    leverIds = {9825, 9826} -- Lever animation, on/off
}

local function getSpectators()
    if not config.centerPosition then
        config.diffX = math.ceil((config.bossArea.toPos.x - config.bossArea.fromPos.x) / 2)
        config.diffY = math.ceil((config.bossArea.toPos.y - config.bossArea.fromPos.y) / 2)
        config.centerPosition = config.bossArea.fromPos + Position(config.diffX, config.diffY, 0)
    end
    return Game.getSpectators(config.centerPosition, false, false, config.diffX, config.diffX, config.diffY, config.diffY)
end

local action = Action()

function action.onUse(player, item, fromPos, target, toPos, isHotkey)
    local participants = {}
    for index, pos in pairs(config.participantsPos) do
        local tile = Tile(pos)
        if not tile then error("[Warning - Tile not found]") end
        local participant = tile:getTopVisibleCreature(player)
        if participant and participant:isPlayer() then
            if index == 1 and participant ~= player then
                player:sendCancelMessage("Only the first participant can pull the lever.")
                return true
            end

            if participant:getStorageValue(config.attempts.storage) >= os.time() then
                player:sendCancelMessage(string.format("The player %s must wait a while before being able to enter again.", participant:getName()))
                return true
            elseif participant:getLevel() < config.attempts.level then
                player:sendCancelMessage(string.format("The player %s is not level %d.", participant:getName(), config.attempts.level))
                return true
            end

            participants[#participants +1] = participant
        -- elseif not participantsAllowAnyCount then
            -- player:sendCancelMessage("Participants are missing.")
            -- return true
        end
    end

    local spectators = getSpectators()
    for _, spectator in pairs(spectators) do
        if spectator:isPlayer() then
            player:sendCancelMessage("At this time the room is occupied, please try again later.")
            return true
        end
    end

    for _, spectator in pairs(spectators) do spectator:remove() end
    local boss = Game.createMonster(config.bossName, config.bossPosition)
    if not boss then error(Game.getReturnMessage(RETURNVALUE_NOTENOUGHROOM)) end
    boss:registerEvent("bossSystemDeath")
    for index, participant in pairs(participants) do
        config.participantsPos[index]:sendMagicEffect(CONST_ME_POFF)
        participant:teleportTo(config.bossArea.entrancePos, false)
        config.bossArea.entrancePos:sendMagicEffect(CONST_ME_TELEPORT)
        participant:setStorageValue(config.attempts.storage, os.time() + config.attempts.seconds)
    end

    config.kickEventId = addEvent(function ()
        for _, spectator in pairs(getSpectators()) do
            if spectator:isPlayer() then
                spectator:getPosition():sendMagicEffect(CONST_ME_POFF)
                spectator:teleportTo(config.bossArea.exitPosition, false)
                config.bossArea.exitPosition:sendMagicEffect(CONST_ME_TELEPORT)
                spectator:sendTextMessage(MESSAGE_EVENT_ADVANCE, "It's been a long time and you haven't managed to defeat the boss.")
            else
                spectator:remove()
            end
        end
    end, config.kickParticipantAfterSeconds * 1000)

    item:transform(item:getId() == config.leverIds[1] and config.leverIds[2] or config.leverIds[1])
    return true
end

action:aid(config.actionId)
action:register()

local creatureEvent = CreatureEvent("bossSystemDeath")

function creatureEvent.onDeath()
    stopEvent(config.kickEventId)
    local teleport = Game.createItem(1387, 1, config.createTeleportPos)
    if teleport then
        teleport:setDestination(config.teleportToPosition)
        addEvent(function ()
            local tile = Tile(config.createTeleportPos)
            if tile then
                local teleport = tile:getItemById(1387)
                if teleport then
                    teleport:remove()
                    config.teleportToPosition:sendMagicEffect(CONST_ME_POFF)
                end
            end

            for _, spectator in pairs(getSpectators()) do
                if spectator:isPlayer() then
                    spectator:getPosition():sendMagicEffect(CONST_ME_POFF)
                    spectator:teleportTo(config.teleportToPosition, false)
                    config.teleportToPosition:sendMagicEffect(CONST_ME_TELEPORT)
                end
            end
        end, config.teleportRemoveSeconds * 1000)
    end
    return true
end

creatureEvent:register()
 
OP
OP
Sarah Wesker

Sarah Wesker

ƐƖєgαηт Sуηтαx ❤
Support Team
Joined
Mar 16, 2017
Messages
1,302
Solutions
141
Reaction score
1,654
Location
London
GitHub
MillhioreBT
Twitch
millhiore_bt
I am using TFS 1.4. It all worked very well for me, until I added my 5th boss room, for some reason now the teleport that's supposed to be created after the boss died doesnt appear on some of the boss rooms, even tho I havent changed anything in their code since it worked.
This is the only error I get in my console.

View attachment 70089
Lua:
local config = {
    actionId = 6001, -- ActionID to use in the lever
    bossName = "Captain Barbossa",
    bossPosition = Position(1031, 836, 6), -- Position where the boss will appear
    bossArea = {
        fromPos = Position(1022, 830, 6), -- Upper left corner of the room
        toPos = Position(1031, 836, 6), -- Lower right corner of the room
        entrancePos = Position(1022, 830, 6), -- Position where players will be teleported when they enter
        exitPosition = Position(1000, 1000, 7) -- If the participants take too long they will be kicked from the room to this position
    },
    participantsAllowAnyCount = true, -- allow any valid number of participants to enter. example: 1,2,3 or 4
    participantsPos = {
        Position(1020, 832, 6), -- Player 1, this player should be the one to pull the lever
        Position(1020, 833, 6), -- Player 2
        Position(1020, 834, 6), -- Player 3
        Position(1020, 835, 6) -- Player 4
    },
    attempts = {
        level = 450, -- Level required to enter
        storage = 25002, -- Storage where we keep the waiting time
        seconds = 72000 -- 20 hours
    },
    createTeleportPos = Position(1031, 833, 6), -- Position where the teleport is created when the boss dies
    teleportToPosition = Position(1033, 835, 6), -- Position where the teleport created by the boss will take you when you die
    teleportRemoveSeconds = 30, -- seconds
    kickParticipantAfterSeconds = 60 * 15, -- 15 minutes
    leverIds = {9825, 9826} -- Lever animation, on/off
}

local function getSpectators()
    if not config.centerPosition then
        config.diffX = math.ceil((config.bossArea.toPos.x - config.bossArea.fromPos.x) / 2)
        config.diffY = math.ceil((config.bossArea.toPos.y - config.bossArea.fromPos.y) / 2)
        config.centerPosition = config.bossArea.fromPos + Position(config.diffX, config.diffY, 0)
    end
    return Game.getSpectators(config.centerPosition, false, false, config.diffX, config.diffX, config.diffY, config.diffY)
end

local action = Action()

function action.onUse(player, item, fromPos, target, toPos, isHotkey)
    local participants = {}
    for index, pos in pairs(config.participantsPos) do
        local tile = Tile(pos)
        if not tile then error("[Warning - Tile not found]") end
        local participant = tile:getTopVisibleCreature(player)
        if participant and participant:isPlayer() then
            if index == 1 and participant ~= player then
                player:sendCancelMessage("Only the first participant can pull the lever.")
                return true
            end

            if participant:getStorageValue(config.attempts.storage) >= os.time() then
                player:sendCancelMessage(string.format("The player %s must wait a while before being able to enter again.", participant:getName()))
                return true
            elseif participant:getLevel() < config.attempts.level then
                player:sendCancelMessage(string.format("The player %s is not level %d.", participant:getName(), config.attempts.level))
                return true
            end

            participants[#participants +1] = participant
        -- elseif not participantsAllowAnyCount then
            -- player:sendCancelMessage("Participants are missing.")
            -- return true
        end
    end

    local spectators = getSpectators()
    for _, spectator in pairs(spectators) do
        if spectator:isPlayer() then
            player:sendCancelMessage("At this time the room is occupied, please try again later.")
            return true
        end
    end

    for _, spectator in pairs(spectators) do spectator:remove() end
    local boss = Game.createMonster(config.bossName, config.bossPosition)
    if not boss then error(Game.getReturnMessage(RETURNVALUE_NOTENOUGHROOM)) end
    boss:registerEvent("bossSystemDeath")
    for index, participant in pairs(participants) do
        config.participantsPos[index]:sendMagicEffect(CONST_ME_POFF)
        participant:teleportTo(config.bossArea.entrancePos, false)
        config.bossArea.entrancePos:sendMagicEffect(CONST_ME_TELEPORT)
        participant:setStorageValue(config.attempts.storage, os.time() + config.attempts.seconds)
    end

    config.kickEventId = addEvent(function ()
        for _, spectator in pairs(getSpectators()) do
            if spectator:isPlayer() then
                spectator:getPosition():sendMagicEffect(CONST_ME_POFF)
                spectator:teleportTo(config.bossArea.exitPosition, false)
                config.bossArea.exitPosition:sendMagicEffect(CONST_ME_TELEPORT)
                spectator:sendTextMessage(MESSAGE_EVENT_ADVANCE, "It's been a long time and you haven't managed to defeat the boss.")
            else
                spectator:remove()
            end
        end
    end, config.kickParticipantAfterSeconds * 1000)

    item:transform(item:getId() == config.leverIds[1] and config.leverIds[2] or config.leverIds[1])
    return true
end

action:aid(config.actionId)
action:register()

local creatureEvent = CreatureEvent("bossSystemDeath")

function creatureEvent.onDeath()
    stopEvent(config.kickEventId)
    local teleport = Game.createItem(1387, 1, config.createTeleportPos)
    if teleport then
        teleport:setDestination(config.teleportToPosition)
        addEvent(function ()
            local tile = Tile(config.createTeleportPos)
            if tile then
                local teleport = tile:getItemById(1387)
                if teleport then
                    teleport:remove()
                    config.teleportToPosition:sendMagicEffect(CONST_ME_POFF)
                end
            end

            for _, spectator in pairs(getSpectators()) do
                if spectator:isPlayer() then
                    spectator:getPosition():sendMagicEffect(CONST_ME_POFF)
                    spectator:teleportTo(config.teleportToPosition, false)
                    config.teleportToPosition:sendMagicEffect(CONST_ME_TELEPORT)
                end
            end
        end, config.teleportRemoveSeconds * 1000)
    end
    return true
end

creatureEvent:register()
This error is not related to my script.
If you want to fix this you should check this PR check all the references at the end, they were fixing each problem found.

Btw for everyone. 🌺
There were some extra details that were missing in the script and it's already fixed.
 

Mr Noxi

Noxus Otserver
Premium User
Joined
May 13, 2010
Messages
273
Solutions
3
Reaction score
93
Location
Sweden
Am having an issue with this part of the code, for some reason when players has made the boss once and gets the storage so they need to wait the time before trying again. But am not getting that "The player %s must wait a while before being able to enter again." Its jumping straight down to "You need atleast 4 participants"

I used the same 4 characters that made the first boss. Anyone has any idea?


Lua:
            if participant:getStorageValue(config.attempts.storage) >= os.time() then
                player:sendCancelMessage(string.format("The player %s must wait a while before being able to enter again.", participant:getName()))
            elseif participant:getLevel() < config.attempts.level then
                player:sendCancelMessage(string.format("The player %s is not level %d.", participant:getName(), config.attempts.level))
            else
                participants[#participants +1] = participant
            end
        end
    end

    if #participants == 0 then
        player:sendCancelMessage("You need atleast 4 participant.")
        return true
    elseif not allowedAnyParticipantsCount and #participants ~= #config.participantsPos then
        player:sendCancelMessage("You need all participants.")
        return true
    end
 

Xikini

I whore myself out for likes
Senator
Joined
Nov 17, 2010
Messages
6,360
Solutions
550
Reaction score
4,636
Am having an issue with this part of the code, for some reason when players has made the boss once and gets the storage so they need to wait the time before trying again. But am not getting that "The player %s must wait a while before being able to enter again." Its jumping straight down to "You need atleast 4 participants"

I used the same 4 characters that made the first boss. Anyone has any idea?


Lua:
            if participant:getStorageValue(config.attempts.storage) >= os.time() then
                player:sendCancelMessage(string.format("The player %s must wait a while before being able to enter again.", participant:getName()))
            elseif participant:getLevel() < config.attempts.level then
                player:sendCancelMessage(string.format("The player %s is not level %d.", participant:getName(), config.attempts.level))
            else
                participants[#participants +1] = participant
            end
        end
    end

    if #participants == 0 then
        player:sendCancelMessage("You need atleast 4 participant.")
        return true
    elseif not allowedAnyParticipantsCount and #participants ~= #config.participantsPos then
        player:sendCancelMessage("You need all participants.")
        return true
    end
add return true under those cancel messages.

Lua:
            if participant:getStorageValue(config.attempts.storage) >= os.time() then
                player:sendCancelMessage(string.format("The player %s must wait a while before being able to enter again.", participant:getName()))
                return true
            elseif participant:getLevel() < config.attempts.level then
                player:sendCancelMessage(string.format("The player %s is not level %d.", participant:getName(), config.attempts.level))
                return true
            else
                participants[#participants +1] = participant
            end
        end
    end

    if #participants == 0 then
        player:sendCancelMessage("You need atleast 4 participant.")
        return true
    elseif not allowedAnyParticipantsCount and #participants ~= #config.participantsPos then
        player:sendCancelMessage("You need all participants.")
        return true
    end
 
Top