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

Convert Script to tfs 1.2

Solution
added some extra shit like invalid player check, queue table instead of storages (so you dont have to iterate through every single player in the game)
and now it actually checks if the vocation is in queue or not, multiple numbers of a voc could have joined before
untested but should be fine unless i forgot about something
Lua:
local config = {
    vocations = { -- you need to set your numbers from vocations.xml
        {1, 5}, -- sorc
        {2, 6}, -- druid
        {3, 6}, -- paladin
        {4, 7}, -- knight
    },
    vocStorages = {
        33313, -- sorc
        33314, -- druid
        33315, -- paladin
        33316, -- knight
    },
    dungeonState = 33318, --// storage value
    dungeonPos = Position(1000, 1000, 7)
}

queue =...
It doesnt works like this? Tfs got backwards compatibility when it comes to functions
 
Code:
local config = {
    vocations = { -- you need to set your numbers from vocations.xml
        {1, 5}, -- sorc
        {2, 6}, -- druid
        {3, 6}, -- paladin
        {4, 7}, -- knight
    },
    vocStorages = {
        33313, -- sorc
        33314, -- druid
        33315, -- paladin
        33316, -- knight
    },
    storages = {
        inQueue = 33317,
        dungeonState = 33318,
    }
    dungeonPos = Position(1000, 1000, 7)
}

local function insertPlayerIntoQueue(player)
    for i = 1, 4 do
        if table.contains(config.vocations[i], player:getVocation():getId()) then
            Game.setStorageValue(config.vocStorages[i], 1)
        end
    end
    return true
end

function onSay(player, words, param, channel)
    if Game.getStorageValue(config.storages.dungeonState) < 0 then
        Game.getStorageValue(config.storages.dungeonState, 0)
    end
    local words = {'first', '1'}
    if table.contains(words, param) then
        if player:getStorageValue(config.storages.inQueue) == 1 then -- player is in queue but other vocations are missing
          if Game.getStorageValue(config.vocStorages[1]) ~= 1 or Game.getStorageValue(config.vocStorages[2]) ~= 1 or Game.getStorageValue(config.vocStorages[3]) ~= 1 or Game.getStorageValue(config.vocStorages[4]) ~= 1 then
                return player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You are in queue, but one or more vocations are missing.')
            end
        elseif player:getStorageValue(config.storages.inQueue) == 0 then
            if insertPlayerIntoQueue(player) then
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You are in queue now.')
            end
        end

        -- Teleport players to dungeon, if all vocations are ready
        if Game.getStorageValue(dungeonState) == 0 then
            if Game.getStorageValue(config.vocStorages[1]) == 1 and Game.getStorageValue(config.vocStorages[2]) == 1 and Game.getStorageValue(config.vocStorages[3]) == 1 and Game.getStorageValue(config.vocStorages[4]) == 1 then
                for _, players in ipairs(Game.getPlayers()) do
                    if players:getStorageValue(config.storages.inQueue) == 1 then
                        players:teleportTo(config.dungeonPosition)
                        players:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Welcome to dungeon one. This is your team.')
                        players:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
                        players:setStorageValue(config.storages.inQueue, 0)           
                    end
                end
                Game.setStorageValue(config.storages.dungeonState, 1)
            end
        else
            player:sendCancelMessage('The dungeon is already in use.')
        end
    end
    return false
end

Not tested

@edit
corrected some typos.
 
Last edited:
Code:
local config = {
    vocations = { -- you need to set yours numbers from vocations.xml
        {1, 5}, -- sorc
        {2, 6}, -- druid
        {3, 6}, -- paladin
        {4, 7}, -- knight
    },
    storages = {
        dungeonState = 33311,
        knight = 33313,
        sorc = 33314,
        paladin = 33315,
        druid = 33316,
        inQueue = 33317,
    }
    dungeonPos = Position(1000, 1000, 7)
}

local function insertPlayerIntoQueue(player)
    if table.contains(config.vocations[1], player:getVocation():getId()) then
        Game.setStorageValue(config.storages.sorc)
    elseif table.contains(config.vocations[2], player:getVocation():getId()) then
        Game.setStorageValue(config.storages.druid)
    elseif table.contains(config.vocations[3], player:getVocation():getId()) then
        Game.setStorageValue(config.storages.paladin)
    elseif table.contains(config.vocations[4], player:getVocation():getId()) then
        Game.setStorageValue(config.storages.knight)
    end
 
    return true
end

