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

[TFS 1.3] Postman Quest, cannot open door

ivvanek

New Member
Joined
Mar 24, 2009
Messages
113
Reaction score
3
Hello there,

I am stuck on 5 mission when you have to open right doors for get the present and return it to npc.

I cannot open these doors.

present.lua
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    item:remove(1)
    toPosition:sendMagicEffect(CONST_ME_POFF)
    player:say("You open the present.", TALKTYPE_MONSTER_SAY)
    return true
end

12:25 You see a closed door. Item ID: 1225, Unique ID: 2156 Position: 32569, 32023, 6

EDIT:
i use in game /a 1 to move 1 sqm to open the chest, and it gives me present, the problem is i cannot open the doors :p i need a storage for it or in my map editor i have to change uniqueid for the doors?
 
Last edited:
Solution
Going further from before.. I still think it's the actionid.
From your other post here.. it shows mission 5 having storage of 12454.
Try changing the actionid on that door to that, and it should open/close like you are intending.
It's probably in doors.lua somewhere using the wrong storage number again, or needs to be added.
 
/action/scripts/other/doors.lua
Code:
unlockedDoors = { }

local function isDoorLocked(keyId, position)
    if keyId == 0 then
        return false
    end

    if unlockedDoors[keyId] then
        for i = 1, #unlockedDoors[keyId] do
            if position == unlockedDoors[keyId][i] then
                return false
            end
        end
    end

    return true
end

local function toggleDoorLock(doorItem, locked)
    local doorId = doorItem:getId()
    local keyId = doorItem:getActionId()
    local doorPosition = doorItem:getPosition()

    if locked then
        for i = #unlockedDoors[keyId], 1, -1 do
            if unlockedDoors[keyId][i] == doorPosition then
                table.remove(unlockedDoors[keyId], i)
            end
        end

        if not doors[doorId] then
            doorItem:transform(doorId - 1)
        end
        return
    end

    if not unlockedDoors[keyId] then
        unlockedDoors[keyId] = {}
    end

    doorItem:transform(doors[doorId])
    unlockedDoors[keyId][#unlockedDoors[keyId] + 1] = doorPosition
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local itemId, actionId = item:getId(), item:getActionId()
    if isInArray(questDoors, itemId) then
        if player:getStorageValue(actionId) ~= -1 then
            item:transform(itemId + 1)
            player:teleportTo(toPosition, true)
        else
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "The door seems to be sealed against unwanted intruders.")
        end
        return true

    elseif isInArray(levelDoors, itemId) then
        if actionId > 0 and player:getLevel() >= actionId - 1000 then
            item:transform(itemId + 1)
            player:teleportTo(toPosition, true)
        else
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Only the worthy may pass.")
        end
        return true

    elseif isInArray(keys, itemId) then
        if not target
                or not target:isItem()
                or not target:getType():isDoor()
                or Tile(toPosition):getHouse() then
            return false
        end

        local targetId = target:getId()
        if isInArray(openSpecialDoors, targetId)
                or isInArray(questDoors, targetId)
                or isInArray(levelDoors, targetId) then
            return false
        end

        local targetActionId = target:getActionId()
        if targetActionId > 0 and actionId == targetActionId then
            if not isDoorLocked(targetActionId, toPosition) then
                toggleDoorLock(target, true)
            elseif doors[targetId] then
                toggleDoorLock(target, false)
            end
        else
            player:sendCancelMessage("The key does not match.")
        end

        return true
    end

    if isInArray(horizontalOpenDoors, itemId) or isInArray(verticalOpenDoors, itemId) then
        local doorCreature = Tile(toPosition):getTopCreature()
        if doorCreature then
            toPosition.x = toPosition.x + 1
            local query = Tile(toPosition):queryAdd(doorCreature, bit.bor(FLAG_IGNOREBLOCKCREATURE, FLAG_PATHFINDING))
            if query ~= RETURNVALUE_NOERROR then
                toPosition.x = toPosition.x - 1
                toPosition.y = toPosition.y + 1
                query = Tile(toPosition):queryAdd(doorCreature, bit.bor(FLAG_IGNOREBLOCKCREATURE, FLAG_PATHFINDING))
            end

            if query ~= RETURNVALUE_NOERROR then
                player:sendCancelMessage(query)
                return true
            end

            doorCreature:teleportTo(toPosition, true)
        end
        if not isInArray(openSpecialDoors, itemId) then
            item:transform(itemId - 1)
        end
        return true
    end

    if doors[itemId] then
        if not isDoorLocked(actionId, toPosition) then
            item:transform(doors[itemId])
        else
            player:sendTextMessage(MESSAGE_INFO_DESCR, "It is locked.")
        end
        return true
    end

    return false
end
 
12:25 You see a closed door. Item ID: 1225, Unique ID: 2156 Position: 32569, 32023, 6
Change Unique ID to Action ID in the map editor.
 
Last edited:
check that your port id is not added in global.lua

