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

Training Room

endziu2222

Active Member
Joined
Nov 2, 2010
Messages
168
Solutions
1
Reaction score
44
Create small training rooms for player to teleport to and add positions to the script. Done

Example screen:
1712080413235.png
Script:
Lua:
local trainingTeleport = MoveEvent()

local roomPositions = {
    Position(2142, 2300, 8), Position(2148, 2300, 8), Position(2154, 2300, 8), Position(2160, 2300, 8), Position(2166, 2300, 8), Position(2172, 2300, 8),
}

local function isRoomOccupied(pos)
    local tile = Tile(pos)
    if tile then
        local creatures = tile:getCreatures()
        if creatures then
            for i = 1, #creatures do
                if creatures[i]:isPlayer() then
                    return true
                end
            end
        end
    end
    return false
end

function trainingTeleport.onStepIn(player, item, position, fromPosition)
    if not player or not player:isPlayer() then
        return true
    end

    for _, roomPos in ipairs(roomPositions) do
        if not isRoomOccupied(roomPos) then
            player:teleportTo(roomPos)
            player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
            return true
        end
    end

    player:sendTextMessage(MESSAGE_STATUS_SMALL, "All training rooms are occupied. Please try again later.")
    player:teleportTo(fromPosition, true)
    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    return true
end

trainingTeleport:type("stepin")
trainingTeleport:aid(38553)
trainingTeleport:register()
 
Back
Top