function onSay(player, words, param, channel)
    if Game.getStorageValue(config.storages.dungeonState) < 0 then
        Game.getStorageValue(config.storages.dungeonState, 0)
    end
    local words = {'first', '1'}
    if table.contains(words, param) then
        if player:getStorageValue(config.storages.inQueue) == 1 then -- player is in queue but other vocations are missing
            if Game.getStorageValue(config.storages.knight) ~= 1 or Game.getStorageValue(config.storages.sorc) ~= 1 or Game.getStorageValue(config.storages.druid) ~= 1 or Game.getStorageValue(config.storages.paladin) ~= 1 then
                return player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You are in queue, but one or more vocations are missing.')
            end
        elseif player:getStorageValue(config.storages.inQueue) == 0 then
            if insertPlayerIntoQueue(player) then
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You are in queue now.')
            end
        end
 
        -- Teleport players to dungeon, if all vocations are ready
        if Game.getStorageValue(dungeonState) == 0 then
            if Game.getStorageValue(config.storages.knight) == 1 and Game.getStorageValue(config.storages.sorc) == 1 and Game.getStorageValue(config.storages.druid) == 1 and Game.getStorageValue(config.storages.paladin) == 1 then
                for i, pid in ipairs(Game.getPlayers()) do
                    if (pid:getStorageValue(config.storages.inQueue) == 1 then
                        pid:teleportTo(config.dungeonPosition)
                        pid:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Welcome to dungeon one. This is your team.')
                        pid:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
                        pid:setStorageValue(config.storages.inQueue, 0)             
                    end
                end
                Game.setStorageValue(config.storages.dungeonState, 1)
            end
        else
            player:sendCancelMessage('The dungeon is already in use.')
        end
    end
    return false
end

Not tested

Take me a few seconds to see that won't work, xD.

Eg: check L53.
 
Code:
local config = {
    vocations = { -- you need to set your numbers from vocations.xml
        {1, 5}, -- sorc
        {2, 6}, -- druid
        {3, 6}, -- paladin
        {4, 7}, -- knight
    },
    vocStorages = {
        33313, -- sorc
        33314, -- druid
        33315, -- paladin
        33316, -- knight
    },
    storages = {
        inQueue = 33317,
        dungeonState = 33318,
    }
    dungeonPos = Position(1000, 1000, 7)
}

local function insertPlayerIntoQueue(player)
    for i = 1, 4 do
        if table.contains(config.vocations[i], player:getVocation():getId()) then
            Game.setStorageValue(config.vocStorages[i], 1)
        end
    end
    return true
end

function onSay(player, words, param, channel)
    if Game.getStorageValue(config.storages.dungeonState) < 0 then
        Game.getStorageValue(config.storages.dungeonState, 0)
    end
    local words = {'first', '1'}
    if table.contains(words, param) then
        if player:getStorageValue(config.storages.inQueue) == 1 then -- player is in queue but other vocations are missing
          if Game.getStorageValue(config.vocStorages[1]) ~= 1 or Game.getStorageValue(config.vocStorages[2]) ~= 1 or Game.getStorageValue(config.vocStorages[3]) ~= 1 or Game.getStorageValue(config.vocStorages[4]) ~= 1 then
                return player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You are in queue, but one or more vocations are missing.')
            end
        elseif player:getStorageValue(config.storages.inQueue) == 0 then
            if insertPlayerIntoQueue(player) then
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You are in queue now.')
            end
        end

        -- Teleport players to dungeon, if all vocations are ready
        if Game.getStorageValue(dungeonState) == 0 then
            if Game.getStorageValue(config.vocStorages[1]) == 1 and Game.getStorageValue(config.vocStorages[2]) == 1 and Game.getStorageValue(config.vocStorages[3]) == 1 and Game.getStorageValue(config.vocStorages[4]) == 1 then
                for _, players in ipairs(Game.getPlayers()) do
                    if players:getStorageValue(config.storages.inQueue) == 1 then
                        players:teleportTo(config.dungeonPosition)
                        players:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Welcome to dungeon one. This is your team.')
                        players:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
                        players:setStorageValue(config.storages.inQueue, 0)         
                    end
                end
                Game.setStorageValue(config.storages.dungeonState, 1)
            end
        else
            player:sendCancelMessage('The dungeon is already in use.')
        end
    end
    return false
end

Not tested

@edit
corrected some typos.

i receive this message
00:36 The dungeon is already in use.
based in your script but don't work :( no errors and nothing

Lua:
local config =
{
dungeon_one_open = 33311,
dungeon_one_pos = Position(32336, 32217, 7), -- teleport poss
knight_in_que = 33313,
sorc_in_que = 33314,
paladin_in_que = 33315,
druid_in_que = 33316,
in_que_one = 33317
}

function onSay(player, words, param, channel)
    if Game.getStorageValue(config.dungeon_one_open) == 0 then
        Game.getStorageValue(config.dungeon_one_open, 0)
    end
     ------------------This part is if player uses talkaction again, after being qued into the dungeon--------------
if (param == "1" or param == "first") then     
    if player:getStorageValue(config.in_que_one) == 1 then
        if player:getVocation():getId() == 1 or player:getVocation():getId() == 5 then
            if Game.getStorageValue(config.knight_in_que) ~= 1 then
                if Game.getStorageValue(config.druid_in_que) ~= 1 then
                    if Game.getStorageValue(config.paladin_in_que) ~= 1 then
                        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Waiting for all vocations.')
                    return false
                    else
                        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'waiting for a druid and a knight.')
                    return false
                    end
                else
                    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Waiting for a knight.')
                return false
                end
            end
          
    elseif player:getVocation():getId() == 2 or player:getVocation():getId() == 6 then
        if Game.getStorageValue(config.knight_in_que) ~= 1 then
            if Game.getStorageValue(config.sorc_in_que) ~= 1 then
                if Game.getStorageValue(config.paladin_in_que) ~= 1 then
                    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Waiting for all vocations.')
                return false
                else
                    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'waiting for a sorcerer and a knight.')
                return false
                end
            else
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Waiting for a knight.')
            return false
            end
        end
    elseif player:getVocation():getId() == 3 or player:getVocation():getId() == 7 then
        if Game.getStorageValue(config.knight_in_que) ~= 1 then
            if Game.getStorageValue(config.sorc_in_que) ~= 1 then
                if Game.getStorageValue(config.druid_in_que) ~= 1 then
                    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Waiting for all vocations.')
                return false
                else
                    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'waiting for a sorcerer and a knight.')
                return false
                end
            else
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Waiting for a knight.')
            return false
            end
        end
    elseif player:getVocation():getId() == 4 or player:getVocation():getId() == 8 then
        if Game.getStorageValue(config.druid_in_que) ~= 1 then
            if Game.getStorageValue(config.sorc_in_que) ~= 1 then
                if Game.getStorageValue(config.paladin_in_que) ~= 1 then
                    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Waiting for all vocations.')
                return false
                else
                    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'waiting for a sorcerer and a druid.')
                return false
                end
            else
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Waiting for a druid.')
            return false
            end
        end
