• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Anti Block Temple Tile.

endziu2222

Well-Known Member
Joined
Nov 2, 2010
Messages
184
Solutions
1
Reaction score
50
It works very easy you can use it as aid, uid or id. Once on the tile you will be teleported to chosen location after delay.
Can be also used in quests I assume.

Tested on OTX and Canary.



client-127.0.0.1_Jfo0FYkY4J.gif

Lua:
local teleportLocations = {
    Position(2495, 2853, 7),
    Position(2497, 2853, 7)
    -- add more positions
}

local teleportDelay = 5

local function delayedTeleport(playerId, originalPosition, locations)
    local player = Player(playerId)
    if not player or not player:isPlayer() then
        return
    end

    if player:getPosition() == originalPosition then
        local randomIndex = math.random(1, #locations)
        player:teleportTo(locations[randomIndex])
        locations[randomIndex]:sendMagicEffect(CONST_ME_TELEPORT)
    end
end

local teleportTeleport = MoveEvent()

function teleportTeleport.onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player then
        return true
    end

    addEvent(delayedTeleport, teleportDelay * 1000, player:getId(), position, teleportLocations)

    return true
end

teleportTeleport:type("stepin")
teleportTeleport:aid(24334)
teleportTeleport:register()

I also add this one:
2 players have to be together on 2 tiles for teleport to occur.

Lua:
local teleportLocations = {
    Position(2496, 2853, 7), 
}

local tilePositions = {
    Position(2493, 2853, 7), 
    Position(2499, 2853, 7) 
}

local playersOnTiles = {}
local teleportDelay = 10 

local function delayedTeleport(playerId, tileId)
    local player = Player(playerId)
    if not player or not player:isPlayer() then
        return
    end

    for _, pos in pairs(tilePositions) do
        if not playersOnTiles[pos] or playersOnTiles[pos] == 0 then
            return 
        end
    end

    local randomIndex = math.random(1, #teleportLocations)
    for _, pos in pairs(tilePositions) do
        local tile = Tile(pos)
        if tile then
            local creatures = tile:getCreatures()
            for _, creature in ipairs(creatures) do
                if creature:isPlayer() then
                    creature:teleportTo(teleportLocations[randomIndex])
                    teleportLocations[randomIndex]:sendMagicEffect(CONST_ME_TELEPORT)
                end
            end
        end
        playersOnTiles[pos] = 0 
    end
end

local teleportTeleport = MoveEvent()

function teleportTeleport.onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player then
        return true
    end

    for _, tilePos in pairs(tilePositions) do
        if position == tilePos then
            playersOnTiles[tilePos] = (playersOnTiles[tilePos] or 0) + 1
            addEvent(delayedTeleport, teleportDelay * 1000, player:getId(), tilePos)
            break
        end
    end

    return true
end

teleportTeleport:type("stepin")
teleportTeleport:aid(24335)
teleportTeleport:register()
client-127.0.0.1_G2W8EtbPrP.gif
 
Last edited:
Back
Top