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

TalkAction Dungeon with que system (need all vocs)

gigastar

Member
Joined
Jan 25, 2009
Messages
252
Reaction score
15
Its based like WoW. You need all vocs (though wow is not all). It is basic, sorry. If you want a advanced one PM me and REP. Then send me everything you can on specific needs so I can be as specific as possible in the script.

Lua:
---------------Pos of dungeon start----------------
local dungeon_one_pos = {x = 1000, y = 1000, z = 7}
---------------Tell server if dungeons are open-------
local dungeon_one_open = 33311

----------Tells server what vocs are in que---------
local knight_in_que = 33313
local sorc_in_que = 33314
local paladin_in_que = 33315
local druid_in_que = 33316
----Tells server players that are in que--------
local in_que_one = 33317
---------------------------
local isSorc = 1, 5, 9
local isDruid = 2, 6, 10
local isPaladin = 3, 6, 11
local isKnight = 4, 7, 12
--------Helps me script----------
local getGlobalStorage = getGlobalStorageValue
local getVocation = getPlayerVocation
local sendTextMessage = doPlayerSendTextMessage
local sendMagicEffect = doSendMagicEffect
local getPlayerStorage = getPlayerStorageValue


function onSay(cid, words, param, channel)
if (getGlobalStorage(dungeon_one_open) == nil) then
	setGlobalStorageValue(dungeon_one_open, 0)
end

if (param == "1" or param == "first") then         ------------------This part is if player uses talkaction again, after being qued into the dungeon--------------
	if (getPlayerStorage(cid, in_que_1) == 1) then
		if (getVocation(cid) == isSorc)) then
			if (getGlobalStorage(knight_in_que) ~= 1) then
				if (getGlobalStorage(druid_in_que) ~= 1) then
					if (getGlobalStorage(paladin_in_que) ~= 1) then
						sendTextMessage(cid, 22, "Waiting for all vocations.")
					return false
					else
						sendTextMessage(cid, 22, "waiting for a druid and a knight.")
					return false
					end
				else
					sendTextMessage(cid, 22, "Waiting for a knight.")
				return false
				end
			end
			
	elseif (getVocation(cid) == isDruid) then
		if (getGlobalStorage(knight_in_que) ~= 1) then
			if (getGlobalStorage(sorc_in_que) ~= 1) then
				if (getGlobalStorage(paladin_in_que) ~= 1) then
					sendTextMessage(cid, 22, "Waiting for all vocations.")
				return false
				else
					sendTextMessage(cid, 22, "waiting for a sorcerer and a knight.")
				return false
				end
			else
				sendTextMessage(cid, 22, "Waiting for a knight.")
			return false
			end
		end
	elseif (getVocation(cid) == isPaladin) then
		if (getGlobalStorage(knight_in_que) ~= 1) then
			if (getGlobalStorage(sorc_in_que) ~= 1) then
				if (getGlobalStorage(druid_in_que) ~= 1) then
					sendTextMessage(cid, 22, "Waiting for all vocations.")
				return false
				else
					sendTextMessage(cid, 22, "waiting for a sorcerer and a knight.")
				return false
				end
			else
				sendTextMessage(cid, 22, "Waiting for a knight.")
			return false
			end
		end
	elseif (getVocation(cid) == isKnight) then
		if (getGlobalStorage(druid_in_que) ~= 1) then
			if (getGlobalStorage(sorc_in_que) ~= 1) then
				if (getGlobalStorage(paladin_in_que) ~= 1) then
					sendTextMessage(cid, 22, "Waiting for all vocations.")
				return false
				else
					sendTextMessage(cid, 22, "waiting for a sorcerer and a druid.")
				return false
				end
			else
				sendTextMessage(cid, 22, "Waiting for a druid.")
			return false
			end
		end
