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

Lever for more players

Wanheda

New Member
Joined
Feb 17, 2016
Messages
44
Solutions
2
Reaction score
4
I have this script and it only teleports the person that is in PlayerPosition. I would like it to teleport more players than configured in PlayerPosition2, PlayerPosition3 and so on.

Lua:
local Config = {
        bossName = 'Rat', -- boss name
        PlayerPosition = Position(32715, 31644, 7),  -- Where the player should be.
        newPosition = Position(32715, 31625, 7), -- Position to teleport
        bossPosition = Position(32715, 31616, 7), -- Boss Position
        centerPosition = Position(32715, 31616, 7), -- Center Room
        exitPosition = Position(32715, 31640, 7), -- Exit Position
        rangeX = 13,
        rangeY = 13,
        time = 1, -- time in minutes to remove the player
}

local function roomIsOccupied(centerPosition, rangeX, rangeY)
    local spectators = Game.getSpectators(centerPosition, false, false, rangeX, rangeX, rangeY, rangeY)
    if #spectators ~= 0 then
        return true
    end

    return false
end

function clearBossRoom(playerId, centerPosition, rangeX, rangeY, exitPosition)
    local spectators, spectator = Game.getSpectators(centerPosition, false, false, rangeX, rangeX, rangeY, rangeY)
    for i = 1, #spectators do
        spectator = spectators[i]
        if spectator:isPlayer() and spectator.uid == playerId then
            spectator:teleportTo(exitPosition)
            exitPosition:sendMagicEffect(CONST_ME_TELEPORT)
        end

        if spectator:isMonster() then
            spectator:remove()
        end
    end
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)

    if item.itemid == 9825 or 9826 then

    local creature = Tile(Config.PlayerPosition):getTopCreature()
    if not creature or not creature:isPlayer() then
        return true
    end
  
    if roomIsOccupied(Config.centerPosition, Config.rangeX, Config.rangeY) then
        player:sendCancelMessage("There is someone in the room.")
        return true
    end
  
    local monster = Game.createMonster(Config.bossName, Config.bossPosition)
    if not monster then
        return true
    end
  
  
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have entered an ancient demon prison cell!')
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have fifteen minutes to kill and loot this boss, else you will lose that chance.')

  
    addEvent(clearBossRoom, 60 * Config.time * 1000, player:getId(), Config.centerPosition, Config.rangeX, Config.rangeY, Config.exitPosition)
    player:teleportTo(Config.newPosition)
    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    end
  
    item:transform(item.itemid == 9825 and 9826 or 9825)
    return true
end
 
Last edited:
yes, I could use it, but in the script the anihilator is needed 4 players, and I want to teleport how many players to configure. example, it has 5 places, but I can pull a lever if you have 3.
 
yes, I could use it, but in the script the anihilator is needed 4 players, and I want to teleport how many players to configure. example, it has 5 places, but I can pull a lever if you have 3.
That isn't true you can configure the annihilator script. See playerPosition and newPosition?
Lua:
local playerPosition = {
    {x = 247, y = 659, z = 13},
    {x = 247, y = 660, z = 13},
    {x = 247, y = 661, z = 13},
    {x = 247, y = 662, z = 13}
}
local newPosition = {
    {x = 189, y = 650, z = 13},
    {x = 189, y = 651, z = 13},
    {x = 189, y = 652, z = 13},
    {x = 189, y = 653, z = 13}
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == 1945 then
        local players = {}
        for _, position in ipairs(playerPosition) do
            local topPlayer = Tile(position):getTopCreature()
            if not topPlayer or not topPlayer:isPlayer() or topPlayer:getLevel() < 100 or topPlayer:getStorageValue(30015) ~= -1 then
                player:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
                return false
            end
            players[#players + 1] = topPlayer
        end

        for i, targetPlayer in ipairs(players) do
            Position(playerPosition[i]):sendMagicEffect(CONST_ME_POFF)
            targetPlayer:teleportTo(newPosition[i], false)
            targetPlayer:getPosition():sendMagicEffect(CONST_ME_ENERGYAREA)
        end
        item:transform(1946)
    elseif item.itemid == 1946 then
        player:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
    end
    return true
end
 
I think you did not understand, what I meant, to take players from a certain area to a sqm, regardless of the amount of player.
 
I think you did not understand, what I meant, to take players from a certain area to a sqm, regardless of the amount of player.
Easiest way to accomplish this is to NOT use positions to teleport a player. You should write a movements script that sets a storage value of the player and then teleport any player with that storage value. You will also need to unset the storage once they have gotten to the destination this way you aren't teleporting them more than once.

You might also need to reset the storage value when they log out just incase they logout before they have a chance to be teleported. I am sure you can proceed from here on your own. :)
 
This?
Lua:
local Config = {
        bossName = 'Rat', -- boss name
        PlayerPosition = Position(32715, 31644, 7),  -- Where the player should be.
        newPosition = Position(32715, 31625, 7), -- Position to teleport
        bossPosition = Position(32715, 31616, 7), -- Boss Position
        centerPosition = Position(32715, 31616, 7), -- Center Room
        exitPosition = Position(32715, 31640, 7), -- Exit Position
        rangeX = 13,
        rangeY = 13,
        time = 1, -- time in minutes to remove the player
}
local function roomIsOccupied(centerPosition, rangeX, rangeY)
    local spectators = Game.getSpectators(centerPosition, false, false, rangeX, rangeX, rangeY, rangeY)
    if #spectators ~= 0 then
        return true
    end
    return false
end
function clearBossRoom(playerId, centerPosition, rangeX, rangeY, exitPosition)
    local spectators, spectator = Game.getSpectators(centerPosition, false, false, rangeX, rangeX, rangeY, rangeY)
    for i = 1, #spectators do
        spectator = spectators[i]
        if spectator:isPlayer() and spectator.uid == playerId then
            spectator:teleportTo(exitPosition)
            exitPosition:sendMagicEffect(CONST_ME_TELEPORT)
        end
        if spectator:isMonster() then
            spectator:remove()
        end
    end
end
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == 9825 or 9826 then
    local creature = Tile(Config.PlayerPosition):getTopCreature()
    if not creature or not creature:isPlayer() then
        return true
    end
    if roomIsOccupied(Config.centerPosition, Config.rangeX, Config.rangeY) then
        player:sendCancelMessage("There is someone in the room.")
        return true
    end
    local monster = Game.createMonster(Config.bossName, Config.bossPosition)
    if not monster then
        return true
    end
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have entered an ancient demon prison cell!')
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have fifteen minutes to kill and loot this boss, else you will lose that chance.')
    addEvent(clearBossRoom, 60 * Config.time * 1000, player:getId(), Config.centerPosition, Config.rangeX, Config.rangeY, Config.exitPosition)


        pos1 = {x = 00000, y = 00000, z = getCreaturePosition(cid).z} -- configure the pos FROM
    pos2 = {x = 00000, y = 00000, z = getCreaturePosition(cid).z} -- configure the pos FROM
    pos3 = {x = 00000, y = 00000, z = getCreaturePosition(cid).z} -- configure the pos FROM
    pos4 = {x = 00000, y = 00000, z = getCreaturePosition(cid).z} -- configure the pos FROM
    pos5 = {x = 00000, y = 00000, z = getCreaturePosition(cid).z} -- configure the pos FROM
       
        -- you can configure more pos

        if(isPlayer(getTopCreature(pos1e).uid)) then               

        doTeleportThing(getTopCreature(pos1).uid, {x = 00000, y = 00000, z = 11}) -- configure the pos TO
    doTeleportThing(getTopCreature(pos2).uid, {x = 00000, y = 00000, z = 11})
    doTeleportThing(getTopCreature(pos3).uid, {x = 00000, y = 00000, z = 11})
    doTeleportThing(getTopCreature(pos4).uid, {x = 00000, y = 00000, z = 11})
    doTeleportThing(getTopCreature(pos5).uid, {x = 00000, y = 00000, z = 11})
        player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)

      --player:teleportTo(Config.newPosition)   
      end
   
    end
    item:transform(item.itemid == 9825 and 9826 or 9825)
    return true
