• 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!

Boss Room

Joined
Mar 14, 2020
Messages
139
Solutions
3
Reaction score
11
Hi guys, i have this code that i found in the internet but is not working 100%

Lua:
local bconfig = {
    boss = 'The Old Widow', -- Nome do Boss
    storagend = 9000, -- Storage Necessária Para Poder Matar o Boss
    bossposition = Position(1442, 1058, 7), -- Onde o Boss Será Criado
    destination = Position(1428, 1059, 7), -- Onde o Teleporta de Entrada Ira Levar
    exitposition = Position(1304, 1051, 7), -- Onde o Teleporte de Saida ou Kick ira levar
    areacenter = Position(1436, 1059, 7), -- O Centro do Lugar onde o Boss Será Criado
    areascan = { -- Largura e Altura minima da Área Onde o Boss Será Criado
        minx = 8,
        maxx = 17,
        miny = 6,
        maxy = 13
    },
    timekill = 10, -- Tempo que o Jogador Terá Para Matar o Boss
    timeopen = 1, -- Tempo Para o Boss ficar acessivel Novamente Desde a Abertura
    aidenter = 65535, -- Action Id do Tile de Entrada
    aidexit  = 65534, -- Action Id do Tile de Saida
    enterpos = DIRECTION_EAST ,-- Direção do Player Quando Entrar na Sala do Boss
    exitpos  = DIRECTION_EAST -- Direção do Player Quando Sair da Sala do Boss
}

function onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    
    if not player then
    player:sendTextMessage(MESSAGE_STATUS_WARNING, 'Nao e um jogador')
        return true
    end

    if item.actionid == bconfig.aidenter then
        local secs = getGlobalStorageValue(50737)

        if player:getStorageValue(bconfig.storagend) == -1 then
            player:sendTextMessage(MESSAGE_STATUS_WARNING, 'Você não pode entrar no boss agora.')
            player:teleportTo(fromPosition, true)
            fromPosition:sendMagicEffect(CONST_ME_TELEPORT)
            return true
        end

        if secs < os.time() then
            local boss = Game.createMonster(bconfig.boss, bconfig.bossposition)

            setGlobalStorageValue(50737, os.time() + (60 * bconfig.timeopen))
            player:teleportTo(bconfig.destination)
            player:setDirection(bconfig.enterpos)
            position:sendMagicEffect(CONST_ME_TELEPORT)
            bconfig.destination:sendMagicEffect(CONST_ME_TELEPORT)
            player:sendTextMessage(MESSAGE_STATUS_WARNING, 'Você tem que esperar ' .. bconfig.timekill .. ' minutos para matar o boss novamente')
            
            addEvent(function()
                local spectators = Game.getSpectators(bconfig.areacenter, false, false, bconfig.areascan.minx, bconfig.areascan.maxx, bconfig.areascan.miny, bconfig.areascan.maxy)

                for i = 1, #spectators, 1 do
                    if spectators[i]:isMonster() then
                        spectators[i]:remove()
                    elseif spectators[i]:isPlayer() then
                        exitPlayer(player)
                        player:sendTextMessage(MESSAGE_STATUS_WARNING, 'Acabou o tempo.')
                    end
                end
            end, (60 * 1000) * bconfig.timekill)
        else
            local remain = secs - os.time()
            local minutes = string.format("%d", math.floor(remain/60))
            local seconds = string.format("%d", remain-(math.floor(remain/60)*60))

            player:teleportTo(fromPosition, true)
            fromPosition:sendMagicEffect(CONST_ME_TELEPORT)
            player:sendTextMessage(MESSAGE_STATUS_WARNING, 'O portal vai estar disponivel novamente em ' .. minutes .. ' minuto(s) e ' .. seconds .. ' segundo(s).')
        end
    elseif item.actionid == bconfig.aidexit then
        exitPlayer(player)
    end
    return true
end

function exitPlayer(player)
    player:setStorageValue(bconfig.storagend, -1)
    player:teleportTo(bconfig.exitposition)
    player:setDirection(bconfig.exitpos)
    bconfig.exitposition:sendMagicEffect(CONST_ME_TELEPORT)
end