else
----------------------This is main script--------------------------
if player:getVocation():getId() == 1 or player:getVocation():getId() == 5 then
        if Game.getStorageValue(config.dungeon_one_open) == 0 then
            if Game.getStorageValue(config.knight_in_que) == 1 then
                if Game.getStorageValue(config.paladin_in_que) == 1 then
                    if Game.getStorageValue(config.druid_in_que) == 1 then
                        if Game.getStorageValue(config.sorc_in_que) == 0 then
                            players:setStorageValue(config.in_que_one, 1)
                            for _, players in ipairs(Game.getPlayers()) do
                            ------------------Auto dungeon starter-----------------
                                if players:getStorageValue(config.in_que_one) == 1 then
                                    players:teleportTo(config.dungeon_one_pos)
                                    players:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Welcome to dungeon one. This is your team.')
                                     players:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
                                     Game.setStorageValue(config.dungeon_one_open, 1)
                                     players:setStorageValue(config.in_que_one, 0)                       
                                end
                            end
                        else
                            player:sendCancelMessage('There is already a Sorcerer qued in this dungeon.')
                        return false
                        end
                    else
                        doPlayerplayer:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have been qued, you will be teleported when there is a full team.')
                         players:setStorageValue(config.in_que_one, 1)
                    return false
                    end
                else
                    players:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have been qued, you will be teleported when there is a full team.')
                     players:setStorageValue(config.in_que_one, 1)
                return false
                end
            else
                players:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have been qued, you will be teleported when there is a full team.')
                 players:setStorageValue(config.in_que_one, 1)
            return false
            end
        else
            player:sendCancelMessage('The dungeon is already in use.')
        return false
        end
        ------------------Reapeat script for each voc.------------
    elseif player:getVocation():getId() == 2 or player:getVocation():getId() == 6 then
        if Game.getStorageValue(config.dungeon_one_open) == 0 then
            if Game.getStorageValue(config.sorc_in_que) == 1 then
                if Game.getStorageValue(config.paladin_in_que) == 1 then
                    if Game.getStorageValue(config.knight_in_que) == 1 then
                        if Game.getStorageValue(config.druid_in_que) == 0 then
                                     players:setStorageValue(config.in_que_one, 1)
                            for _, players in ipairs(Game.getPlayers()) do
                                if players:getStorageValue(config.in_que_one) == 1 then
                                    players:teleportTo(config.dungeon_one_pos)
                                    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Welcome to dungeon one. This is your team.')
                                    players:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
                                    Game.setStorageValue(config.dungeon_one_open, 1)
                                  
                                end
                            end
                        else
                            player:sendCancelMessage('There is already a Druid qued in this dungeon.')
                        return false
                        end
                    else
                        players:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have been qued, you will be teleported when there is a full team.')
                         players:setStorageValue(config.in_que_one, 1)
                    return false
                    end
                else
                    players:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have been qued, you will be teleported when there is a full team.')
                     players:setStorageValue(config.in_que_one, 1)
                return false
                end
            else
                players:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have been qued, you will be teleported when there is a full team.')
                 players:setStorageValue(config.in_que_one, 1)
            return false
            end
        else
            player:sendCancelMessage('The dungeon is already in use.')
        return false
        end
