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

Teleport player every 2 minutes

Azerty

Active Member
Joined
Apr 15, 2022
Messages
335
Solutions
4
Reaction score
37
I'm doing the soulwar quest on my server, could someone make me the script in which the player is teleported every 2 minutes in the boats? in all there are 8 boats
In this case, the player teleports to the same position for the upper or lower floor
boat 1.jpg
boat 2.jpg
 
Maybe explain more for people who don't know soulwar quest.
So there are 8 boats where you want if a player is on any of them then he gets kicked/teleported out after 2 minutes?
 
Maybe explain more for people who don't know soulwar quest.
So there are 8 boats where you want if a player is on any of them then he gets kicked/teleported out after 2 minutes?
Yes bro
Post automatically merged:

I managed to make it work only one position back and forth, just changing the floor as it should be, but I would have other positions of the boat to do the same, but I am not able to make it work, could someone help me? Note: The lever is just a reference for the player to be teleported according to the position of the lever "every 2 minutes"

LUA:
local positions = {
    Position(33830, 30981, 8)
}

local config = {
    playerPositions = {
        Position(33910, 31001, 9), -- 1
    },
    newPositions = {
        Position(33910, 31001, 8), -- 1
    },
}
local config2 = {
    playerPositions = {
        Position(33910, 31001, 9), -- 1
    },
    newPositions = {
        Position(33910, 31001, 8), -- 1
    },
}
local config3 = {
    playerPositions = {
        Position(33911, 31001, 9), -- 1
    },
    newPositions = {
        Position(33911, 31001, 8), -- 1
    },
}
local config4 = {
    playerPositions = {
        Position(33911, 31001, 8), -- 1
    },
    newPositions = {
        Position(33911, 31001, 9), -- 1
    },
}

function onThink(interval, lastExecution)
    local item
    for i = 1, #positions do
        item = Tile(positions[i]):getThing(1)
        if item and isInArray({1945, 1946}, item.itemid) then
            item:transform(item.itemid == 1945 and 1946 or 1945)           
        for _, player in ipairs(Game.getPlayers()) do
            if item.itemid == 1946 then
        local storePlayers, playerTile = {}
                for i = 1, #config.playerPositions do
                    playerTile = Tile(config.playerPositions[i]):getTopCreature()
                if not playerTile or not playerTile:isPlayer() then
                    return true
                end
                    player:teleportTo(config.newPositions[i])
                end   
        else

                for i = 1, #config2.playerPositions do
                    playerTile = Tile(config2.playerPositions[i]):getTopCreature()
                if not playerTile or not playerTile:isPlayer() then
                    return true
                end
                    player:teleportTo(config2.newPositions[i])
                end               
            end
        end
        end
    end
    return true
end
 
Last edited:
Something like this? Using the lever will teleport player to teleportToPosition from the table and start addEvent to kick players in the range fromPosition toPosition to the kickPos for each actionId on the table after 2 minutes passed.
LUA:
local soulWarBoats = Action()

local soulWarPositions = {
    -- [actionId]
    [1000] = {
        teleportToPosition = {x = 500, y = 500, z = 7},
        fromPosition = {x = 1000, y = 1000, z = 7},
        toPosition = {x = 2000, y = 2000, z = 7},
        kickPos = {x = 3000, y = 3000, z = 7}
    },
    [2000] = {
        teleportToPosition = {x = 500, y = 500, z = 7},
        fromPosition = {x = 1000, y = 1000, z = 7},
        toPosition = {x = 2000, y = 2000, z = 7},
        kickPos = {x = 3000, y = 3000, z = 7}
    }
}

function soulWarBoats.onUse(player, item, fromPos, target, toPos, isHotkey)
    local soulWarBoats = soulWarPositions[item:getActionId()]

    player:teleportTo(soulWarBoats.teleportToPosition)
    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)

    for v, k in pairs(soulWarPositions) do
        addEvent(
            function(playerId)
                local boatPlayer = Player(playerId)
                if not boatPlayer or not boatPlayer:isPlayer() then
                    return nil
                end
                if boatPlayer then
                    local boatPlayerPos = boatPlayer:getPosition()
                    local leftTopCorner = k.fromPosition
                    local rightBottomCorner = k.fromPosition
                    if boatPlayerPos:isInRange(leftTopCorner, rightBottomCorner) then
                        boatPlayer:getPosition():sendMagicEffect(CONST_ME_POFF)
                        boatPlayer:teleportTo(k.kickPos)
                    end
                end
            end,
            2 * 60 * 1000,
            player:getId()
        )
    end
    return true
end

for v, k in pairs(soulWarPositions) do
    soulWarBoats:aid(v)
end
soulWarBoats:register()
 
Something like this? Using the lever will teleport player to teleportToPosition from the table and start addEvent to kick players in the range fromPosition toPosition to the kickPos for each actionId on the table after 2 minutes passed.
LUA:
local soulWarBoats = Action()

local soulWarPositions = {
    -- [actionId]
    [1000] = {
        teleportToPosition = {x = 500, y = 500, z = 7},
        fromPosition = {x = 1000, y = 1000, z = 7},
        toPosition = {x = 2000, y = 2000, z = 7},
        kickPos = {x = 3000, y = 3000, z = 7}
    },
    [2000] = {
        teleportToPosition = {x = 500, y = 500, z = 7},
        fromPosition = {x = 1000, y = 1000, z = 7},
        toPosition = {x = 2000, y = 2000, z = 7},
        kickPos = {x = 3000, y = 3000, z = 7}
    }
}

