• 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 Teleport Players

Mr Erimyth

Member
Joined
Apr 8, 2009
Messages
163
Reaction score
11
Location
Brazil
VERSION : OTX Custon 1.3

Hell0o Anyone Can Help me ? my script dont teleports Players to new Roon

I need script if have 10 Players in 10 position and one use lever teleport all to new positions, all members need 100 Demonic essence and 30 Comandos Tokens

if one player dont have itens, no teleport anything.

my script dont have error on console :( ...

Lua:
-- Ao clicar na alavanca teleport 10 players para as 10 posicoes

--Pos atual
local playerPosition = {
    {x = 27137, y = 29737, z = 8,},   -- Trono 1
    {x = 27224, y = 29693, z = 9,},   -- Trono 2
    {x = 27154, y = 29638, z = 9,},   -- Trono 3
    {x = 27212, y = 29785, z = 5,},   -- Trono 10
    {x = 27121, y = 29710, z = 2,},   -- Trono 9
    {x = 27061, y = 29753, z = 6,},   -- Trono 8
    {x = 27016, y = 29786, z = 7,},   -- Trono 7
    {x = 27059, y = 29772, z = 8,},   -- Trono 6
    {x = 27013, y = 29670, z = 7,},   -- Trono 4
    {x = 27044, y = 29727, z = 7,}    -- Trono Principal 5 (Com alavanca)
}
--nova pos
local newPosition = {
    {x = 27017, y = 29692, z = 8},
    {x = 27018, y = 29692, z = 8},
    {x = 27019, y = 29692, z = 8},
    {x = 27020, y = 29692, z = 8},
    {x = 27021, y = 29692, z = 8},
    {x = 27022, y = 29692, z = 8},
    {x = 27023, y = 29692, z = 8},
    {x = 27024, y = 29692, z = 8},
    {x = 27025, y = 29692, z = 8},
    {x = 27026, y = 29692, z = 8}
}

local qtdPlayersToQuest = 1 -- test purpose

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local player = {}
    local haveAllRequiredActions = false
      
        if item.itemid == 1945 then          
              
                for i = 1, qtdPlayersToQuest do
                    player[i] = getThingfromPos(playerPosition[i])
                    if isPlayer(player[i].uid) ~= TRUE or getPlayerItemCount(player[i].uid, 6500) < 100 or getPlayerItemCount(player[i].uid, 29070) < 30  then
                        doCreatureSay(cid, 'You must conquest all Spirits Temples and each one needs to sacrifice 100 demoniac essence and 30 Comandos Tokens enter on Spirits of Infernia (SOI).', TALKTYPE_ORANGE_1)
                        return false
                    end      
                    if getPlayerLevel(player[i].uid) < 1000 then
                        doCreatureSay(cid, 'This quest can only be made by players level ' .. tostring(getConfigValue("soiLevel")) .. '+', TALKTYPE_ORANGE_1)
                        return false
                    end
                end
              
                for i = 1, qtdPlayersToQuest do
                        player[i] = getThingfromPos(playerPosition[i])                   
                        doPlayerRemoveItem(player[i].uid,6500, 100)
                        doPlayerRemoveItem(player[i].uid,29070, 30)
                        doSendMagicEffect(playerPosition[i], CONST_ME_POFF)      
                        doTeleportThing(player[i].uid, newPosition[i], FALSE)
                        doSendMagicEffect(newPosition[i], CONST_ME_ENERGYAREA)                                  
                end
          
                return true
          
        elseif item.itemid == 1946 then
            doPlayerSendCancel(cid, "Sorry, not possible. You need 10 players, one on each throne with the soul of the demonic.")
            return doTransformItem(item.uid, item.itemid - 1)
        end
end
 
Solution
Your code is so badly made, you are not even taking the advantage of OOP coding in Lua:
Code:
local config = {
    requiredLevel = 100,
    playerPositions = {
        Position(27137, 29737, 8),   -- Trono 1
        Position(27224, 29693, 9),   -- Trono 2
        Position(27154, 29638, 9),   -- Trono 3
        Position(27212, 29785, 5),   -- Trono 10
        Position(27121, 29710, 2),   -- Trono 9
        Position(27061, 29753, 6),   -- Trono 8
        Position(27016, 29786, 7),   -- Trono 7
        Position(27059, 29772, 8),   -- Trono 6
        Position(27013, 29670, 7),   -- Trono 4
        Position(27044, 29727, 7)    -- Trono Principal 5 (Com alavanca)
    },
    newPositions = {
        Position(27017, 29692, 8)...
local config = {
requiredLevel = 100,
daily = false,
centerRoomPosition = Position(33221, 31659, 13),
playerPositions = {
Position(33225, 31671, 13),
Position(33224, 31671, 13),
Position(33223, 31671, 13),
Position(33223, 31671, 13),
Position(33223, 31671, 13),
Position(33223, 31671, 13),
Position(33223, 31671, 13),
Position(33223, 31671, 13),
Position(33223, 31671, 13),
Position(33222, 31671, 13)
},
newPositions = {
Position(33222, 31659, 13),
Position(33221, 31659, 13),
Position(33220, 31659, 13),
Position(33223, 31671, 13),
Position(33223, 31671, 13),
Position(33223, 31671, 13),
Position(33223, 31671, 13),
Position(33223, 31671, 13),
Position(33223, 31671, 13),
Position(33219, 31659, 13)
}
}


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

for i = 1, #config.playerPositions do
playerTile = Tile(config.playerPositions):getTopCreature()
if not playerTile or not playerTile:isPlayer() then
player:sendTextMessage(MESSAGE_STATUS_SMALL, "You need 10 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

if playerTile:getItemCount(29465) == 30 and playerTile:getItemCount(29465) == 100 then -- coloque aqui o id dos items e a quantidade
return player:sendTextMessage(MESSAGE_STATUS_SMALL, "coloque sua mensagem quaso o palyers n tenha o item")
end

storePlayers[#storePlayers + 1] = playerTile
end

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

spec:remove()
end

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

item:transform(item.itemid == 1946 and 1945 or 1946)
return true
end
 
Your code is so badly made, you are not even taking the advantage of OOP coding in Lua:
Code:
local config = {
    requiredLevel = 100,
    playerPositions = {
        Position(27137, 29737, 8),   -- Trono 1
        Position(27224, 29693, 9),   -- Trono 2
        Position(27154, 29638, 9),   -- Trono 3
        Position(27212, 29785, 5),   -- Trono 10
        Position(27121, 29710, 2),   -- Trono 9
        Position(27061, 29753, 6),   -- Trono 8
        Position(27016, 29786, 7),   -- Trono 7
        Position(27059, 29772, 8),   -- Trono 6
        Position(27013, 29670, 7),   -- Trono 4
        Position(27044, 29727, 7)    -- Trono Principal 5 (Com alavanca)
    },
    newPositions = {
        Position(27017, 29692, 8),
        Position(27018, 29692, 8),
        Position(27019, 29692, 8),
        Position(27020, 29692, 8),
        Position(27021, 29692, 8),
        Position(27022, 29692, 8),
        Position(27023, 29692, 8),
        Position(27024, 29692, 8),
        Position(27025, 29692, 8),
        Position(27026, 29692, 8)
    },
}


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

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

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

            if playerTile:getItemCount(6500) < 100 or playerTile:getItemCount(29070) < 30 then
                player:say("You must conquest all Spirits Temples and each one needs to sacrifice 100 demoniac essence and 30 Comandos Tokens enter on Spirits of Infernia (SOI).", TALKTYPE_MONSTER_SAY)
                return true
            end

            storePlayers[#storePlayers + 1] = playerTile
        end

        for i = 1, #storePlayers do
            local 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)
            players:removeItem(6500, 100)
            players:removeItem(29070, 30)
        end
    end

    item:transform(item.itemid == 1946 and 1945 or 1946)
    return true
end
 
Last edited:
Solution
Dont work
Ul2eJPP.png
 
I would like something similar but the script that should check a square area, and then all the players in that area would be teleported to a single location.
 
Back
Top