elseif player:getVocation():getId() == 3 or player:getVocation():getId() == 7 then
        if Game.getStorageValue(config.dungeon_one_open) == 0 then
            if Game.getStorageValue(config.knight_in_que) == 1 then
                if Game.getStorageValue(config.sorc_in_que) == 1 then
                    if Game.getStorageValue(config.druid_in_que) == 1 then
                        if Game.getStorageValue(config.paladin_in_que) == 0 then
                                     players:setStorageValue(config.in_que_one, 1)
                            for _, players in ipairs(Game.getPlayers()) do
                                if players:getStorageValue(config.in_que_one) == 1 then
                                    players:teleportTo(config.dungeon_one_pos)
                                    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Welcome to dungeon one. This is your team.')
                                    players:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
                                    Game.setStorageValue(config.dungeon_one_open, 1)
                                  
                                end
                            end
                        else
                            players:sendCancelMessage('There is already a Paladin qued in this dungeon.')
                        return false
                        end
                    else
                        players:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have been qued, you will be teleported when there is a full team.')
                         players:setStorageValue(config.in_que_one, 1)
                    return false
                    end
                else
                    players:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have been qued, you will be teleported when there is a full team.')
                     players:setStorageValue(config.in_que_one, 1)
                return false
                end
            else
                players:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have been qued, you will be teleported when there is a full team.')
                 players:setStorageValue(config.in_que_one, 1)
            return false
            end
        else
            players:sendCancelMessage('The dungeon is already in use.')
        return false
        end
elseif player:getVocation():getId() == 4 or player:getVocation():getId() == 8 then
        if Game.getStorageValue(config.dungeon_one_open) == 0 then
            if Game.getStorageValue(config.paladin_in_que) == 1 then
                if Game.getStorageValue(config.sorc_in_que) == 1 then
                    if Game.getStorageValue(config.druid_in_que) == 1 then
                        if Game.getStorageValue(config.knight_in_que) == 0 then
                                     players:setStorageValue(config.in_que_one, 1)
                            for _, players in ipairs(Game.getPlayers()) do
                                if players:getStorageValue(config.in_que_one) == 1 then
                                    players:teleportTo(config.dungeon_one_pos)
                                    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Welcome to dungeon one. This is your team.')
                                    players:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
                                    Game.setStorageValue(config.dungeon_one_open, 1)
                                end
                            end
                        else
                            players:sendCancelMessage('There is already a Paladin qued in this dungeon.')
                        return false
                        end
                    else
                        players:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have been qued, you will be teleported when there is a full team.')
                         players:setStorageValue(config.in_que_one, 1)
                    return false
                    end
                else
                    players:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have been qued, you will be teleported when there is a full team.')
                     players:setStorageValue(config.in_que_one, 1)
                return false
                end
            else
                players:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have been qued, you will be teleported when there is a full team.')
                 players:setStorageValue(config.in_que_one, 1)
            return false
            end
        else
            players:sendCancelMessage('The dungeon is already in use.')
        return false
        end
end

