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

help with a script

dfs1

Member
Joined
Aug 27, 2011
Messages
82
Solutions
1
Reaction score
8
good day community , Could you help me, with the following script, that each player teleports to a different place, this script teleport all players to a single place.

I would be very grateful, if they could help me.

Lua:
local config = {
    leverUniqueID = 1255,
    requiredLevel = 150,
    daily = true,
    bossName = "Absum, Lacunean Wanderer",
    storage = 1255,
    roomCenterPosition = Position(784, 431, 10),
    playerPositions = {
        Position(785, 437, 9),
        Position(784, 439, 9),
        Position(786, 439, 9)
    },
    teleportPosition = Position(785, 434, 10),
    bossPosition = Position(781, 432, 10),

    kickMinutes = 10, -- minutes
    kickPosition = Position(785, 444, 9)
}

local absum = Action()

function absum.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item:getId() == 8047 then
            if player:getPosition() ~= Position (785, 437, 9) then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Stand in front of the book..")
            return true
        end

        local participants = {}
        for _, playerPos in pairs(config.playerPositions) do
            local tile = Tile(playerPos)
            if tile then
                local participant = tile:getTopCreature()
                if participant and participant:isPlayer() then
                    if participant:getLevel() < config.requiredLevel then
                        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("All the players need to be level %d or higher.", config.requiredLevel))
                        return true
                    end

                    if config.daily and participant:getStorageValue(config.storage) > os.time() then
                        player:getPosition():sendMagicEffect(CONST_ME_POFF)
                        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "One or more players are not ready to fight again.")
                        participant:sendCancelMessage("you need to wait "..player:getStorageValue(config.storage) - os.time().." seconds to boss fight.")
                        return true
                    end

                    participants[#participants +1] = participant
                end
            end

 local clearOberonRoom = Game.getSpectators(Position(config.roomCenterPosition), false, false, 7, 7, 7, 7)       
 for index, spectatorcheckface in ipairs(clearOberonRoom) do
 if spectatorcheckface:isPlayer() then
 player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Someone is fighting against the boss! You need wait awhile.")
 return false
 end
 end
 for index, removeOberon in ipairs(clearOberonRoom) do
 if (removeOberon:isMonster()) then
 removeOberon:remove()
 end
 end
        end

        local boss = Game.createMonster(config.bossName, config.bossPosition)
        if boss then boss:registerEvent("CancelKickEvent") end

        for _, participant in pairs(participants) do
            participant:getPosition():sendMagicEffect(CONST_ME_POFF)
            participant:teleportTo(config.teleportPosition)
            participant:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have 10 minute(s) to defeat the boss.')
            participant:setStorageValue(config.storage, os.time() + 0*60*60)
        end
        
        config.teleportPosition:sendMagicEffect(CONST_ME_ENERGYAREA)

        config.kickEventId = addEvent(function ()
            for _, spectator in pairs(Game.getSpectators(config.roomCenterPosition, false, false, 7, 7, 7, 7)) do
                if spectator:isPlayer() then
                    spectator:teleportTo(config.kickPosition, false)
                    spectator:sendTextMessage(MESSAGE_EVENT_ADVANCE,"Time is out!")
                else
                    spectator:remove()
                end
            end
            config.kickPosition:sendMagicEffect(CONST_ME_TELEPORT)
        end, config.kickMinutes * 1000 * 60)
    end

    item:transform(8047)
    return true
end

absum:uid(config.leverUniqueID)
absum:register()
 
Solution
B
Lua:
local config = {
    leverUniqueID = 1255,
    requiredLevel = 150,
    daily = true,
    bossName = "Absum, Lacunean Wanderer",
    storage = 1255,
    roomCenterPosition = Position(784, 431, 10),
    playerPositions = {
        Position(785, 437, 9),
        Position(784, 439, 9),
        Position(786, 439, 9)
    },
    teleportPositions = {
        Position(785, 434, 10),
        Position(786, 434, 10),
        Position(787, 434, 10)
    }
    bossPosition = Position(781, 432, 10),

    kickMinutes = 10, -- minutes
    kickPosition = Position(785, 444, 9)
}

local absum = Action()

function absum.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item:getId() == 8047 then
            if player:getPosition() ~=...
Just random specified positions? A position can be repeated or must be unique for every player?
 
Lua:
local config = {
    leverUniqueID = 1255,
    requiredLevel = 150,
    daily = true,
    bossName = "Absum, Lacunean Wanderer",
    storage = 1255,
    roomCenterPosition = Position(784, 431, 10),
    playerPositions = {
        Position(785, 437, 9),
        Position(784, 439, 9),
        Position(786, 439, 9)
    },
    teleportPositions = {
        Position(785, 434, 10),
        Position(786, 434, 10),
        Position(787, 434, 10)
    }
    bossPosition = Position(781, 432, 10),

    kickMinutes = 10, -- minutes
    kickPosition = Position(785, 444, 9)
}

local absum = Action()

function absum.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item:getId() == 8047 then
            if player:getPosition() ~= Position (785, 437, 9) then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Stand in front of the book..")
            return true
        end

        local participants = {}
        for _, playerPos in pairs(config.playerPositions) do
            local tile = Tile(playerPos)
            if tile then
                local participant = tile:getTopCreature()
                if participant and participant:isPlayer() then
                    if participant:getLevel() < config.requiredLevel then
                        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("All the players need to be level %d or higher.", config.requiredLevel))
                        return true
                    end

                    if config.daily and participant:getStorageValue(config.storage) > os.time() then
                        player:getPosition():sendMagicEffect(CONST_ME_POFF)
                        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "One or more players are not ready to fight again.")
                        participant:sendCancelMessage("you need to wait "..player:getStorageValue(config.storage) - os.time().." seconds to boss fight.")
                        return true
                    end

                    participants[#participants +1] = participant
                end
            end

            local clearOberonRoom = Game.getSpectators(Position(config.roomCenterPosition), false, false, 7, 7, 7, 7)  
            for index, spectatorcheckface in ipairs(clearOberonRoom) do
                if spectatorcheckface:isPlayer() then
                    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Someone is fighting against the boss! You need wait awhile.")
                    return false
                end
            end
            for index, removeOberon in ipairs(clearOberonRoom) do
                if (removeOberon:isMonster()) then
                    removeOberon:remove()
                end
            end
        end

        local boss = Game.createMonster(config.bossName, config.bossPosition)
        if boss then boss:registerEvent("CancelKickEvent") end

        for i, participant in pairs(participants) do
            participant:getPosition():sendMagicEffect(CONST_ME_POFF)
            participant:teleportTo(config.teleportPositions[i])
            participant:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have 10 minute(s) to defeat the boss.')
            participant:setStorageValue(config.storage, os.time() + 0*60*60)
            config.teleportPositions[i]:sendMagicEffect(CONST_ME_ENERGYAREA)
        end

        config.kickEventId = addEvent(function ()
            for _, spectator in pairs(Game.getSpectators(config.roomCenterPosition, false, false, 7, 7, 7, 7)) do
                if spectator:isPlayer() then
                    spectator:teleportTo(config.kickPosition, false)
                    spectator:sendTextMessage(MESSAGE_EVENT_ADVANCE,"Time is out!")
                else
                    spectator:remove()
                end
            end
            config.kickPosition:sendMagicEffect(CONST_ME_TELEPORT)
        end, config.kickMinutes * 1000 * 60)
    end

    item:transform(8047)
    return true
end

absum:uid(config.leverUniqueID)
absum:register()

Edit: Just realised this won't actually co-ordinate the exact matched fromPos and toPos, because its looping through a different table.
For example, if theres only 1 player standing on the 4th tile, he will get teleported to the 1st position in teleportPositions.

It will still work but not ideal. It's a very quick fix but wait for someone to spend more time writing a better alternative.
 
Solution
Back
Top