else
if (getVocation(cid) == isSorc) then ----------------------This is main script--------------------------
		if (getGlobalStorage(dungeon_one_open) == 0) then
			if	(getGlobalStorage(knight_in_que) == 1) then
				if (getGlobalStorage(paladin_in_que) == 1) then
					if (getGlobalStorage(druid_in_que) == 1) then
						if (getGlobalStorage(sorc_in_que) == 0) then
									setPlayerStorageValue(cid, in_que_1, 1)
							for i, pid in ipairs(getPlayersOnline()) do 
							------------------Auto dungeon starter-----------------
								if (getPlayerStorage(pid, in_que_one) == 1) then
									doTeleportThing(pid, dungeon_one_pos)
									sendTextMessage(pid, 22, "Welcome to dungeon one. This is your team.")
									sendMagicEffect(pid, math.random(1, 20))
									setGlobalStorageValue(dungeon_one_open, 1)
									setPlayerStorageValue(pid, in_que_1, 0)							
								end
							end
						else
							doPlayerSendCancel(cid, "There is already a Sorcerer qued in this dungeon.")
						return false
						end
					else
						doPlayerSendTextMessage(cid, 22, "You have been qued, you will be teleported when there is a full team.")
						setPlayerStorageValue(cid, in_que_1, 1)
					return false
					end
				else
					doPlayerSendTextMessage(cid, 22, "You have been qued, you will be teleported when there is a full team.")
					setPlayerStorageValue(cid, in_que_1, 1)
				return false
				end
			else
				doPlayerSendTextMessage(cid, 22, "You have been qued, you will be teleported when there is a full team.")
				setPlayerStorageValue(cid, in_que_1, 1)
			return false
			end
		else
			doPlayerSendCancel(cid, "The dungeon is already in use.")
		return false
		end
elseif (getVocation(cid) == isDruid) then ------------------Reapeat script for each voc.------------
		if (getGlobalStorage(dungeon_one_open) == 0) then
			if	(getGlobalStorage(sorc_in_que) == 1) then
				if (getGlobalStorage(paladin_in_que) == 1) then
					if (getGlobalStorage(knight_in_que) == 1) then
						if (getGlobalStorage(druid_in_que) == 0) then
									setPlayerStorageValue(cid, in_que_one, 1)
							for i, pid in ipairs(getPlayersOnline()) do 
								if (getPlayerStorage(pid, in_que_one) == 1) then
									doTeleportThing(pid, dungeon_one_pos)
									sendTextMessage(pid, 22, "Welcome to dungeon one. This is your team.")
									sendMagicEffect(pid, math.random(1, 20))
									setGlobalStorageValue(dungeon_one_open, 1)
									
								end
							end
						else
							doPlayerSendCancel(cid, "There is already a Druid qued in this dungeon.")
						return false
						end
					else
						doPlayerSendTextMessage(cid, 22, "You have been qued, you will be teleported when there is a full team.")
						setPlayerStorageValue(cid, in_que_1, 1)
					return false
					end
				else
					doPlayerSendTextMessage(cid, 22, "You have been qued, you will be teleported when there is a full team.")
					setPlayerStorageValue(cid, in_que_1, 1)
				return false
				end
			else
				doPlayerSendTextMessage(cid, 22, "You have been qued, you will be teleported when there is a full team.")
				setPlayerStorageValue(cid, in_que_1, 1)
			return false
			end
		else
			doPlayerSendCancel(cid, "The dungeon is already in use.")
		return false
		end
elseif (getVocation(cid) == isPaladin) then
		if (getGlobalStorage(dungeon_one_open) == 0) then
			if	(getGlobalStorage(knight_in_que) == 1) then
				if (getGlobalStorage(sorc_in_que) == 1) then
					if (getGlobalStorage(druid_in_que) == 1) then
						if (getGlobalStorage(paladin_in_que) == 0) then
									setPlayerStorageValue(cid, in_que_one, 1)
							for i, pid in ipairs(getPlayersOnline()) do 
								if (getPlayerStorage(pid, in_que_one) == 1) then
									doTeleportThing(pid, dungeon_one_pos)
									sendTextMessage(pid, 22, "Welcome to dungeon one. This is your team.")
									sendMagicEffect(pid, math.random(1, 20))
									setGlobalStorageValue(dungeon_one_open, 1)
									
								end
							end
						else
							doPlayerSendCancel(cid, "There is already a Paladin qued in this dungeon.")
						return false
						end
					else
						doPlayerSendTextMessage(cid, 22, "You have been qued, you will be teleported when there is a full team.")
						setPlayerStorageValue(cid, in_que_1, 1)
					return false
					end
				else
					doPlayerSendTextMessage(cid, 22, "You have been qued, you will be teleported when there is a full team.")
					setPlayerStorageValue(cid, in_que_1, 1)
				return false
				end
			else
				doPlayerSendTextMessage(cid, 22, "You have been qued, you will be teleported when there is a full team.")
				setPlayerStorageValue(cid, in_que_1, 1)
			return false
			end
		else
			doPlayerSendCancel(cid, "The dungeon is already in use.")
		return false
		end