end
end
end
return true
end
 
Last edited:
Code:
local config = {
    vocations = { -- you need to set your numbers from vocations.xml
        {1, 5}, -- sorc
        {2, 6}, -- druid
        {3, 6}, -- paladin
        {4, 7}, -- knight
    },
    vocStorages = {
        33313, -- sorc
        33314, -- druid
        33315, -- paladin
        33316, -- knight
    },
    storages = {
        inQueue = 33317,
        dungeonState = 33318,
    }
    dungeonPos = Position(1000, 1000, 7)
}
local function insertPlayerIntoQueue(player)
    for i = 1, 4 do
        if table.contains(config.vocations[i], player:getVocation():getId()) then
            Game.setStorageValue(config.vocStorages[i], 1)
        end
    end
    return true
end
function onSay(player, words, param, channel)
    if Game.getStorageValue(config.storages.dungeonState) < 0 then
        Game.setStorageValue(config.storages.dungeonState, 0)
    end
    local words = {'first', '1'}
    if table.contains(words, param) then
        if player:getStorageValue(config.storages.inQueue) == 1 then -- player is in queue but other vocations are missing
          if Game.getStorageValue(config.vocStorages[1]) ~= 1 or Game.getStorageValue(config.vocStorages[2]) ~= 1 or Game.getStorageValue(config.vocStorages[3]) ~= 1 or Game.getStorageValue(config.vocStorages[4]) ~= 1 then
                return player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You are in queue, but one or more vocations are missing.')
            end
        elseif player:getStorageValue(config.storages.inQueue) == 0 then
            if insertPlayerIntoQueue(player) then
                player:setStorageValue(config.storages.inQueue, 1)
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You are in queue now.')
            end
        end
        -- Teleport players to dungeon, if all vocations are ready
        if Game.getStorageValue(config.dungeonState) == 0 then
            if Game.getStorageValue(config.vocStorages[1]) == 1 and Game.getStorageValue(config.vocStorages[2]) == 1 and Game.getStorageValue(config.vocStorages[3]) == 1 and Game.getStorageValue(config.vocStorages[4]) == 1 then
                for _, players in ipairs(Game.getPlayers()) do
                    if players:getStorageValue(config.storages.inQueue) == 1 then
                        players:teleportTo(config.dungeonPosition)
                        players:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Welcome to dungeon one. This is your team.')
                        players:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
                        players:setStorageValue(config.storages.inQueue, 0)     
                    end
                end
                Game.setStorageValue(config.storages.dungeonState, 1)
            end
        else
            player:sendCancelMessage('The dungeon is already in use.')
        end
    end
    return false
end

Keep it mind it will not reset after used, so you have to reset the "dungeonstate" to 0 somehow.
I forgot about setting player storage, try now.
 
Last edited:
Code:
local config = {
    vocations = { -- you need to set your numbers from vocations.xml
        {1, 5}, -- sorc
        {2, 6}, -- druid
        {3, 6}, -- paladin
        {4, 7}, -- knight
    },
    vocStorages = {
        33313, -- sorc
        33314, -- druid
        33315, -- paladin
        33316, -- knight
    },
    storages = {
        inQueue = 33317,
        dungeonState = 33318,
    }
    dungeonPos = Position(1000, 1000, 7)
}
local function insertPlayerIntoQueue(player)
    for i = 1, 4 do
        if table.contains(config.vocations[i], player:getVocation():getId()) then
            Game.setStorageValue(config.vocStorages[i], 1)
        end
    end
    return true
end
function onSay(player, words, param, channel)
    if Game.getStorageValue(config.storages.dungeonState) < 0 then
        Game.getStorageValue(config.storages.dungeonState, 0)
    end
    local words = {'first', '1'}
    if table.contains(words, param) then
        if player:getStorageValue(config.storages.inQueue) == 1 then -- player is in queue but other vocations are missing
          if Game.getStorageValue(config.vocStorages[1]) ~= 1 or Game.getStorageValue(config.vocStorages[2]) ~= 1 or Game.getStorageValue(config.vocStorages[3]) ~= 1 or Game.getStorageValue(config.vocStorages[4]) ~= 1 then
                return player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You are in queue, but one or more vocations are missing.')
            end
        elseif player:getStorageValue(config.storages.inQueue) == 0 then
            if insertPlayerIntoQueue(player) then
                player:setStorageValue(config.storages.inQueue, 1)
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You are in queue now.')
            end
        end
        -- Teleport players to dungeon, if all vocations are ready
        if Game.getStorageValue(dungeonState) == 0 then
            if Game.getStorageValue(config.vocStorages[1]) == 1 and Game.getStorageValue(config.vocStorages[2]) == 1 and Game.getStorageValue(config.vocStorages[3]) == 1 and Game.getStorageValue(config.vocStorages[4]) == 1 then
                for _, players in ipairs(Game.getPlayers()) do
                    if players:getStorageValue(config.storages.inQueue) == 1 then
                        players:teleportTo(config.dungeonPosition)
                        players:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Welcome to dungeon one. This is your team.')
                        players:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
                        players:setStorageValue(config.storages.inQueue, 0)     
                    end
                end
                Game.setStorageValue(config.storages.dungeonState, 1)
            end
        else
            player:sendCancelMessage('The dungeon is already in use.')
        end
    end
    return false