The boss is spawning, and the timmer is working ( player got kicked before 10m in the room ), but the clear isn't.
I create an item that give a player "Storage 9000", then he can acess the portal and kill the boss, but he only can kill one time and i want him to kill multiple times based on "1 per day boss". If i give another item that give him storage 9000, he can kill again, but only once (again). In my database on phpmyadmin shows that he have the storage 9000 (players_storage table) but seems he lost de storage when he ends the boss(???)

sorry for bad english.
 
Not quite sure on what you mean but if you're wondering why the player looses storage 9000 after the player has exited it is because of this piece of code on line 78
Code:
    player:setStorageValue(bconfig.storagend, -1)
 
You can play with time and storages like:
Lua:
//24Hrs = 86400
local timehrs = 86400
local STORAGEVALUE = 9000

if player:getStorageValue(STORAGEVALUE) <= os.time() then
 // DO STUFF
else
    player:setStorageValue(STORAGEVALUE, os.time() + timehrs)
end
 
Your script already has a global delay that you do not use. But I presume what you are after is the ability to limit each player to 1 battle per day.

This should not be difficult.
Post automatically merged:

I think this should do it. As long is you weren't already using player storage 9001 for anything.

Lua:
local bconfig = {
    boss = 'The Old Widow', -- Nome do Boss
    storagend = 9000, -- Storage Necessária Para Poder Matar o Boss
    storagday = 9001, -- Storage for limiting each player per day.
    bossposition = Position(1442, 1058, 7), -- Onde o Boss Será Criado
    destination  = Position(1428, 1059, 7), -- Onde o Teleporta de Entrada Ira Levar
    exitposition = Position(1304, 1051, 7), -- Onde o Teleporte de Saida ou Kick ira levar
    areacenter   = Position(1436, 1059, 7), -- O Centro do Lugar onde o Boss Será Criado
    areascan = { -- Largura e Altura minima da Área Onde o Boss Será Criado
        minx = 8,
        maxx = 17,
        miny = 6,
        maxy = 13
    },
    timekill = 10, -- Tempo que o Jogador Terá Para Matar o Boss
    timeopen = 1, -- Tempo Para o Boss ficar acessivel Novamente Desde a Abertura
    aidenter = 65535, -- Action Id do Tile de Entrada
    aidexit  = 65534, -- Action Id do Tile de Saida
    enterpos = DIRECTION_EAST, -- Direção do Player Quando Entrar na Sala do Boss
    exitpos  = DIRECTION_EAST, -- Direção do Player Quando Sair da Sala do Boss
    global   = 50737, -- stores the global delay before boss can spawn again
    throttle = 20 * 60 * 60 -- Setting for personal delay before player can visit again -- 20 hours
}


function onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()

    if not player then
    player:sendTextMessage(MESSAGE_STATUS_WARNING, 'Nao e um jogador')
        return true
    end

    if item.actionid == bconfig.aidenter then
        local secs = getGlobalStorageValue(bconfig.global)
        local psecs = player:getStorageValue(bconfig.storagday)

        if player:getStorageValue(bconfig.storagend) == -1 then
            player:sendTextMessage(MESSAGE_STATUS_WARNING, 'Você não pode entrar no boss agora.')
            player:teleportTo(fromPosition, true)
            fromPosition:sendMagicEffect(CONST_ME_TELEPORT)
            return true
        end

        if psecs > os.time() then
            player:sendTextMessage(MESSAGE_STATUS_WARNING, 'Volte amanhã!')
            player:teleportTo(fromPosition, true)
            fromPosition:sendMagicEffect(CONST_ME_TELEPORT)
            return true
        end

        if secs < os.time() then
            local boss = Game.createMonster(bconfig.boss, bconfig.bossposition)

            setGlobalStorageValue(bconfig.global, os.time() + (60 * bconfig.timeopen))
            player:setStorageValue(bconfig.storagday, os.time() + throttle)
            player:teleportTo(bconfig.destination)
            player:setDirection(bconfig.enterpos)
            position:sendMagicEffect(CONST_ME_TELEPORT)
            bconfig.destination:sendMagicEffect(CONST_ME_TELEPORT)
            player:sendTextMessage(MESSAGE_STATUS_WARNING, 'Você tem que esperar ' .. bconfig.timekill .. ' minutos para matar o boss novamente')

            addEvent(function()
                local spectators = Game.getSpectators(bconfig.areacenter, false, false, bconfig.areascan.minx, bconfig.areascan.maxx, bconfig.areascan.miny, bconfig.areascan.maxy)

                for i = 1, #spectators, 1 do
                    if spectators[i]:isMonster() then
                        spectators[i]:remove()
                    elseif spectators[i]:isPlayer() then
                        exitPlayer(player)
                        player:sendTextMessage(MESSAGE_STATUS_WARNING, 'Acabou o tempo.')
                    end
                end
            end, (60 * 1000) * bconfig.timekill)
        else
            local remain = secs - os.time()
            local minutes = string.format("%d", math.floor(remain/60))
            local seconds = string.format("%d", remain-(math.floor(remain/60)*60))

            player:teleportTo(fromPosition, true)
            fromPosition:sendMagicEffect(CONST_ME_TELEPORT)
            player:sendTextMessage(MESSAGE_STATUS_WARNING, 'O portal vai estar disponivel novamente em ' .. minutes .. ' minuto(s) e ' .. seconds .. ' segundo(s).')
        end
    elseif item.actionid == bconfig.aidexit then
        exitPlayer(player)
    end
    return true