elseif (getVocation(cid) == isKnight) then
		if (getGlobalStorage(dungeon_one_open) == 0) then
			if (getGlobalStorage(paladin_in_que) == 1) then
				if (getGlobalStorage(sorc_in_que) == 1) then
					if (getGlobalStorage(druid_in_que) == 1) then
						if (getGlobalStorage(knight_in_que) == 0) then
									setPlayerStorageValue(cid, in_que_one, 1)
							for i, pid in ipairs(getPlayersOnline()) do 
								if (getPlayerStorage(pid, in_que_one) == 1) then
									doTeleportThing(pid, dungeon_one_pos)
									sendTextMessage(pid, 22, "Welcome to dungeon one. This is your team.")
									sendMagicEffect(pid, math.random(1, 20))
									setGlobalStorageValue(dungeon_one_open, 1)
								end
							end
						else
							doPlayerSendCancel(cid, "There is already a Paladin qued in this dungeon.")
						return false
						end
					else
						doPlayerSendTextMessage(cid, 22, "You have been qued, you will be teleported when there is a full team.")
						setPlayerStorageValue(cid, in_que_1, 1)
					return false
					end
				else
					doPlayerSendTextMessage(cid, 22, "You have been qued, you will be teleported when there is a full team.")
					setPlayerStorageValue(cid, in_que_1, 1)
				return false
				end
			else
				doPlayerSendTextMessage(cid, 22, "You have been qued, you will be teleported when there is a full team.")
				setPlayerStorageValue(cid, in_que_1, 1)
			return false
			end
		else
			doPlayerSendCancel(cid, "The dungeon is already in use.")
		return false
		end
end
end
end
return true
end

Usage:
Code:
!dungeon 1
 
Very nice, this can be the base for an Elemental Quest with 4 players of each vocation xD!
 
Updated to TFS 1.3. Keep in mind you need to create code so if the players get out of the dungeon the storages are set back to -1 to open them back up to other groups.

Lua:
local vocations = { -- You can add custom vocations here --
    [1] = "Sorcerer",
    [2] = "Druid",
    [3] = "Paladin",
    [4] = "Knight"
}

local vocQueues = {
    "Sorcerer" = {},
    "Druid" = {},
    "Paladin" = {},
    "Knight" = {},
}

local dungeonName = "Serpant Survival" -- Name of the dungeon --
local dungeonNameArray = {"serpant dungeon", "serpant", "1", "dungeon one", "one"} -- Player can say these words to queue for this dungeon.
local levelReq = 100 -- Players need level 100 to queue for this dungeon. --

local dungeons = { -- You can add multiple of the same dungeons in your map and use this to link the players to them.
    [1] = {storage = 31460, pos = Position(1000, 1000, 7)},
    [2] = {storage = 31461, pos = Position(1000, 1000, 7)},
    [3] = {storage = 31462, pos = Position(1000, 1000, 7)}
} 

local eventStatus = 0 -- Dont touch --

-- Usage: !dungeon 1
-- !dungeon 1 cancel