end

Keep it mind it will not reset after used, so you have to reset the "dungeonstate" to 0 somehow.
I forgot about setting player storage, try now.
you have the incorrect variable on line 45, you have dungeonState and not the config.storages.dungeonState
that's why it doesn't work for him.
you could also create a local function to check all vocations & storages with a loop instead of having a massive line that looks nasty, if you care about your code looking good
 
Last edited:
you have the incorrect variable on line 45, you have dungeonState and not the config.storages.dungeonState
that's why it doesn't work for him.
you could also create a local function to check all vocations & storages with a loop instead of having a massive line that looks nasty, if you care about your code looking good
Thank you, didnt see that :D
 
Code:
local config = {
    vocations = { -- you need to set your numbers from vocations.xml
        {1, 5}, -- sorc
        {2, 6}, -- druid
        {3, 6}, -- paladin
        {4, 7}, -- knight
    },
    vocStorages = {
        33313, -- sorc
        33314, -- druid
        33315, -- paladin
        33316, -- knight
    },
    storages = {
        inQueue = 33317,
        dungeonState = 33318,
    }
    dungeonPos = Position(1000, 1000, 7)
}
local function insertPlayerIntoQueue(player)
    for i = 1, 4 do
        if table.contains(config.vocations[i], player:getVocation():getId()) then
            Game.setStorageValue(config.vocStorages[i], 1)
        end
    end
    return true
end
function onSay(player, words, param, channel)
    if Game.getStorageValue(config.storages.dungeonState) < 0 then
        Game.getStorageValue(config.storages.dungeonState, 0)
    end
    local words = {'first', '1'}
    if table.contains(words, param) then
        if player:getStorageValue(config.storages.inQueue) == 1 then -- player is in queue but other vocations are missing
          if Game.getStorageValue(config.vocStorages[1]) ~= 1 or Game.getStorageValue(config.vocStorages[2]) ~= 1 or Game.getStorageValue(config.vocStorages[3]) ~= 1 or Game.getStorageValue(config.vocStorages[4]) ~= 1 then
                return player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You are in queue, but one or more vocations are missing.')
            end
        elseif player:getStorageValue(config.storages.inQueue) == 0 then
            if insertPlayerIntoQueue(player) then
                player:setStorageValue(config.storages.inQueue, 1)
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You are in queue now.')
            end
        end
        -- Teleport players to dungeon, if all vocations are ready
        if Game.getStorageValue(config.dungeonState) == 0 then
            if Game.getStorageValue(config.vocStorages[1]) == 1 and Game.getStorageValue(config.vocStorages[2]) == 1 and Game.getStorageValue(config.vocStorages[3]) == 1 and Game.getStorageValue(config.vocStorages[4]) == 1 then
                for _, players in ipairs(Game.getPlayers()) do
                    if players:getStorageValue(config.storages.inQueue) == 1 then
                        players:teleportTo(config.dungeonPosition)
                        players:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Welcome to dungeon one. This is your team.')
                        players:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
                        players:setStorageValue(config.storages.inQueue, 0)    
                    end
                end
                Game.setStorageValue(config.storages.dungeonState, 1)
            end
        else
            player:sendCancelMessage('The dungeon is already in use.')
        end
    end
    return false
end

Keep it mind it will not reset after used, so you have to reset the "dungeonstate" to 0 somehow.
I forgot about setting player storage, try now.
Code:
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/dungeon.lua:onSay
data/talkactions/scripts/dungeon.lua:29: attempt to compare nil with number
stack traceback:
        [C]: in function '__lt'
        data/talkactions/scripts/dungeon.lua:29: in function <data/talkactions/s