end

function exitPlayer(player)
    player:setStorageValue(bconfig.storagend, -1)
    player:teleportTo(bconfig.exitposition)
    player:setDirection(bconfig.exitpos)
    bconfig.exitposition:sendMagicEffect(CONST_ME_TELEPORT)
end
 
Last edited:
Your script already has a global delay that you do not use. But I presume what you are after is the ability to limit each player to 1 battle per day.

This should not be difficult.
Post automatically merged:

I think this should do it. As long is you weren't already using player storage 9001 for anything.

Lua:
local bconfig = {
    boss = 'The Old Widow', -- Nome do Boss
    storagend = 9000, -- Storage Necessária Para Poder Matar o Boss
    storagday = 9001, -- Storage for limiting each player per day.
    bossposition = Position(1442, 1058, 7), -- Onde o Boss Será Criado
    destination  = Position(1428, 1059, 7), -- Onde o Teleporta de Entrada Ira Levar
    exitposition = Position(1304, 1051, 7), -- Onde o Teleporte de Saida ou Kick ira levar
    areacenter   = Position(1436, 1059, 7), -- O Centro do Lugar onde o Boss Será Criado
    areascan = { -- Largura e Altura minima da Área Onde o Boss Será Criado
        minx = 8,
        maxx = 17,
        miny = 6,
        maxy = 13
    },
    timekill = 10, -- Tempo que o Jogador Terá Para Matar o Boss
    timeopen = 1, -- Tempo Para o Boss ficar acessivel Novamente Desde a Abertura
    aidenter = 65535, -- Action Id do Tile de Entrada
    aidexit  = 65534, -- Action Id do Tile de Saida
    enterpos = DIRECTION_EAST, -- Direção do Player Quando Entrar na Sala do Boss
    exitpos  = DIRECTION_EAST, -- Direção do Player Quando Sair da Sala do Boss
    global   = 50737, -- stores the global delay before boss can spawn again
    throttle = 20 * 60 * 60 -- Setting for personal delay before player can visit again -- 20 hours
}


function onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()

    if not player then
    player:sendTextMessage(MESSAGE_STATUS_WARNING, 'Nao e um jogador')
        return true
    end

    if item.actionid == bconfig.aidenter then
        local secs = getGlobalStorageValue(bconfig.global)
        local psecs = player:getStorageValue(bconfig.storagday)

        if player:getStorageValue(bconfig.storagend) == -1 then
            player:sendTextMessage(MESSAGE_STATUS_WARNING, 'Você não pode entrar no boss agora.')
            player:teleportTo(fromPosition, true)
            fromPosition:sendMagicEffect(CONST_ME_TELEPORT)
            return true
        end

        if psecs > os.time() then
            player:sendTextMessage(MESSAGE_STATUS_WARNING, 'Volte amanhã!')
            player:teleportTo(fromPosition, true)
            fromPosition:sendMagicEffect(CONST_ME_TELEPORT)
            return true
        end

        if secs < os.time() then
            local boss = Game.createMonster(bconfig.boss, bconfig.bossposition)

            setGlobalStorageValue(bconfig.global, os.time() + (60 * bconfig.timeopen))
            player:setStorageValue(bconfig.storagday, os.time() + throttle)
            player:teleportTo(bconfig.destination)
            player:setDirection(bconfig.enterpos)
            position:sendMagicEffect(CONST_ME_TELEPORT)
            bconfig.destination:sendMagicEffect(CONST_ME_TELEPORT)
            player:sendTextMessage(MESSAGE_STATUS_WARNING, 'Você tem que esperar ' .. bconfig.timekill .. ' minutos para matar o boss novamente')

            addEvent(function()
                local spectators = Game.getSpectators(bconfig.areacenter, false, false, bconfig.areascan.minx, bconfig.areascan.maxx, bconfig.areascan.miny, bconfig.areascan.maxy)

                for i = 1, #spectators, 1 do
                    if spectators[i]:isMonster() then
                        spectators[i]:remove()
                    elseif spectators[i]:isPlayer() then
                        exitPlayer(player)
                        player:sendTextMessage(MESSAGE_STATUS_WARNING, 'Acabou o tempo.')
                    end
                end
            end, (60 * 1000) * bconfig.timekill)
        else
            local remain = secs - os.time()
            local minutes = string.format("%d", math.floor(remain/60))
            local seconds = string.format("%d", remain-(math.floor(remain/60)*60))

            player:teleportTo(fromPosition, true)
            fromPosition:sendMagicEffect(CONST_ME_TELEPORT)
            player:sendTextMessage(MESSAGE_STATUS_WARNING, 'O portal vai estar disponivel novamente em ' .. minutes .. ' minuto(s) e ' .. seconds .. ' segundo(s).')
        end
    elseif item.actionid == bconfig.aidexit then
        exitPlayer(player)
    end
    return true
end

function exitPlayer(player)
    player:setStorageValue(bconfig.storagend, -1)
    player:teleportTo(bconfig.exitposition)
    player:setDirection(bconfig.exitpos)
    bconfig.exitposition:sendMagicEffect(CONST_ME_TELEPORT)
end

You can play with time and storages like:
Lua:
//24Hrs = 86400
local timehrs = 86400
local STORAGEVALUE = 9000

if player:getStorageValue(STORAGEVALUE) <= os.time() then
// DO STUFF
else
    player:setStorageValue(STORAGEVALUE, os.time() + timehrs)
end


Timming is working now... But theres a new issue, the boss area doesn't restart ( if the player leaves without killing the boss he stays and when another player get's in, there 2 bosses now )... I guess this is the only thing not working to be 100% in this script. Why do you guys think? It's a areascan issue?
 
It's a boss battle. Should the player ever be able to leave while it's still alive?

I just want some like: If has no player in the arena, then clean him ( monster, corpses etc ), i tried te oberonCleamRoom code:
But ins't working aswell.

Lua:
            local function clearRoom(playerId, areacenter, maxx, maxy, exitposition)
                local spectators, spectator = Game.getSpectators(bconfig.areacenter, false, false, bconfig.maxx, bconfig.maxx, bconfig.maxy, bconfig.maxy)
                    for i = 1, #spectators do
                        spectator = spectators[i]
                            if spectator:isPlayer() and spectator.uid == playerId then
                                spectator:teleportTo(bconfig.exitposition)
                                exitposition:sendMagicEffect(CONST_ME_TELEPORT)
                            end
                        if spectator:isMonster() then
                            spectator:remove()
                        end
                    end
            end

And yes, this is my boss arena with a TP to go out during the boss fight (its wrong?):
bossarena.png

And i have this issue with throttle:
throtle.png
 

Attachments

Last edited:
change
player:setStorageValue(bconfig.storagday, os.time() + throttle)
to
player:setStorageValue(bconfig.storagday, os.time() + bconfig.throttle)

Worked. And about the clearRoom? Do u know how to solve?

Solved: I just put the function clearRoom in the begin of onStep
 
Back
Top