function onSay(player, words, param, channel)
    if words == "!dungeon" then
  
        local VOC = vocations[player:getBaseVocation()]
              
        if not VOC then print("Code Error in: Dungeon "..dungeonName.." Could not find vocation in vocations array.") return false end
              
        local queueArray = vocQueues[VOC]
              
        if not queueArray then print("Code Error in: Dungeon "..dungeonName.." Could not connect vocation name in vocQueues.") return false end
  
        local t = param:split(",")
        if t[2] then
            if t[2] == "cancel" and isInArray(dungeonNameArray, t[1]) then
                local inQueue = false
              
                for i = 1, #queueArray do
                    if queueArray[i] == player:getName() then
                        queueArray[i] = nil
                        inQueue = true
                        player:sendCancelMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have left the queue")
                        break
                    end
                end
              
                if not inQueue then
                    player:sendCancelMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You were not queued for "..dungeonName..".")
                    return false
                end
            end
        end
  
        if isInArray(dungeonNameArray, param) then
            if player:getLevel() < levelReq then player:sendCancelMessage("You are not high enough level to queue for this dungeon.") return false end
          
            local isInQueue = false
          
            for i = 1, #queueArray do
                if queueArray[i] == player:getName() then
                    isInQueue = true
                    break
                end
            end
              
              
            if not isInQueue then
                queueArray[queueArray + 1] = player:getName()
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have queued in "..dungeonName..". You are behind "..#queueArray.." "..player:getVocation():getName().."'s.")
              
                if eventStatus == 0 then
                    eventStatus = 1
                    addEvent(startDungeon1, 60 * 1000) -- If you do multiple of this script change this and the event name from 1, 2, 3, 4, ect. Otherwise there will be a problem with the code. --
                end
            else
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You are already queued for this dungeon. You are behind "..#queueArray.." "..player:getVocation():getName().."'s.")
            end
        end
    end
return false
end

function startDungeon1()
    local DUNGEON = nil
  
    for i = 1, #dungeons do
        if Game.getStorageValue(dungeons[i].storage) ~= 1 then
            DUNGEON = dungeons[i]
            break
        end
    end
  
    if DUNGEON ~= nil then
        local players = {}
      
        for i = 1, #vocQueues do
            players[vocQueues[i]] = queueArray[vocQueues[i]][1]
        end
          
        if #players < #vocations then
            addEvent(startDungeon1, 60 * 1000)
            return true
        end
      
        for i, v in ipairs(players) do
            local player = Player(v)
          
            if not VOC then print("Code Error in: Dungeon "..dungeonName.." Could not find dungeon player.") return true end
          
            player:setStorageValue(DUNGEON.storage, 1)
            player:teleportTo(DUNGEON.pos)
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, dungeonMsg)
        end
      
        for i = 1, #vocQueues do
            queueArray[vocQueues[i]][1] = nil
        end
      
        for i = 1, #vocations do
            for k, v in ipairs(vocQueue[vocations[i]]) do
                local player = Player(v)
              
                if player then
                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You are now behind "..#vocQueue[vocations[i]].." "..player:getVocation():getName().."'s for the "..dungeonName.." dungeon.")
                end
            end
        end
        addEvent(startDungeon1, 60 * 1000)
    else
        addEvent(startDungeon1, 60 * 1000)
    end
end

You also need to add this in data/lib/core/player.lua
Lua:
local vocCount = 4 -- Change to how many vocation you have --
local promotions = 1 -- How many promotions for each voc --
function Player.getBaseVocation(self)
    local voc = nil
    for i = 1, #promotions do
        if self:getVocation():getId() > (vocCount * i) then
            voc = self:getVocation():getId() - (vocCount * i)
        end
    end
return voc
end
 
Last edited:
Updated to TFS 1.3. Keep in mind you need to create code so if the players get out of the dungeon the storages are set back to -1 to open them back up to other groups.

Lua:
local vocations = { -- You can add custom vocations here --
    [1] = "Sorcerer",
    [2] = "Druid",
    [3] = "Paladin",
    [4] = "Knight"
}

local vocQueues = {
    "Sorcerer" = {},
    "Druid" = {},
    "Paladin" = {},
    "Knight" = {},
}

local dungeonName = "Serpant Survival" -- Name of the dungeon --
local dungeonNameArray = {"serpant dungeon", "serpant", "1", "dungeon one", "one"} -- Player can say these words to queue for this dungeon.
local levelReq = 100 -- Players need level 100 to queue for this dungeon. --