cripts/dungeon.lua:28>
00:36 The dungeon is already in use.
 
added some extra shit like invalid player check, queue table instead of storages (so you dont have to iterate through every single player in the game)
and now it actually checks if the vocation is in queue or not, multiple numbers of a voc could have joined before
untested but should be fine unless i forgot about something
Lua:
local config = {
    vocations = { -- you need to set your numbers from vocations.xml
        {1, 5}, -- sorc
        {2, 6}, -- druid
        {3, 6}, -- paladin
        {4, 7}, -- knight
    },
    vocStorages = {
        33313, -- sorc
        33314, -- druid
        33315, -- paladin
        33316, -- knight
    },
    dungeonState = 33318, --// storage value
    dungeonPos = Position(1000, 1000, 7)
}

queue = queue or {} --// stores names incase of cid invalidation

local function insertPlayerIntoQueue(player)
    local id = player:getVocation():getId()
    local name = player:getName()
    for i = 1, #config.vocations do
        if isInArray(config.vocations[i], id) and not isInArray(queue, name) then
            queue[i] = name
            return true
        end
    end
    return false
end

local function deleteInvalidPlayers()
    local deleted = 0
    for key, name in pairs(queue) do
        local player = Player(name)
        if not player then
            queue[key] = nil
            deleted = deleted + 1
        end
    end
    return deleted
end

--// useless to check for this every time function is executed, so do it whenever the script is loaded instead
if not Game.getStorageValue(config.dungeonState) then
    Game.setStorageValue(config.dungeonState, 0)
end

function onSay(player, words, param, channel)
    if not (param == "first" or param == "1") then
        return false
    end
    --// the queue has lost 1 or more players
    if deleteInvalidPlayers() > 0 then
        for _, name in pairs(queue) do
            --// notify the rest of the players in queue
            Player(name):sendTextMessage(MESSAGE_EVENT_ADVANCE, deleted .. " players are not online and therefore have been removed from the queue.")
        end
    end
    --// the player is in queue but 1+ vocation is missing
    if isInArray(queue, player:getName()) and #queue ~= 4 then
        return player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You are in queue, but one or more vocations are missing.')
    --// attempt to insert player into queue
    elseif insertPlayerIntoQueue(player) then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You are in queue now.')
    --// player's vocation is already in queue, therefore cannot join
    else
        return player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You are unable to join the queue, your vocation is already in the queue.")
    end
    if not Game.getStorageValue(config.dungeonState) == 1 then
        return player:sendCancelMessage('The dungeon is already in use.')
    end
    --// start the dungeon and reset the queue
    if #queue == 4 then
        for _, name in pairs(queue) do
            local tmpPlayer = Player(name)
            if not tmpPlayer then -- this shouldnt happen but wtf anyways
                error("player machine broke")
            end
            tmpPlayer:teleportTo(config.dungeonPos)
            tmpPlayer:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Welcome to dungeon one. This is your team.')
            tmpPlayer:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
        end
        Game.setStorageValue(config.dungeonState, 1)
        queue = {}
    end
    return false
end
 
Last edited:
Solution
added some extra shit like invalid player check, queue table instead of storages (so you dont have to iterate through every single player in the game)
and now it actually checks if the vocation is in queue or not, multiple numbers of a voc could have joined before
untested but should be fine unless i forgot about something
Lua:
local config = {
    vocations = { -- you need to set your numbers from vocations.xml
        {1, 5}, -- sorc
        {2, 6}, -- druid
        {3, 6}, -- paladin
        {4, 7}, -- knight
    },
    vocStorages = {
        33313, -- sorc
        33314, -- druid
        33315, -- paladin
        33316, -- knight
    },
    dungeonState = 33318, --// storage value
    dungeonPos = Position(1000, 1000, 7)
}

queue = queue or {} --// stores names incase of cid invalidation

local function insertPlayerIntoQueue(player)
    local id = player:getVocation():getId()
    for i = 1, #config.vocations do
        if isInArray(config.vocations[i], id) and not isInArray(queue, i) then
            queue[i] = player:getName()
            return true
        end
    end
    return false
end

local function deleteInvalidPlayers()
    local deleted = 0
    for key, name in pairs(queue) do
        local player = Player(name)
        if not player then
            queue[key] = nil
            deleted = deleted + 1
        end
    end
    return deleted
end

