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

[REQUEST]Ani quest for 4 players

SixNine

Active Member
Joined
Dec 12, 2018
Messages
442
Reaction score
40
Hello,
i cant find ani script like this, basically it works like this

  1. You can go on this ani just every two hours so if someone went before you, you have to wait 2hours.
  2. Need 4 players for this ani.
  3. Those 4 players have to stand on those 4 tiles to be able to teleport to ani.
34958
  1. If all 4 players stand on those tiles one of them have to click on lever and then it teleports to that ani.
  2. All those 4 players teleports to different (x,y,z)
  3. You can pick just one item from the chest.
TFS 1.2
 
Last edited:
Solution
Well yea it looks like i used wrong id in the map. But now
View attachment 35146
You probably didn't write the position right in one of the positions.fromPosition. This edit will stop the error and tell you which one.
Lua:
local positions = {
    {fromPosition = Position(1102, 1391, 11), toPosition = Position(1101, 1407, 11)},
    {fromPosition = Position(1103, 1391, 11), toPosition = Position(1102, 1407, 11)},
    {fromPosition = Position(1104, 1391, 11), toPosition = Position(1103, 1407, 11)},
    {fromPosition = Position(1105, 1391, 11), toPosition = Position(1104, 1407, 11)}
}

local demons = {
    [1] = Position(1101, 1405, 11),
    [2] = Position(1103, 1405, 11),
    [3] = Position(1102, 1409, 11),
    [4] = Position(1104, 1409, 11)...
I made this a while ago so not sure how well it'll work, let me know if it does. You can edit the positions and duration to fit your needs. The parts in annihilator chests the lines where it says 'if item.uid ==' is the unique ids that are set for the chests. Also there is no need to add demons into the spawn, this script will summon and remove them.

annihilator lever
Lua:
local positions = {
    {fromPosition = Position(1102, 1391, 11), toPosition = Position(1101, 1407, 11)},
    {fromPosition = Position(1103, 1391, 11), toPosition = Position(1102, 1407, 11)},
    {fromPosition = Position(1104, 1391, 11), toPosition = Position(1103, 1407, 11)},
    {fromPosition = Position(1105, 1391, 11), toPosition = Position(1104, 1407, 11)}
}

local demons = {
    [1] = Position(1101, 1405, 11),
    [2] = Position(1103, 1405, 11),
    [3] = Position(1102, 1409, 11),
    [4] = Position(1104, 1409, 11),
    [5] = Position(1105, 1407, 11),
    [6] = Position(1106, 1407, 11)
}

local pull_pos = Position(1105, 1391, 11)

local duration = 30 -- in minutes

local function resetAnnihilator(uid)
    local item = Item(uid)
    if item.itemid == 1946 then
        item:transform(1945)
    end
    for i = 1, #demons do
        local creatures = Tile(demons[i]):getCreatures()
        for key, creature in pairs(creatures) do
            if creature:getName() == "Demon" then
                creature:remove()
            end
        end
    end
    for key, value in pairs(positions) do
        local creatures = Tile(value.toPosition):getCreatures()
        for k, creature in pairs(creatures) do
            if creature:getName() == "Demon" then
                creature:remove()
            end
        end
    end
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == 1945 then
        local players = {}
        for i = 1, #positions do
            if positions[i].fromPosition == pull_pos and player:getPosition() ~= pull_pos then
                player:sendTextMessage(MESSAGE_INFO_DESCR, 'You are in the wrong position.')
                return false
            end

            local creature = Tile(positions[i].fromPosition):getBottomCreature()
            if creature then
                local temp_player = creature:getPlayer()
                if not temp_player then
                    player:sendTextMessage(MESSAGE_INFO_DESCR, creature:getName()..' is not a valid participant.')
                    return false
                end

                if temp_player:getLevel() < 100 then
                    player:sendTextMessage(MESSAGE_INFO_DESCR, 'Some players are under the required level 100.')
                    return false
                end
                

                players[#players + 1] = temp_player
            end
        end

        if #players ~= 4 then
            player:sendTextMessage(MESSAGE_INFO_DESCR, 'You do not have the required amount of players.')
            return false
        end

        for i = 1, #players do
            local temp_player = players[i]
            if creature then
                players[i]:teleportTo(positions[i].toPosition)
                positions[i].toPosition:sendMagicEffect(CONST_ME_TELEPORT)
            end
        end

        for i = 1, #demons do
            doSummonCreature('Demon', demons[i], false, true)
        end
        
        item:transform(1946)
        addEvent(resetAnnihilator, duration*60*1000, item.uid)
    else
        player:sendTextMessage(MESSAGE_INFO_DESCR, 'Someone has recently started this quest, the cooldown is '..duration..' minutes.')
        return false
    end
    return true
end

annihilator chests
Lua:
local storage_id = 5310

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local storage = player:getStorageValue(storage_id)
    if storage > 0 then
        return player:sendTextMessage(MESSAGE_INFO_DESCR, "It is empty.")
    end

    local reward_id
    if item.uid == 5306 then
        reward_id = 2494 -- Demon Armor
    elseif item.uid == 5307 then
        reward_id = 2400 -- Magic Sword
    elseif item.uid == 5308 then
        reward_id = 2431 -- Stonecutter Axe
    elseif item.uid == 5309 then
        reward_id = 2421 -- Thunder Armor
    end

    local reward_type = ItemType(reward_id)
    if reward_type then
        if player:addItem(reward_id, 1, false, 1, CONST_SLOT_WHEREEVER) then
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You have found a " .. reward_type:getName():lower() .. ".")
            player:setStorageValue(storage_id, 1)
        else
            local weight = reward_type:getWeight()
            player:sendTextMessage(MESSAGE_INFO_DESCR, 'You have found an item weighing ' .. weight / 100 .. ' oz it\'s too heavy or you do not have enough room.')
        end
    end
    return true
end
 
I made this a while ago so not sure how well it'll work, let me know if it does. You can edit the positions and duration to fit your needs. The parts in annihilator chests the lines where it says 'if item.uid ==' is the unique ids that are set for the chests. Also there is no need to add demons into the spawn, this script will summon and remove them.

annihilator lever
Lua:
local positions = {
    {fromPosition = Position(1102, 1391, 11), toPosition = Position(1101, 1407, 11)},
    {fromPosition = Position(1103, 1391, 11), toPosition = Position(1102, 1407, 11)},
    {fromPosition = Position(1104, 1391, 11), toPosition = Position(1103, 1407, 11)},
    {fromPosition = Position(1105, 1391, 11), toPosition = Position(1104, 1407, 11)}
}

local demons = {
    [1] = Position(1101, 1405, 11),
    [2] = Position(1103, 1405, 11),
    [3] = Position(1102, 1409, 11),
    [4] = Position(1104, 1409, 11),
    [5] = Position(1105, 1407, 11),
    [6] = Position(1106, 1407, 11)
}

local pull_pos = Position(1105, 1391, 11)

local duration = 30 -- in minutes

local function resetAnnihilator(uid)
    local item = Item(uid)
    if item.itemid == 1946 then
        item:transform(1945)
    end
    for i = 1, #demons do
        local creatures = Tile(demons[i]):getCreatures()
        for key, creature in pairs(creatures) do
            if creature:getName() == "Demon" then
                creature:remove()
            end
        end
    end
    for key, value in pairs(positions) do
        local creatures = Tile(value.toPosition):getCreatures()
        for k, creature in pairs(creatures) do
            if creature:getName() == "Demon" then
                creature:remove()
            end
        end
    end
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == 1945 then
        local players = {}
        for i = 1, #positions do
            if positions[i].fromPosition == pull_pos and player:getPosition() ~= pull_pos then
                player:sendTextMessage(MESSAGE_INFO_DESCR, 'You are in the wrong position.')
                return false
            end

            local creature = Tile(positions[i].fromPosition):getBottomCreature()
            if creature then
                local temp_player = creature:getPlayer()
                if not temp_player then
                    player:sendTextMessage(MESSAGE_INFO_DESCR, creature:getName()..' is not a valid participant.')
                    return false
                end

                if temp_player:getLevel() < 100 then
                    player:sendTextMessage(MESSAGE_INFO_DESCR, 'Some players are under the required level 100.')
                    return false
                end
               

                players[#players + 1] = temp_player
            end
        end

        if #players ~= 4 then
            player:sendTextMessage(MESSAGE_INFO_DESCR, 'You do not have the required amount of players.')
            return false
        end

        for i = 1, #players do
            local temp_player = players[i]
            if creature then
                players[i]:teleportTo(positions[i].toPosition)
                positions[i].toPosition:sendMagicEffect(CONST_ME_TELEPORT)
            end
        end

        for i = 1, #demons do
            doSummonCreature('Demon', demons[i], false, true)
        end
       
        item:transform(1946)
        addEvent(resetAnnihilator, duration*60*1000, item.uid)
    else
        player:sendTextMessage(MESSAGE_INFO_DESCR, 'Someone has recently started this quest, the cooldown is '..duration..' minutes.')
        return false
    end
    return true
end

annihilator chests
Lua:
local storage_id = 5310

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local storage = player:getStorageValue(storage_id)
    if storage > 0 then
        return player:sendTextMessage(MESSAGE_INFO_DESCR, "It is empty.")
    end

    local reward_id
    if item.uid == 5306 then
        reward_id = 2494 -- Demon Armor
    elseif item.uid == 5307 then
        reward_id = 2400 -- Magic Sword
    elseif item.uid == 5308 then
        reward_id = 2431 -- Stonecutter Axe
    elseif item.uid == 5309 then
        reward_id = 2421 -- Thunder Armor
    end

    local reward_type = ItemType(reward_id)
    if reward_type then
        if player:addItem(reward_id, 1, false, 1, CONST_SLOT_WHEREEVER) then
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You have found a " .. reward_type:getName():lower() .. ".")
            player:setStorageValue(storage_id, 1)
        else
            local weight = reward_type:getWeight()
            player:sendTextMessage(MESSAGE_INFO_DESCR, 'You have found an item weighing ' .. weight / 100 .. ' oz it\'s too heavy or you do not have enough room.')
        end
    end
    return true
end
What about that lever
 
What about that lever
positions.fromPosition = The 4 tiles players are standing on when they pull the lever
positions.toPosition = The 4 tiles the players will be teleported to
demons = The positions the demons will be spawned at
pull_pos = The positions of the lever
duration = How long until the annihilator resets (in minutes)
 
positions.fromPosition = The 4 tiles players are standing on when they pull the lever
positions.toPosition = The 4 tiles the players will be teleported to
demons = The positions the demons will be spawned at
pull_pos = The positions of the lever
duration = How long until the annihilator resets (in minutes)
About installation ani chest goes to "Action", ani level goes to action either?
 
About installation ani chest goes to "Action", ani level goes to action either?
Everything is registered in actions.

Also:
Demon Armor Chest = unique id 5306
Magic Sword Chest = unique id 5307
Stonecutter Axe Chest = 5308
Thunder Armor Chest = 5309

Just attempt to set it up yourself further, you can do it.
 
Everything is registered in actions.

Also:
Demon Armor Chest = unique id 5306
Magic Sword Chest = unique id 5307
Stonecutter Axe Chest = 5308
Thunder Armor Chest = 5309

Just attempt to set it up yourself further, you can do it.
Is it like have to be register like this?
<action fromid="1945" toid="1946" script="quests/ani.lua" />
or
<action itemid="1945" script="quests/ani.lua" />
 
Use an action id for the lever.
Okay so something is not right, installed this script and it says that 19:02 Someone has recently started this quest, the cooldown is 30 minutes.
when server is opened fresh no one did ani. Tested with admin
 
Okay so something is not right, installed this script and it says that 19:02 Someone has recently started this quest, the cooldown is 30 minutes.
when server is opened fresh no one did ani. Tested with admin
Starting lever needs to be id 1945, then it will transform to 1946.
 
Starting lever needs to be id 1945, then it will transform to 1946.
What, how message "Someone has recently started this quest, the cooldown is 30 minutes " have to do with lever id?
<action actionid="1573" script="quests/ani.lua" />
and inside
local pull_pos = Position(543, 722, 7) lever position
and thats the id of lever
if item.itemid == 1946 then
item:transform(1945)
everything is fine it just something not right with code
 
What, how message "Someone has recently started this quest, the cooldown is 30 minutes " have to do with lever id?
<action actionid="1573" script="quests/ani.lua" />
and inside
local pull_pos = Position(543, 722, 7) lever position
and thats the id of lever
if item.itemid == 1946 then
item:transform(1945)
everything is fine it just something not right with code
The code is fine, you are messing up the id of the lever. I gave you a working script, I cannot help more. If you're going to be running a server you need to know how to set something up without someone leading you. If you get an actual error, I'll be happy to help.
 
The code is fine, you are messing up the id of the lever. I gave you a working script, I cannot help more. If you're going to be running a server you need to know how to set something up without someone leading you. If you get an actual error, I'll be happy to help.
Well yea it looks like i used wrong id in the map. But now
35146
 
Well yea it looks like i used wrong id in the map. But now
View attachment 35146
You probably didn't write the position right in one of the positions.fromPosition. This edit will stop the error and tell you which one.
Lua:
local positions = {
    {fromPosition = Position(1102, 1391, 11), toPosition = Position(1101, 1407, 11)},
    {fromPosition = Position(1103, 1391, 11), toPosition = Position(1102, 1407, 11)},
    {fromPosition = Position(1104, 1391, 11), toPosition = Position(1103, 1407, 11)},
    {fromPosition = Position(1105, 1391, 11), toPosition = Position(1104, 1407, 11)}
}

local demons = {
    [1] = Position(1101, 1405, 11),
    [2] = Position(1103, 1405, 11),
    [3] = Position(1102, 1409, 11),
    [4] = Position(1104, 1409, 11),
    [5] = Position(1105, 1407, 11),
    [6] = Position(1106, 1407, 11)
}

local pull_pos = Position(1105, 1391, 11)

local duration = 30 -- in minutes

local function resetAnnihilator(uid)
    local item = Item(uid)
    if item.itemid == 1946 then
        item:transform(1945)
    end
    for i = 1, #demons do
        local creatures = Tile(demons[i]):getCreatures()
        for key, creature in pairs(creatures) do
            if creature:getName() == "Demon" then
                creature:remove()
            end
        end
    end
    for key, value in pairs(positions) do
        local creatures = Tile(value.toPosition):getCreatures()
        for k, creature in pairs(creatures) do
            if creature:getName() == "Demon" then
                creature:remove()
            end
        end
    end
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == 1945 then
        local players = {}
        for i = 1, #positions do
            if positions[i].fromPosition == pull_pos and player:getPosition() ~= pull_pos then
                player:sendTextMessage(MESSAGE_INFO_DESCR, 'You are in the wrong position.')
                return false
            end

            local tile = Tile(positions[i].fromPosition)
            if tile then
                local creature = tile:getBottomCreature()
                if creature then
                    local temp_player = creature:getPlayer()
                    if not temp_player then
                        player:sendTextMessage(MESSAGE_INFO_DESCR, creature:getName()..' is not a valid participant.')
                        return false
                    end

                    if temp_player:getLevel() < 100 then
                        player:sendTextMessage(MESSAGE_INFO_DESCR, 'Some players are under the required level 100.')
                        return false
                    end
                   

                    players[#players + 1] = temp_player
                end
            else
                print("Cannot find tile for position " .. positions[i].fromPosition.x .. ", " .. positions[i].fromPosition.y .. ", " .. positions[i].fromPosition.z)
            end
        end

        if #players ~= 4 then
            player:sendTextMessage(MESSAGE_INFO_DESCR, 'You do not have the required amount of players.')
            return false
        end

        for i = 1, #players do
            local temp_player = players[i]
            if creature then
                players[i]:teleportTo(positions[i].toPosition)
                positions[i].toPosition:sendMagicEffect(CONST_ME_TELEPORT)
            end
        end

        for i = 1, #demons do
            doSummonCreature('Demon', demons[i], false, true)
        end
       
        item:transform(1946)
        addEvent(resetAnnihilator, duration*60*1000, item.uid)
    else
        player:sendTextMessage(MESSAGE_INFO_DESCR, 'Someone has recently started this quest, the cooldown is '..duration..' minutes.')
        return false
    end
    return true
end
 
Solution
You probably didn't write the position right in one of the positions.fromPosition. This edit will stop the error and tell you which one.
Lua:
local positions = {
    {fromPosition = Position(1102, 1391, 11), toPosition = Position(1101, 1407, 11)},
    {fromPosition = Position(1103, 1391, 11), toPosition = Position(1102, 1407, 11)},
    {fromPosition = Position(1104, 1391, 11), toPosition = Position(1103, 1407, 11)},
    {fromPosition = Position(1105, 1391, 11), toPosition = Position(1104, 1407, 11)}
}

local demons = {
    [1] = Position(1101, 1405, 11),
    [2] = Position(1103, 1405, 11),
    [3] = Position(1102, 1409, 11),
    [4] = Position(1104, 1409, 11),
    [5] = Position(1105, 1407, 11),
    [6] = Position(1106, 1407, 11)
}

local pull_pos = Position(1105, 1391, 11)

local duration = 30 -- in minutes

local function resetAnnihilator(uid)
    local item = Item(uid)
    if item.itemid == 1946 then
        item:transform(1945)
    end
    for i = 1, #demons do
        local creatures = Tile(demons[i]):getCreatures()
        for key, creature in pairs(creatures) do
            if creature:getName() == "Demon" then
                creature:remove()
            end
        end
    end
    for key, value in pairs(positions) do
        local creatures = Tile(value.toPosition):getCreatures()
        for k, creature in pairs(creatures) do
            if creature:getName() == "Demon" then
                creature:remove()
            end
        end
    end
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == 1945 then
        local players = {}
        for i = 1, #positions do
            if positions[i].fromPosition == pull_pos and player:getPosition() ~= pull_pos then
                player:sendTextMessage(MESSAGE_INFO_DESCR, 'You are in the wrong position.')
                return false
            end

            local tile = Tile(positions[i].fromPosition)
            if tile then
                local creature = tile:getBottomCreature()
                if creature then
                    local temp_player = creature:getPlayer()
                    if not temp_player then
                        player:sendTextMessage(MESSAGE_INFO_DESCR, creature:getName()..' is not a valid participant.')
                        return false
                    end

                    if temp_player:getLevel() < 100 then
                        player:sendTextMessage(MESSAGE_INFO_DESCR, 'Some players are under the required level 100.')
                        return false
                    end
                  

                    players[#players + 1] = temp_player
                end
            else
                print("Cannot find tile for position " .. positions[i].fromPosition.x .. ", " .. positions[i].fromPosition.y .. ", " .. positions[i].fromPosition.z)
            end
        end

        if #players ~= 4 then
            player:sendTextMessage(MESSAGE_INFO_DESCR, 'You do not have the required amount of players.')
            return false
        end

        for i = 1, #players do
            local temp_player = players[i]
            if creature then
                players[i]:teleportTo(positions[i].toPosition)
                positions[i].toPosition:sendMagicEffect(CONST_ME_TELEPORT)
            end
        end

        for i = 1, #demons do
            doSummonCreature('Demon', demons[i], false, true)
        end
      
        item:transform(1946)
        addEvent(resetAnnihilator, duration*60*1000, item.uid)
    else
        player:sendTextMessage(MESSAGE_INFO_DESCR, 'Someone has recently started this quest, the cooldown is '..duration..' minutes.')
        return false
    end
    return true
end
Btw what if i want to add monsters with different names? Since now it will spawn creatures only with name 'Demons"
 
Back
Top