local dungeons = { -- You can add multiple of the same dungeons in your map and use this to link the players to them.
    [1] = {storage = 31460, pos = Position(1000, 1000, 7)},
    [2] = {storage = 31461, pos = Position(1000, 1000, 7)},
    [3] = {storage = 31462, pos = Position(1000, 1000, 7)}
}

local eventStatus = 0 -- Dont touch --

-- Usage: !dungeon 1
-- !dungeon 1 cancel

function onSay(player, words, param, channel)
    if words == "!dungeon" then
 
        local VOC = vocations[player:getBaseVocation()]
             
        if not VOC then print("Code Error in: Dungeon "..dungeonName.." Could not find vocation in vocations array.") return false end
             
        local queueArray = vocQueues[VOC]
             
        if not queueArray then print("Code Error in: Dungeon "..dungeonName.." Could not connect vocation name in vocQueues.") return false end
 
        local t = param:split(",")
        if t[2] then
            if t[2] == "cancel" and isInArray(dungeonNameArray, t[1]) then
                local inQueue = false
             
                for i = 1, #queueArray do
                    if queueArray[i] == player:getName() then
                        queueArray[i] = nil
                        inQueue = true
                        player:sendCancelMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have left the queue")
                        break
                    end
                end
             
                if not inQueue then
                    player:sendCancelMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You were not queued for "..dungeonName..".")
                    return false
                end
            end
        end
 
        if isInArray(dungeonNameArray, param) then
            if player:getLevel() < levelReq then player:sendCancelMessage("You are not high enough level to queue for this dungeon.") return false end
         
            local isInQueue = false
         
            for i = 1, #queueArray do
                if queueArray[i] == player:getName() then
                    isInQueue = true
                    break
                end
            end
             
             
            if not isInQueue then
                queueArray[queueArray + 1] = player:getName()
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have queued in "..dungeonName..". You are behind "..#queueArray.." "..player:getVocation():getName().."'s.")
             
                if eventStatus == 0 then
                    eventStatus = 1
                    addEvent(startDungeon1, 60 * 1000) -- If you do multiple of this script change this and the event name from 1, 2, 3, 4, ect. Otherwise there will be a problem with the code. --
                end
            else
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You are already queued for this dungeon. You are behind "..#queueArray.." "..player:getVocation():getName().."'s.")
            end
        end
    end
return false
end

function startDungeon1()
    local DUNGEON = nil
 
    for i = 1, #dungeons do
        if Game.getStorageValue(dungeons[i].storage) ~= 1 then
            DUNGEON = dungeons[i]
            break
        end
    end
 
    if DUNGEON ~= nil then
        local players = {}
     
        for i = 1, #vocQueues do
            players[vocQueues[i]] = queueArray[vocQueues[i]][1]
        end
         
        if #players < #vocations then
            addEvent(startDungeon1, 60 * 1000)
            return true
        end
     
        for i, v in ipairs(players) do
            local player = Player(v)
         
            if not VOC then print("Code Error in: Dungeon "..dungeonName.." Could not find dungeon player.") return true end
         
            player:setStorageValue(DUNGEON.storage, 1)
            player:teleportTo(DUNGEON.pos)
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, dungeonMsg)
        end
     
        for i = 1, #vocQueues do
            queueArray[vocQueues[i]][1] = nil
        end
     
        for i = 1, #vocations do
            for k, v in ipairs(vocQueue[vocations[i]]) do
                local player = Player(v)
             
                if player then
                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You are now behind "..#vocQueue[vocations[i]].." "..player:getVocation():getName().."'s for the "..dungeonName.." dungeon.")
                end
            end
        end
        addEvent(startDungeon1, 60 * 1000)
    else
        addEvent(startDungeon1, 60 * 1000)
    end
end

You also need to add this in data/lib/core/player.lua
Lua:
local vocCount = 4 -- Change to how many vocation you have --
local promotions = 1 -- How many promotions for each voc --
function Player.getBaseVocation(self)
    local voc = nil
    for i = 1, #promotions do
        if self:getVocation():getId() > (vocCount * i) then
            voc = self:getVocation():getId() - (vocCount * i)
        end
    end
return voc
end

local vocationId = player:getVocation():getBase():getId()
 
Back
Top