--// useless to check for this every time function is executed, so do it whenever the script is loaded instead
if not Game.getStorageValue(config.dungeonState) then
    Game.getStorageValue(config.dungeonState, 0)
end

function onSay(player, words, param, channel)
    if not (param == "first" or param == "1") then
        return false
    end
    --// the queue has lost 1 or more players
    if deleteInvalidPlayers() > 0 then
        for _, name in pairs(queue) do
            --// notify the rest of the players in queue
            Player(name):sendTextMessage(MESSAGE_EVENT_ADVANCE, deleted .. " players are not online and therefore have been removed from the queue.")
        end
    end
    --// the player is in queue but 1+ vocation is missing
    if isInArray(queue, player:getName()) and #queue ~= 4 then
        return player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You are in queue, but one or more vocations are missing.')
    --// attempt to insert player into queue
    elseif insertPlayerIntoQueue(player) then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You are in queue now.')
    --// player's vocation is already in queue, therefore cannot join
    else
        return player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You are unable to join the queue, your vocation is already in the queue.")
    end
    if not Game.getStorageValue(config.dungeonState) == 1 then
        return player:sendCancelMessage('The dungeon is already in use.')
    end
    --// start the dungeon and reset the queue
    if #queue == 4 then
        for _, tmpPlayer in pairs(queue) do
            tmpPlayer:teleportTo(config.dungeonPosition)
            tmpPlayer:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Welcome to dungeon one. This is your team.')
            tmpPlayer:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
        end
        Game.setStorageValue(config.dungeonState, 1)
        queue = {}
    end
    return false
end
Code:
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/dungeon.lua:onSay
data/talkactions/scripts/dungeon.lua:74: attempt to call method 'teleportTo' (a
nil value)
stack traceback:
        [C]: in function 'teleportTo'
        data/talkactions/scripts/dungeon.lua:74: in function <data/talkactions/s
cripts/dungeon.lua:47>
house leave code
house leave house count:4
 
Code:
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/dungeon.lua:onSay
data/talkactions/scripts/dungeon.lua:74: attempt to call method 'teleportTo' (a
nil value)
stack traceback:
        [C]: in function 'teleportTo'
        data/talkactions/scripts/dungeon.lua:74: in function <data/talkactions/s
cripts/dungeon.lua:47>
house leave code
house leave house count:4
updated my post
figured i forgot something, forgot to reconstruct player with the saved name in the queue
 
updated my post
figured i forgot something, forgot to reconstruct player with the saved name in the queue
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/dungeon.lua:eek:nSay
attempt to index a nil value
stack traceback:
[C]: at 0x013f3689e0
[C]: in function 'teleportTo'
data/talkactions/scripts/dungeon.lua:79: in function <data/talkactions/
cripts/dungeon.lua:48>
 
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/dungeon.lua:eek:nSay
attempt to index a nil value
stack traceback:
[C]: at 0x013f3689e0
[C]: in function 'teleportTo'
data/talkactions/scripts/dungeon.lua:79: in function <data/talkactions/
cripts/dungeon.lua:48>
that shouldn't happen, you sure you re copied everything?
if it was nil it would throw error and say "player machine broke"
 
that shouldn't happen, you sure you re copied everything?
if it was nil it would throw error and say "player machine broke"
changed
tmpPlayer:teleportTo(config.dungeonPosition)
to
tmpPlayer:teleportTo(config.dungeonPos)
 
Last edited:
changed
tmpPlayer:teleportTo(config.dungeonPosition)
to
tmpPlayer:teleportTo(config.dungeonPos)
now working.
But if three players are in queue two are teleported
re edited, i forgot to change the way players were inserted into queue
maybe you had multiple mages or something and it overwrote the first player in the queue
 
changed
tmpPlayer:teleportTo(config.dungeonPosition)
to
tmpPlayer:teleportTo(config.dungeonPos)
wrong vocations
vocations = { -- you need to set your numbers from vocations.xml
{3, 6}, -- paladin > 3, 7
{4, 7}, -- knight > 4, 8
now working.
Very very thaks, @Static_ and @Thexamx
happy forever
re edited, i forgot to change the way players were inserted into queue
maybe you had multiple mages or something and it overwrote the first player in the queue
 
Lua:
--// useless to check for this every time function is executed, so do it whenever the script is loaded instead
if not Game.getStorageValue(config.dungeonState) then
    Game.getStorageValue(config.dungeonState, 0)
end

Should be setStorageValue(config.dungeonState, 0).
That was also the problem on the previous versions.
 
Back
Top