• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Help Wall does not disappear [TFS 1.2]

flaviiojr

Active Member
Joined
Jan 20, 2017
Messages
230
Solutions
13
Reaction score
39
By killing the "parasite" creature 4 times next to the wall, the wall does not disappear ...
Could you help me figure out why you're not removing the wall? Thank you very much in advance!

Lua:
local positions = {
    Position(33097, 31976, 11),
    Position(33097, 31977, 11),
    Position(33097, 31978, 11),
    Position(33097, 31979, 11)
}

local barrierPositions = {
    Position(33098, 31976, 11),
    Position(33098, 31977, 11),
    Position(33098, 31978, 11),
    Position(33098, 31979, 11)
}

local function clearArena()
    local spectators = Game.getSpectators(Position(33114, 31956, 11), false, false, 10, 10, 13, 13)
    local exitPosition = Position(33011, 31937, 11)
    for i = 1, #spectators do
        local spectator = spectators[i]
        if spectator:isPlayer() then
            spectator:teleportTo(exitPosition)
            exitPosition:sendMagicEffect(CONST_ME_TELEPORT)
            spectator:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You were teleported out by the gnomish emergency device.')
            return
        end
        spectator:remove()
    end
end

function onKill(creature, target)
    if not target:isMonster() or target:getName():lower() ~= 'parasite' or Game.getStorageValue(GlobalStorage.Weeper) >= 1 then
        return true
    end

    local barrier, targetPosition = false, target:getPosition()
    for i = 1, #positions do
        if targetPosition == positions[i] then
            barrier = true
            break
        end
    end

    if not barrier then
        return true
    end

    local tile, item
    for i = 1, #barrierPositions do
        tile = Tile(barrierPositions[i])
        if tile then
            item = tile:getItemById(18459)
            if item then
                item:remove()
                addEvent(function(itemid, count, position) Game.createItem(itemid, count, position), 30 * 60 * 1000, 18459, 1, barrier[i])
            end

            item = tile:getItemById(18460)
            if item then
                item:transform(19461)
            end
        end
    end

    Game.setStorageValue(GlobalStorage.Weeper, 1)
    addEvent(Game.setStorageValue, 30 * 60 * 1000, GlobalStorage.Weeper, 0)
    Game.createMonster('gnomevil', Position(33114, 31953, 11))
    addEvent(clearArena, 32 * 60 * 1000)

    return true
end
 
Try with this:
Lua:
local positions = {
    Position(33097, 31976, 11),
    Position(33097, 31977, 11),
    Position(33097, 31978, 11),
    Position(33097, 31979, 11)
}


local barrierPositions = {
    Position(33098, 31976, 11),
    Position(33098, 31977, 11),
    Position(33098, 31978, 11),
    Position(33098, 31979, 11)
}

local function clearArena()
    local spectators = Game.getSpectators(Position(33114, 31956, 11), false, false, 10, 10, 13, 13)
    local exitPosition = Position(33011, 31937, 11)
    for i = 1, #spectators do
        local spectator = spectators[i]
        if spectator:isPlayer() then
            spectator:teleportTo(exitPosition)
            exitPosition:sendMagicEffect(CONST_ME_TELEPORT)
            spectator:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You were teleported out by the gnomish emergency device.')
        else
            spectator:remove()
        end
    end
end

function onKill(creature, target)
    local targetMonster = target:getMonster()
    if not targetMonster then
        return true
    end

    if targetMonster:getName():lower() ~= 'parasite' or Game.getStorageValue(GlobalStorage.Weeper) >= 1 then
        return true
    end

    local targetPosition = targetMonster:getPosition()
    local barrier = false
    for i = 1, #positions do
        if targetPosition == positions[i] then
            barrier = true
            break
        end
    end

    if not barrier then
        return true
    end

    local last = false
    local tile, item
    for i = 1, #barrierPositions do
        tile = Tile(barrierPositions[i])
        if tile then
            item = tile:getItemById(18459)
            if item then
                item:transform(19460)
            end

            item = tile:getItemById(18460)
            if item then
                item:transform(19461)
            end
        end
    end

    if not last then
        return true
    end

    Game.setStorageValue(GlobalStorage.Weeper, 1)
    addEvent(Game.setStorageValue, 30 * 60 * 1000, GlobalStorage.Weeper, 0)
    Game.createMonster('gnomevil', Position(33114, 31953, 11))
    addEvent(clearArena, 32 * 60 * 1000)
    return true
end
 
didn't work :(
thanks for answering @Dyabl0 !
I'm trying to understand this script to see where the error is, but I'm new to it, understanding this and where the error is, it's a great learning ...
 
