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

Lua tp 1 or more players from sqm

leandroluck

New Member
Joined
Dec 24, 2010
Messages
104
Reaction score
1
Code:
local config = {
    requiredLevel = 100,
    daily = false,
    centerDemonRoomPosition = Position(32799, 32829, 14),
    playerPositions = {
        Position(32759, 32868, 14),
        Position(32759, 32869, 14),
        Position(32759, 32870, 14),
        Position(32759, 32871, 14),
        Position(32759, 32872, 14),
    },
    newPositions = {
    Position(32795, 32816, 14),
        Position(32795, 32816, 14),
            Position(32795, 32816, 14),
                Position(32795, 32816, 14),
                    Position(32795, 32816, 14),
    },
    demonPositions = {
        Position(32799, 32829, 14)
    }
}


function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == 9826 then
    local storePlayers, playerTile = {}

        for i = 1, #config.playerPositions do
            playerTile = Tile(config.playerPositions[i]):getTopCreature()
            if not playerTile or not playerTile:isPlayer() then
                player:sendTextMessage(MESSAGE_STATUS_SMALL, "You need 5 players.")
                return true
            end

            if playerTile:getLevel() < config.requiredLevel then
                player:sendTextMessage(MESSAGE_STATUS_SMALL, "All the players need to be level ".. config.requiredLevel .." or higher.")
                return true
            end

            storePlayers[#storePlayers + 1] = playerTile
        end

        local specs, spec = Game.getSpectators(config.centerDemonRoomPosition, false, false, 3, 3, 2, 2)
        for i = 1, #specs do
            spec = specs[i]
            if spec:isPlayer() then
                player:sendTextMessage(MESSAGE_STATUS_SMALL, "A team is already inside the quest room.")
                return true
            end

            spec:remove()
        end

        for i = 1, #config.demonPositions do
            Game.createMonster("nomateste", config.demonPositions[i])
            end

        local players
        for i = 1, #storePlayers do
            players = storePlayers[i]
            config.playerPositions[i]:sendMagicEffect(CONST_ME_POFF)
            players:teleportTo(config.newPositions[i])
            config.newPositions[i]:sendMagicEffect(CONST_ME_ENERGYAREA)
            players:setDirection(DIRECTION_EAST)
        end
    elseif item.itemid == 9825 then
        if config.daily then
            player:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_NOTPOSSIBLE))
            return true
        end
    end

    item:transform(item.itemid == 9826 and 9825 or 9826)
    return true
end

I'm trying to edit this script more unsuccessfully
in this place has 5 sqm for the players to stay at the pull the lever who was in the sqm will take tp to the room
 
Last edited:
Solution
Delete this part:
Lua:
if not playerTile or not playerTile:isPlayer() then
    player:sendTextMessage(MESSAGE_STATUS_SMALL, "You need 5 players.")
    return true
end

Change this part:
Lua:
 if playerTile:getLevel() < config.requiredLevel then
to:
Lua:
 if playerTile and playerTile:getLevel() < config.requiredLevel then
In line:
Lua:
Game.createMonster("bossname, config.demonPositions[i])

use actual monster name, for example:
Lua:
Game.createMonster("Demon", config.demonPositions[i])
 
are there any errors? what happens when you click the lever?
I do not have error in the script as it is now.
now only 5 people can go.
my idea is if I had only 1 person it can go if I had 2 person can go since it is in sqm

In line:
Lua:
Game.createMonster("bossname, config.demonPositions[i])

use actual monster name, for example:
Lua:
Game.createMonster("Demon", config.demonPositions[i])
That's not what I'm trying to do, I just put the boss name as an example.
the creation of the monster is ok.
 
Delete this part:
Lua:
if not playerTile or not playerTile:isPlayer() then
    player:sendTextMessage(MESSAGE_STATUS_SMALL, "You need 5 players.")
    return true
end

Change this part:
Lua:
 if playerTile:getLevel() < config.requiredLevel then
to:
Lua:
 if playerTile and playerTile:getLevel() < config.requiredLevel then
 
Solution
Delete this part:
Lua:
if not playerTile or not playerTile:isPlayer() then
    player:sendTextMessage(MESSAGE_STATUS_SMALL, "You need 5 players.")
    return true
end

Change this part:
Lua:
 if playerTile:getLevel() < config.requiredLevel then
to:
Lua:
 if playerTile and playerTile:getLevel() < config.requiredLevel then
I had tried this way more what happens is that now the lever moves sideways plus anyone who is in the sqm is not moved to the other location

--edit-

I edited a part and it worked thanks
 
Last edited:
Delete this part:
Lua:
if not playerTile or not playerTile:isPlayer() then
    player:sendTextMessage(MESSAGE_STATUS_SMALL, "You need 5 players.")
    return true
end

Change this part:
Lua:
 if playerTile:getLevel() < config.requiredLevel then
to:
Lua:
 if playerTile and playerTile:getLevel() < config.requiredLevel then

You can add use dialy for the 5 players?
 
Back
Top