end
 
Lua:
local area = { --This checks a square area defined by the top left and bottom right positions
    min = {x = 1000, y = 1000}, --Set this to the top left square of area you want to check
    max = {x = 1000, y = 1000} --Set this to the bottom right square of area you want to check
}

local area_teleport_to = {
    min = {x = 1000, y = 1000}, -- Area top left to teleport players
    min = {x = 1000, y = 1000} -- Area bottom right to teleport players
}

local posz = 7 --Floor its checking

local Config = {
        bossName = 'Rat', -- boss name
        bossPosition = Position(32715, 31616, 7), -- Boss Position
        centerPosition = Position(32715, 31616, 7), -- Center Room
        exitPosition = Position(32715, 31640, 7), -- Exit Position
        rangeX = 13,
        rangeY = 13,
        time = 1, -- time in minutes to remove the player
}

local function roomIsOccupied(centerPosition, rangeX, rangeY)
    local spectators = Game.getSpectators(centerPosition, false, false, rangeX, rangeX, rangeY, rangeY)
    if #spectators ~= 0 then
        return true
    end
    return false
end

function clearBossRoom(centerPosition, rangeX, rangeY, exitPosition)
    local spectators, spectator = Game.getSpectators(centerPosition, false, false, rangeX, rangeX, rangeY, rangeY)
    for i = 1, #spectators do
        spectator = spectators[i]
        if spectator:isPlayer() then
            spectator:teleportTo(exitPosition)
            exitPosition:sendMagicEffect(CONST_ME_TELEPORT)
        end
        if spectator:isMonster() then
            spectator:remove()
        end
    end
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local creature = Tile(Config.PlayerPosition):getTopCreature()
    if not creature or not creature:isPlayer() then
        return true
    end

    if roomIsOccupied(Config.centerPosition, Config.rangeX, Config.rangeY) then
        player:sendCancelMessage("There is someone in the room.")
        return true
    end

    local monster = Game.createMonster(Config.bossName, Config.bossPosition)
    if not monster then
        return true
    end
   
    local area_x = area.min.x
    local area_y = area.min.y
   
    while area_x <= area.max.x do
        while area_y <= area.max.y do
            POS = {x = area_x, y = area_y, z = posz}
           
            PLAYER = Player(POS:getThing())
           
            if PLAYER then
                PLAYER:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have entered an ancient demon prison cell!')
                PLAYER:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have fifteen minutes to kill and loot this boss, else you will lose that chance.')
                rand_pos = {x = math.random(area_teleport_to.min.x, area_teleport_to.max.x), y = math.random(area_teleport_to.min.y, area_teleport_to.max.y), z = posz}
                PLAYER:teleportTo(rand_pos)
                PLAYER:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
            end
            area_x = area_x + 1
            area_y = area_y + 1
        end
    end
    addEvent(clearBossRoom, 60 * Config.time * 1000, Config.centerPosition, Config.rangeX, Config.rangeY, Config.exitPosition)
    item:transform(item.itemid == 9825 and 9826 or 9825)
    return true
end
 
Back
Top