The fact it will not properly is because the wall does not get the last Weeper killed, try with this:

Lua:
local positions = {
    Position(33097, 31976, 11),
    Position(33097, 31977, 11),
    Position(33097, 31978, 11),
    Position(33097, 31979, 11)
}


local barrierPositions = {
    Position(33098, 31976, 11),
    Position(33098, 31977, 11),
    Position(33098, 31978, 11),
    Position(33098, 31979, 11)
}

local function clearArena()
    local spectators = Game.getSpectators(Position(33114, 31956, 11), false, false, 10, 10, 13, 13)
    local exitPosition = Position(33011, 31937, 11)
    for i = 1, #spectators do
        local spectator = spectators[i]
        if spectator:isPlayer() then
            spectator:teleportTo(exitPosition)
            exitPosition:sendMagicEffect(CONST_ME_TELEPORT)
            spectator:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You were teleported out by the gnomish emergency device.')
        else
            spectator:remove()
        end
    end
end

function onKill(creature, target)
    local targetMonster = target:getMonster()
    if not targetMonster then
        return true
    end

    if targetMonster:getName():lower() ~= 'parasite' or Game.getStorageValue(GlobalStorage.Weeper) >= 1 then
        return true
    end

    local targetPosition = targetMonster:getPosition()
    local barrier = false
    for i = 1, #positions do
        if targetPosition == positions[i] then
            barrier = true
            break
        end
    end

    if not barrier then
        return true
    end

    local last = false
    local tile, item
    for i = 1, #barrierPositions do
        tile = Tile(barrierPositions[i])
        if tile then
            item = tile:getItemById(18459)
            if item then
                item:transform(19460)
            end

            item = tile:getItemById(18460)
            if item then
                item:transform(19461)
            end

            elseif(getTileItemById(barrier[i], 18459).uid > 0) then
                doRemoveItem(getTileItemById(barrier[i], 18461).uid, 1)
                addEvent(doCreateItem, 30 * 60 * 1000, 18459, 1, barrier[i])
                last = true
            end
        end
    end

    if not last then
        return true
    end

    Game.setStorageValue(GlobalStorage.Weeper, 1)
    addEvent(Game.setStorageValue, 30 * 60 * 1000, GlobalStorage.Weeper, 0)
    Game.createMonster('gnomevil', Position(33114, 31953, 11))
    addEvent(clearArena, 32 * 60 * 1000)
    return true
end
 
This error appears now:

IQRwiBw.png


thanks, @Dyabl0

------------------- EDIT ----------------------------
I fixed the error, but even then the walls do not turn or disappear
 
Last edited:
The fact it will not properly is because the wall does not get the last Weeper killed, try with this:

Lua:
local positions = {
    Position(33097, 31976, 11),
    Position(33097, 31977, 11),
    Position(33097, 31978, 11),
    Position(33097, 31979, 11)
}


local barrierPositions = {
    Position(33098, 31976, 11),
    Position(33098, 31977, 11),
    Position(33098, 31978, 11),
    Position(33098, 31979, 11)
}

local function clearArena()
    local spectators = Game.getSpectators(Position(33114, 31956, 11), false, false, 10, 10, 13, 13)
    local exitPosition = Position(33011, 31937, 11)
    for i = 1, #spectators do
        local spectator = spectators[i]
        if spectator:isPlayer() then
            spectator:teleportTo(exitPosition)
            exitPosition:sendMagicEffect(CONST_ME_TELEPORT)
            spectator:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You were teleported out by the gnomish emergency device.')
        else
            spectator:remove()
        end
    end
end

function onKill(creature, target)
    local targetMonster = target:getMonster()
    if not targetMonster then
        return true
    end

    if targetMonster:getName():lower() ~= 'parasite' or Game.getStorageValue(GlobalStorage.Weeper) >= 1 then
        return true
    end

    local targetPosition = targetMonster:getPosition()
    local barrier = false
    for i = 1, #positions do
        if targetPosition == positions[i] then
            barrier = true
            break
        end
    end

    if not barrier then
        return true
    end

    local last = false
    local tile, item
    for i = 1, #barrierPositions do
        tile = Tile(barrierPositions[i])
        if tile then
            item = tile:getItemById(18459)
            if item then
                item:transform(19460)
            end

            item = tile:getItemById(18460)
            if item then
                item:transform(19461)
            end

            elseif(getTileItemById(barrier[i], 18459).uid > 0) then
                doRemoveItem(getTileItemById(barrier[i], 18461).uid, 1)
                addEvent(doCreateItem, 30 * 60 * 1000, 18459, 1, barrier[i])
                last = true
            end
        end
    end

    if not last then
        return true
    end

    Game.setStorageValue(GlobalStorage.Weeper, 1)
    addEvent(Game.setStorageValue, 30 * 60 * 1000, GlobalStorage.Weeper, 0)
    Game.createMonster('gnomevil', Position(33114, 31953, 11))
    addEvent(clearArena, 32 * 60 * 1000)
    return true