Lua:
doors = {
    [1209] = 1211, [1210] = 1211, [1212] = 1214, [1213] = 1214, [1219] = 1220, [1221] = 1222, [1231] = 1233, [1232] = 1233, [1234] = 1236,
    [1235] = 1236, [1237] = 1238, [1239] = 1240, [1249] = 1251, [1250] = 1251, [1252] = 1254, [1253] = 1254, [1539] = 1540, [1541] = 1542,
    [3535] = 3537, [3536] = 3537, [3538] = 3539, [3544] = 3546, [3545] = 3546, [3547] = 3548, [4913] = 4915, [4914] = 4915, [4916] = 4918,
    [4917] = 4918, [5082] = 5083, [5084] = 5085, [5098] = 5100, [5099] = 5100, [5101] = 5102, [5107] = 5109, [5108] = 5109, [5110] = 5111,
    [5116] = 5118, [5117] = 5118, [5119] = 5120, [5125] = 5127, [5126] = 5127, [5128] = 5129, [5134] = 5136, [5135] = 5136, [5137] = 5139,
    [5138] = 5139, [5140] = 5142, [5141] = 5142, [5143] = 5145, [5144] = 5145, [5278] = 5280, [5279] = 5280, [5281] = 5283, [5282] = 5283,
    [5284] = 5285, [5286] = 5287, [5515] = 5516, [5517] = 5518, [5732] = 5734, [5733] = 5734, [5735] = 5737, [5736] = 5737, [6192] = 6194,
    [6193] = 6194, [6195] = 6197, [6196] = 6197, [6198] = 6199, [6200] = 6201, [6249] = 6251, [6250] = 6251, [6252] = 6254, [6253] = 6254,
    [6255] = 6256, [6257] = 6258, [6795] = 6796, [6797] = 6798, [6799] = 6800, [6801] = 6802, [6891] = 6893, [6892] = 6893, [6894] = 6895,
    [6900] = 6902, [6901] = 6902, [6903] = 6904, [7033] = 7035, [7034] = 7035, [7036] = 7037, [7042] = 7044, [7043] = 7044, [7045] = 7046,
    [7054] = 7055, [7056] = 7057, [8541] = 8543, [8542] = 8543, [8544] = 8546, [8545] = 8546, [8547] = 8548, [8549] = 8550, [9165] = 9167,
    [9166] = 9167, [9168] = 9170, [9169] = 9170, [9171] = 9172, [9173] = 9174, [9267] = 9269, [9268] = 9269, [9270] = 9272, [9271] = 9272,
    [9273] = 9274, [9275] = 9276, [10276] = 10277, [10274] = 10275, [10268] = 10270, [10269] = 10270, [10271] = 10273, [10272] = 10273, [10471] = 10472,
    [10480] = 10481, [10477] = 10479, [10478] = 10479, [10468] = 10470, [10469] = 10470, [10775] = 10777, [10776] = 10777, [12092] = 12094, [12093] = 12094,
    [12188] = 12190, [12189] = 12190, [19840] = 19842, [19841] = 19842, [19843] = 19844, [19980] = 19982, [19981] = 19982, [19983] = 19984, [20273] = 20275,
    [20274] = 20275, [20276] = 20277, [17235] = 17236, [18208] = 18209, [13022] = 13023, [10784] = 10786, [10785] = 10786, [12099] = 12101, [12100] = 12101,
    [12197] = 12199, [12198] = 12199, [19849] = 19851, [19850] = 19851, [19852] = 19853, [19989] = 19991, [19990] = 19991, [19992] = 19993, [20282] = 20284,
    [20283] = 20284, [20285] = 20286, [17237] = 17238, [13020] = 13021, [10780] = 10781, [12095] = 12096, [12195] = 12196, [19845] = 19846, [19985] = 19986,
    [20278] = 20279, [10789] = 10790, [12102] = 12103, [12204] = 12205, [19854] = 19855, [19994] = 19995, [20287] = 20288, [10782] = 10783, [12097] = 12098,
    [12193] = 12194, [19847] = 19848, [19987] = 19988, [20280] = 20281, [10791] = 10792, [12104] = 12105, [12202] = 12203, [19856] = 19857, [19996] = 19997,
    [20289] = 20290, [22814] = 22815, [22815] = 22816, [22817] = 22818, [22819] = 22820, [22823] = 22825, [22824] = 22825, [22826] = 22827, [22828] = 22829
}

because in doors.lua blocks the doors that are there, doors.lua line 118

Code:
if doors[itemId] then
        if not isDoorLocked(actionId, toPosition) then
            item:transform(doors[itemId])
        else
            player:sendTextMessage(MESSAGE_INFO_DESCR, "It is locked.")
        end
        return true
    end
 
Going further from before.. I still think it's the actionid.
From your other post here.. it shows mission 5 having storage of 12454.
Try changing the actionid on that door to that, and it should open/close like you are intending.
 
Solution
Back
Top