function soulWarBoats.onUse(player, item, fromPos, target, toPos, isHotkey)
    local soulWarBoats = soulWarPositions[item:getActionId()]

    player:teleportTo(soulWarBoats.teleportToPosition)
    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)

    for v, k in pairs(soulWarPositions) do
        addEvent(
            function(playerId)
                local boatPlayer = Player(playerId)
                if not boatPlayer or not boatPlayer:isPlayer() then
                    return nil
                end
                if boatPlayer then
                    local boatPlayerPos = boatPlayer:getPosition()
                    local leftTopCorner = k.fromPosition
                    local rightBottomCorner = k.fromPosition
                    if boatPlayerPos:isInRange(leftTopCorner, rightBottomCorner) then
                        boatPlayer:getPosition():sendMagicEffect(CONST_ME_POFF)
                        boatPlayer:teleportTo(k.kickPos)
                    end
                end
            end,
            2 * 60 * 1000,
            player:getId()
        )
    end
    return true
end

for v, k in pairs(soulWarPositions) do
    soulWarBoats:aid(v)
end
soulWarBoats:register()
No bro, the lever was just a reference I had for the TP to happen automatically. It works like this... Every 2 minutes the boat rises and falls with the flood, and with that the player is teleported to the same position upstairs and the same thing downstairs. In fact there is no lever in this system, I just found a reference to try to make the system, because I don't understand much about LUA =/
Post automatically merged:

I managed to do it in just one position as shown in the gif below. I can't do it with other positions...

converter para gif_2.gif
 
Last edited:
You can use the same script above but change to onStepIn and add actionIds to the boat tiles.
LUA:
local soulWarBoats = MoveEvent()
soulWarBoats:type("stepin")

local soulWarPositions = {
    -- [actionId]
    [1000] = {
        teleportToPosition = {x = 500, y = 500, z = 7},
        fromPos = {x = 1000, y = 1000, z = 7},
        toPosition = {x = 2000, y = 2000, z = 7},
        kickPos = {x = 3000, y = 3000, z = 7}
    },
    [2000] = {
        teleportToPosition = {x = 500, y = 500, z = 7},
        fromPos = {x = 1000, y = 1000, z = 7},
        toPosition = {x = 2000, y = 2000, z = 7},
        kickPos = {x = 3000, y = 3000, z = 7}
    }
}

function soulWarBoats.onStepIn(creature, item, position, fromPosition)
    local soulWarBoats = soulWarPositions[item:getActionId()]
    if not creature:isPlayer() then
        return true
    end

    creature:teleportTo(soulWarBoats.teleportToPosition)
    creature:getPosition():sendMagicEffect(CONST_ME_TELEPORT)

    for v, k in pairs(soulWarPositions) do
        addEvent(
            function(playerId)
                local boatPlayer = Player(playerId)
                if not boatPlayer or not boatPlayer:isPlayer() then
                    return nil
                end
                if boatPlayer then
                    local boatPlayerPos = boatPlayer:getPosition()
                    local leftTopCorner = k.fromPos
                    local rightBottomCorner = k.fromPos
                    if boatPlayerPos:isInRange(leftTopCorner, rightBottomCorner) then
                        boatPlayer:getPosition():sendMagicEffect(CONST_ME_POFF)
                        boatPlayer:teleportTo(k.kickPos)
                    end
                end
            end,
            2 * 60 * 1000,
            creature:getId()
        )
    end
    return true
end

for v, k in pairs(soulWarPositions) do
    soulWarBoats:aid(v)
end
soulWarBoats:register()
 
You can use the same script above but change to onStepIn and add actionIds to the boat tiles.
LUA:
local soulWarBoats = MoveEvent()
soulWarBoats:type("stepin")

local soulWarPositions = {
    -- [actionId]
    [1000] = {
        teleportToPosition = {x = 500, y = 500, z = 7},
        fromPos = {x = 1000, y = 1000, z = 7},
        toPosition = {x = 2000, y = 2000, z = 7},
        kickPos = {x = 3000, y = 3000, z = 7}
    },
    [2000] = {
        teleportToPosition = {x = 500, y = 500, z = 7},
        fromPos = {x = 1000, y = 1000, z = 7},
        toPosition = {x = 2000, y = 2000, z = 7},
        kickPos = {x = 3000, y = 3000, z = 7}
    }
}

function soulWarBoats.onStepIn(creature, item, position, fromPosition)
    local soulWarBoats = soulWarPositions[item:getActionId()]
    if not creature:isPlayer() then
        return true
    end

    creature:teleportTo(soulWarBoats.teleportToPosition)
    creature:getPosition():sendMagicEffect(CONST_ME_TELEPORT)

    for v, k in pairs(soulWarPositions) do
        addEvent(
            function(playerId)
                local boatPlayer = Player(playerId)
                if not boatPlayer or not boatPlayer:isPlayer() then
                    return nil
                end
                if boatPlayer then
                    local boatPlayerPos = boatPlayer:getPosition()
                    local leftTopCorner = k.fromPos
                    local rightBottomCorner = k.fromPos
                    if boatPlayerPos:isInRange(leftTopCorner, rightBottomCorner) then
                        boatPlayer:getPosition():sendMagicEffect(CONST_ME_POFF)
                        boatPlayer:teleportTo(k.kickPos)
                    end
                end
            end,
            2 * 60 * 1000,
            creature:getId()
        )
    end
    return true
end

for v, k in pairs(soulWarPositions) do
    soulWarBoats:aid(v)
end
soulWarBoats:register()
It doesn't work synchronized with the map script. I believe it has to be onThink, just like I was trying to do
 

Similar threads

Back
Top