end

Ehm?
Lua:
            elseif(getTileItemById(barrier[i], 18459).uid > 0) then
                doRemoveItem(getTileItemById(barrier[i], 18461).uid, 1)
                addEvent(doCreateItem, 30 * 60 * 1000, 18459, 1, barrier[i])
                last = true
            end

Why did you add this? barrier, barrier is a boolean not a table.
The if statment is also already executed on line 60 except with diffrent itemids.
For others coming here for the errors, note that it's an end and then an elseif, elseif statments uses the parent if statment's end, so the fix is to remove the end at line 67.

This should work;
Lua:
local positions = {
    Position(33097, 31976, 11),
    Position(33097, 31977, 11),
    Position(33097, 31978, 11),
    Position(33097, 31979, 11)
}

local barrierPositions = {
    Position(33098, 31976, 11),
    Position(33098, 31977, 11),
    Position(33098, 31978, 11),
    Position(33098, 31979, 11)
}

local function clearArena()
    local spectators = Game.getSpectators(Position(33114, 31956, 11), false, false, 10, 10, 13, 13)
    local exitPosition = Position(33011, 31937, 11)
    for i = 1, #spectators do
        local spectator = spectators[i]
        if spectator:isPlayer() then
            spectator:teleportTo(exitPosition)
            exitPosition:sendMagicEffect(CONST_ME_TELEPORT)
            spectator:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You were teleported out by the gnomish emergency device.')
        else
            spectator:remove()
        end
    end
end

local function removeWall(itemid, count, position, itemUid)
    local targetWall = Item(itemUid)
    if targetWall then
        targetWall:remove()
    end
    Game.createItem(itemid, count, position)
end

function onKill(creature, target)
    local targetMonster = target:getMonster()
    if not targetMonster then
        return true
    end

    if targetMonster:getName():lower() ~= 'parasite' or Game.getStorageValue(GlobalStorage.Weeper) >= 1 then
        return true
    end

    local targetPosition = targetMonster:getPosition()
    local barrier = false
    for i = 1, #positions do
        if targetPosition == positions[i] then
            barrier = true
            break
        end
    end

    if not barrier then
        return true
    end

    local last = false
    local tile, item
    for i = 1, #barrierPositions do
        tile = Tile(barrierPositions[i])
        if tile then
            item = tile:getItemById(18459)
            if item then
                item:transform(19460)
                addEvent(removeWall, 30 * 60 * 1000, 18459, 1, barrierPositions[i], item:getUniqueId())
                last = true
            end

            item = tile:getItemById(18460)
            if item then
                item:transform(19461)
            end
        end
    end

    if not last then
        return true
    end

    Game.setStorageValue(GlobalStorage.Weeper, 1)
    addEvent(Game.setStorageValue, 30 * 60 * 1000, GlobalStorage.Weeper, 0)
    Game.createMonster('gnomevil', Position(33114, 31953, 11))
    addEvent(clearArena, 32 * 60 * 1000)
    return true
end

The wall has to have the itemid: 18459
If it does, it will transform into 19460
Then a scheduled event will be executed after 30 seconds, removing 19460 and adding back 18459.
 
Still does not work, I kill the "parasites" alongside the barriers, but they do not disappear or transform...
Thank you for your help, @WibbenZ
 
Lua:
local positions = {
    Position(33097, 31976, 11),
    Position(33097, 31977, 11),
    Position(33097, 31978, 11),
    Position(33097, 31979, 11)
}

local barrierPositions = {
    Position(33098, 31976, 11),
    Position(33098, 31977, 11),
    Position(33098, 31978, 11),
    Position(33098, 31979, 11)
}

local function clearArena()
    local spectators = Game.getSpectators(Position(33114, 31956, 11), false, false, 10, 10, 13, 13)
    local exitPosition = Position(33011, 31937, 11)
    for i = 1, #spectators do
        local spectator = spectators[i]
        if spectator:isPlayer() then
            spectator:teleportTo(exitPosition)
            exitPosition:sendMagicEffect(CONST_ME_TELEPORT)
            spectator:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You were teleported out by the gnomish emergency device.')
        else
            spectator:remove()
        end
    end
end

local function removeWall(itemid, count, position, itemUid)
    local targetWall = Item(itemUid)
    if targetWall then
        targetWall:remove()
    end
    Game.createItem(itemid, count, position)
end

