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

Mini Boss Room - Teleport

willks123

New Member
Joined
Dec 31, 2012
Messages
24
Reaction score
1
I am creating an OT 12.51 TFS 1.3.

I need help, I didn't find it here on the forum, I don't know how to look it up. I am making a TP to go to the Lions Mini Boss room under the Werehyenas. It needs to be a Teleport that when the person enters the Boss appears, And when he leaves or dies, the Boss disappears. Only one person can enter at a time, and he can only stay there within 15 minutes, if he doesn't kill the boss he is teleported out and the boss disappears.

Can you help me?
 

roriscrave

Advanced OT User
Joined
Dec 7, 2011
Messages
1,097
Solutions
34
Reaction score
182
I am creating an OT 12.51 TFS 1.3.

I need help, I didn't find it here on the forum, I don't know how to look it up. I am making a TP to go to the Lions Mini Boss room under the Werehyenas. It needs to be a Teleport that when the person enters the Boss appears, And when he leaves or dies, the Boss disappears. Only one person can enter at a time, and he can only stay there within 15 minutes, if he doesn't kill the boss he is teleported out and the boss disappears.

Can you help me?
Lua:
local bconfig = {
    boss = 'The Old Widow', -- BOSS Name
    storagend = 9000, -- Storage Needed for kill the boss
    storagday = 9001, -- Storage for limiting each player per day.
    bossposition = Position(1442, 1058, 7), -- Where boss will respaw?
    destination  = Position(1428, 1059, 7), -- Where player will teleport at enter
    exitposition = Position(1304, 1051, 7), -- Where player will teleport at kicked/exit
    areacenter   = Position(1436, 1059, 7), -- Center where boss will created
    areascan = { -- width and height boss area
        minx = 20,
        maxx = 20,
        miny = 20,
        maxy = 20
    },
    timekill = 10, -- Time to kill a boss or will get kicked
    timeopen = 1, -- Time to another player can enter
    aidenter = 65535, -- Action ID enter tile
    aidexit  = 65534, -- Action ID exit tile
    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, 'Not a player')
        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, 'You cant enter now.')
            player:teleportTo(fromPosition, true)
            fromPosition:sendMagicEffect(CONST_ME_TELEPORT)
            return true
        end

        if psecs > os.time() then
            player:sendTextMessage(MESSAGE_STATUS_WARNING, 'Back tomorrow!')
            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() + bconfig.throttle)
            player:teleportTo(bconfig.destination)
            position:sendMagicEffect(CONST_ME_TELEPORT)
            bconfig.destination:sendMagicEffect(CONST_ME_TELEPORT)
            player:sendTextMessage(MESSAGE_STATUS_WARNING, 'Wait ' .. bconfig.timekill .. ' minutes to kill again.')

            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, 'Time finished.')
                    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, 'The portal will open in' .. minutes .. ' minute(s) and ' .. seconds .. ' second(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)
    bconfig.exitposition:sendMagicEffect(CONST_ME_TELEPORT)
end
 
Top