function onKill(creature, target)
    print("onKill")
    local targetMonster = target:getMonster()
    if not targetMonster then
        print("1")
        return true
    end

    if targetMonster:getName():lower() ~= 'parasite' or Game.getStorageValue(GlobalStorage.Weeper) >= 1 then
        print("2")
        return true
    end

    local targetPosition = targetMonster:getPosition()
    local barrier = false
    for i = 1, #positions do
        if targetPosition == positions[i] then
            barrier = true
            break
        end
    end

    if not barrier then
        print("3")
        return true
    end

    local last = false
    local tile, item
    for i = 1, #barrierPositions do
        tile = Tile(barrierPositions[i])
        if tile then
            item = tile:getItemById(18459)
            if item then
                item:transform(19460)
                addEvent(removeWall, 30 * 60 * 1000, 18459, 1, barrierPositions[i], item:getUniqueId())
                last = true
            end

            item = tile:getItemById(18460)
            if item then
                item:transform(19461)
            end
        end
    end

    if not last then
        print("4")
        return true
    end

    Game.setStorageValue(GlobalStorage.Weeper, 1)
    addEvent(Game.setStorageValue, 30 * 60 * 1000, GlobalStorage.Weeper, 0)
    Game.createMonster('gnomevil', Position(33114, 31953, 11))
    addEvent(clearArena, 32 * 60 * 1000)
    print("5")
    return true
end
 
Lua:
local positions = {
    Position(33097, 31976, 11),
    Position(33097, 31977, 11),
    Position(33097, 31978, 11),
    Position(33097, 31979, 11)
}

local barrierPositions = {
    Position(33098, 31976, 11),
    Position(33098, 31977, 11),
    Position(33098, 31978, 11),
    Position(33098, 31979, 11)
}

local function clearArena()
    local spectators = Game.getSpectators(Position(33114, 31956, 11), false, false, 10, 10, 13, 13)
    local exitPosition = Position(33011, 31937, 11)
    for i = 1, #spectators do
        local spectator = spectators[i]
        if spectator:isPlayer() then
            spectator:teleportTo(exitPosition)
            exitPosition:sendMagicEffect(CONST_ME_TELEPORT)
            spectator:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You were teleported out by the gnomish emergency device.')
        else
            spectator:remove()
        end
    end
end

local function removeWall(itemid, count, position, itemUid)
    local targetWall = Item(itemUid)
    if targetWall then
        targetWall:remove()
    end
    Game.createItem(itemid, count, position)
end

function onKill(creature, target)
    print("onKill")
    local targetMonster = target:getMonster()
    if not targetMonster then
        print("1")
        return true
    end

    if targetMonster:getName():lower() ~= 'parasite' or Game.getStorageValue(GlobalStorage.Weeper) >= 1 then
        print("2")
        return true
    end

    local targetPosition = targetMonster:getPosition()
    local barrier = false
    for i = 1, #positions do
        if targetPosition == positions[i] then
            barrier = true
            break
        end
    end

    if not barrier then
        print("3")
        return true
    end

    local last = false
    local tile, item
    for i = 1, #barrierPositions do
        tile = Tile(barrierPositions[i])
        if tile then
            item = tile:getItemById(18459)
            if item then
                item:transform(19460)
                addEvent(removeWall, 30 * 60 * 1000, 18459, 1, barrierPositions[i], item:getUniqueId())
                last = true
            end

            item = tile:getItemById(18460)
            if item then
                item:transform(19461)
            end
        end
    end

    if not last then
        print("4")
        return true
    end

    Game.setStorageValue(GlobalStorage.Weeper, 1)
    addEvent(Game.setStorageValue, 30 * 60 * 1000, GlobalStorage.Weeper, 0)
    Game.createMonster('gnomevil', Position(33114, 31953, 11))
    addEvent(clearArena, 32 * 60 * 1000)
    print("5")
    return true
end

GEtTCh9.png


By killing a creature by the side of the wall, it all disappears at once ... should work as follows:
When killing the first parasite next to the wall would occur a transformation:
Lua:
            item = tile:getItemById(18459)
            if item then
                item:transform(18460)
                last = true
            end
When killing the second parasite next to the wall would occur a transformation:
Lua:
            item = tile:getItemById(18460)
            if item then
                item:transform(18461)
            end
By killing the third parasite by the side of the wall, the wall would disappear, giving access to the portal to the boss ...

And without abuse, I wanted to add some time to summon the boss ...
thank you very much, @WibbenZ
 
Either the monster name is wrong, the global storage isn't set (make prints of these 2 to see what the problem is)
And make sure the positions are correct, since it did once go to no. 5 but didnt change the walls.
 
Back
Top