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

Door bug Black Tek Server

sarab

New Member
Joined
Sep 15, 2017
Messages
7
Reaction score
3
Olá pessoal, estou com esse bug nas portas, compilei o Black Tek 1.0 e deu esse bug em todas as portas.Olá pessoal, estou com esse bug nas portas, compilei o Black Tek 1.0 e deu esse bug em todas as portas, sou meio leigo e não sei como resolver isso, abro a porta e ela vira outra porta com um ID diferente, tipo a porta com ID 1221 era para virar 1214 e não 1220, não sei se vocês entenderam bem o problema.
 

Attachments

This has already been fixed. Did you download main branch or 1.0 release?


To be specific
 
Last edited:
Olá pessoal, estou com esse bug nas portas, compilei o Black Tek 1.0 e deu esse bug em todas as portas.Olá pessoal, estou com esse bug nas portas, compilei o Black Tek 1.0 e deu esse bug em todas as portas, sou meio leigo e não sei como resolver isso, abro a porta e ela vira outra porta com um ID diferente, tipo a porta com ID 1221 era para virar 1214 e não 1220, não sei se vocês entenderam bem o problema.
Envie-nos o arquivo data/global.lua
Post automatically merged:

Have you edited the data\scripts\actions\others\doors.lua ?
Não tem nada a ver com o problema que você mencionou
Você está reclamando da mudança da porta para um ID diferente do ID normal. Você pode ajustar isso no arquivo data/global.lua.
Post automatically merged:

Se o seu problema é com orientações, aqui está a solução
LUA:
local positionOffsets = {
    {x = 1, y = 0}, -- east
    {x = 0, y = 1}, -- south
    {x = 1, y = 0}, -- west
    {x = 0, y = 1}, -- north
}

local function findPushPosition(creature, round)
    local pos = creature:getPosition()
    for _, offset in ipairs(positionOffsets) do
        local offsetPosition = pos + offset
        local tile = Tile(offsetPosition)
        if tile then
            local creatureCount = tile:getCreatureCount()
            if round == 1 then
                if tile:queryAdd(creature) == RETURNVALUE_NOERROR and creatureCount == 0 then
                    if not tile:hasFlag(TILESTATE_PROTECTIONZONE) or (tile:hasFlag(TILESTATE_PROTECTIONZONE) and creature:canAccessPz()) then
                        return offsetPosition
                    end
                end
            elseif round == 2 then
                if creatureCount > 0 then
                    if not tile:hasFlag(TILESTATE_PROTECTIONZONE) or (tile:hasFlag(TILESTATE_PROTECTIONZONE) and creature:canAccessPz()) then
                        return offsetPosition
                    end
                end
            elseif round == 3 then
                local topItem = tile:getTopDownItem()
                if topItem then
                    if topItem:getType():isMovable() then
                        return offsetPosition
                    end
                end
            else
                if tile:getItemById(ITEM_MAGICWALL) or tile:getItemById(ITEM_WILDGROWTH) then
                    return offsetPosition
                end
            end
        end
    end
    if round < 4 then
        return findPushPosition(creature, round + 1)
    end
end

local door = Action()

function door.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local itemId = item:getId()
    if table.contains(closedQuestDoors, itemId) then
        if player:getStorageValue(item.actionid) ~= -1 or player:getGroup():getAccess() 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 table.contains(closedLevelDoors, itemId) then
        if item.actionid > 0 and player:getLevel() >= item.actionid - actionIds.levelDoor or player:getGroup():getAccess() then
            item:transform(itemId + 1)
            player:teleportTo(toPosition, true)
        else
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Only the worthy may pass.")
        end
        return true
    elseif table.contains(keys, itemId) then
        local tile = Tile(toPosition)
        if not tile then
            return false
        end
        target = tile:getTopVisibleThing()
        if target.actionid == 0 then
            return false
        end
        if table.contains(keys, target.itemid) then
            return false
        end
        if not table.contains(openDoors, target.itemid) and not table.contains(closedDoors, target.itemid) and not table.contains(lockedDoors, target.itemid) then
            return false
        end
        if item.actionid ~= target.actionid then
            player:sendTextMessage(MESSAGE_STATUS_SMALL, "The key does not match.")
            return true
        end
        local transformTo = target.itemid + 2
        if table.contains(openDoors, target.itemid) then
            transformTo = target.itemid - 2
        elseif table.contains(closedDoors, target.itemid) then
            transformTo = target.itemid - 1
        end
        target:transform(transformTo)
        return true
    elseif table.contains(lockedDoors, itemId) then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "It is locked.")
        return true   
    elseif table.contains(openDoors, itemId) or table.contains(openExtraDoors, itemId) or table.contains(openHouseDoors, itemId) then
        local creaturePositionTable = {}
        local doorCreatures = Tile(toPosition):getCreatures()
        if doorCreatures and #doorCreatures > 0 then
            for _, doorCreature in pairs(doorCreatures) do
                local pushPosition = findPushPosition(doorCreature, 1)
                if not pushPosition then
                    player:sendCancelMessage(RETURNVALUE_NOTENOUGHROOM)
                    return true
                end
                table.insert(creaturePositionTable, {creature = doorCreature, position = pushPosition})
            end
            for _, tableCreature in ipairs(creaturePositionTable) do
                tableCreature.creature:teleportTo(tableCreature.position, true)
            end
        end
    
        item:transform(itemId - 1)
        return true   
    elseif table.contains(closedDoors, itemId) or table.contains(closedExtraDoors, itemId) or table.contains(closedHouseDoors, itemId) then
        item:transform(itemId + 1)
        return true
    end
    return false
end

local doorTables = {keys, openDoors, closedDoors, lockedDoors, openExtraDoors, closedExtraDoors, openHouseDoors, closedHouseDoors, closedQuestDoors, closedLevelDoors}
for _, doors in pairs(doorTables) do
    for _, doorId in pairs(doors) do
        door:id(doorId)
    end
end
door:register()
 
Last edited:
Isso já foi corrigido. Você baixou o branch principal ou a versão 1.0?


Para ser específico
Baixei a versão BlackTek-Server-1.0.Windows
Post automatically merged:

Envie-nos o arquivo data/global.lua
Post automatically merged:


Não tem nada a ver com o problema que você mencionou
Você está reclamando da mudança da porta para um ID diferente do ID normal. Você pode ajustar isso no arquivo data/global.lua.
Post automatically merged:

Se o seu problema é com orientações, aqui está a solução
LUA:
local positionOffsets = {
    {x = 1, y = 0}, -- east
    {x = 0, y = 1}, -- south
    {x = 1, y = 0}, -- west
    {x = 0, y = 1}, -- north
}

local function findPushPosition(creature, round)
    local pos = creature:getPosition()
    for _, offset in ipairs(positionOffsets) do
        local offsetPosition = pos + offset
        local tile = Tile(offsetPosition)
        if tile then
            local creatureCount = tile:getCreatureCount()
            if round == 1 then
                if tile:queryAdd(creature) == RETURNVALUE_NOERROR and creatureCount == 0 then
                    if not tile:hasFlag(TILESTATE_PROTECTIONZONE) or (tile:hasFlag(TILESTATE_PROTECTIONZONE) and creature:canAccessPz()) then
                        return offsetPosition
                    end
                end
            elseif round == 2 then
                if creatureCount > 0 then
                    if not tile:hasFlag(TILESTATE_PROTECTIONZONE) or (tile:hasFlag(TILESTATE_PROTECTIONZONE) and creature:canAccessPz()) then
                        return offsetPosition
                    end
                end
            elseif round == 3 then
                local topItem = tile:getTopDownItem()
                if topItem then
                    if topItem:getType():isMovable() then
                        return offsetPosition
                    end
                end
            else
                if tile:getItemById(ITEM_MAGICWALL) or tile:getItemById(ITEM_WILDGROWTH) then
                    return offsetPosition
                end
            end
        end
    end
    if round < 4 then
        return findPushPosition(creature, round + 1)
    end
end

local door = Action()

function door.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local itemId = item:getId()
    if table.contains(closedQuestDoors, itemId) then
        if player:getStorageValue(item.actionid) ~= -1 or player:getGroup():getAccess() 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 table.contains(closedLevelDoors, itemId) then
        if item.actionid > 0 and player:getLevel() >= item.actionid - actionIds.levelDoor or player:getGroup():getAccess() then
            item:transform(itemId + 1)
            player:teleportTo(toPosition, true)
        else
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Only the worthy may pass.")
        end
        return true
    elseif table.contains(keys, itemId) then
        local tile = Tile(toPosition)
        if not tile then
            return false
        end
        target = tile:getTopVisibleThing()
        if target.actionid == 0 then
            return false
        end
        if table.contains(keys, target.itemid) then
            return false
        end
        if not table.contains(openDoors, target.itemid) and not table.contains(closedDoors, target.itemid) and not table.contains(lockedDoors, target.itemid) then
            return false
        end
        if item.actionid ~= target.actionid then
            player:sendTextMessage(MESSAGE_STATUS_SMALL, "The key does not match.")
            return true
        end
        local transformTo = target.itemid + 2
        if table.contains(openDoors, target.itemid) then
            transformTo = target.itemid - 2
        elseif table.contains(closedDoors, target.itemid) then
            transformTo = target.itemid - 1
        end
        target:transform(transformTo)
        return true
    elseif table.contains(lockedDoors, itemId) then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "It is locked.")
        return true 
    elseif table.contains(openDoors, itemId) or table.contains(openExtraDoors, itemId) or table.contains(openHouseDoors, itemId) then
        local creaturePositionTable = {}
        local doorCreatures = Tile(toPosition):getCreatures()
        if doorCreatures and #doorCreatures > 0 then
            for _, doorCreature in pairs(doorCreatures) do
                local pushPosition = findPushPosition(doorCreature, 1)
                if not pushPosition then
                    player:sendCancelMessage(RETURNVALUE_NOTENOUGHROOM)
                    return true
                end
                table.insert(creaturePositionTable, {creature = doorCreature, position = pushPosition})
            end
            for _, tableCreature in ipairs(creaturePositionTable) do
                tableCreature.creature:teleportTo(tableCreature.position, true)
            end
        end
  
        item:transform(itemId - 1)
        return true 
    elseif table.contains(closedDoors, itemId) or table.contains(closedExtraDoors, itemId) or table.contains(closedHouseDoors, itemId) then
        item:transform(itemId + 1)
        return true
    end
    return false
end

local doorTables = {keys, openDoors, closedDoors, lockedDoors, openExtraDoors, closedExtraDoors, openHouseDoors, closedHouseDoors, closedQuestDoors, closedLevelDoors}
for _, doors in pairs(doorTables) do
    for _, doorId in pairs(doors) do
        door:id(doorId)
    end
end
door:register()
this is the global.lua of the server


LUA:
math.randomseed(os.time())
dofile('data/lib/lib.lua')

ropeSpots = {
    384, 418, 8278, 8592, 13189, 14435, 14436, 14857, 15635, 19518, 24621, 24622, 24623, 24624, 26019
}

keys = {
    2086, 2087, 2088, 2089, 2090, 2091, 2092, 10032
}

openDoors = {
    1211, 1214, 1233, 1236, 1251, 1254, 3546, 3537, 4915, 4918, 5100, 5109, 5118, 5127, 5136, 5139, 5142,
    5145, 5280, 5283, 5734, 5737, 6194, 6197, 6251, 6254, 6893, 6902, 7035, 7044, 8543, 8546, 9167, 9170,
    9269, 9272, 10270, 10273, 10470, 10479, 10777, 10786, 12094, 12101, 12190, 12199, 19842, 19851, 19982,
    19991, 20275, 20284, 22816, 22825, 25285, 25292
}
closedDoors = {
    1210, 1213, 1232, 1235, 1250, 1253, 3536, 3545, 4914, 4917, 5099, 5108, 5117, 5126, 5135, 5138, 5141,
    5144, 5279, 5282, 5733, 5736, 6193, 6196, 6250, 6253, 6892, 6901, 7034, 7043, 8542, 8545, 9166, 9169,
    9268, 9271, 10269, 10272, 10766, 10785, 10469, 10478, 12093, 12100, 12189, 12198, 19841, 19850, 19981,
    19990, 20274, 20283, 22815, 22824, 25284, 25291
}
lockedDoors = {
    1209, 1212, 1231, 1234, 1249, 1252, 3535, 3544, 4913, 4916, 5098, 5107, 5116, 5125, 5134, 5137, 5140,
    5143, 5278, 5281, 5732, 5735, 6192, 6195, 6249, 6252, 6891, 6900, 7033, 7042, 8541, 8544, 9165, 9168,
    9267, 9270, 10268, 10271, 10468, 10477, 10775, 10784, 12092, 12099, 12188, 12197, 19840, 19849, 19980,
    19989, 20273, 20282, 22814, 22823, 25283, 25290
}

openExtraDoors = {
    1540, 1542, 6796, 6798, 6800, 6802, 6960, 6962, 7055, 7057, 12695, 12703, 14635, 17236, 17238, 25159, 25161
}
closedExtraDoors = {
    1539, 1541, 6795, 6797, 6799, 6801, 6959, 6961, 7054, 7056, 12692, 12701, 14633, 17235, 17237, 25158, 25160
}

openHouseDoors = {
    1220, 1222, 1238, 1240, 3539, 3548, 5083, 5085, 5102, 5111, 5120, 5129, 5285, 5287, 5516, 5518, 6199,
    6201, 6256, 6258, 6895, 6904, 7037, 7046, 8548, 8550, 9172, 9174, 9274, 9276, 10275, 10277, 10472, 10481,
    13021, 13023, 18209, 19844, 19853, 19984, 19993, 20277, 20286, 22818, 22827
}
closedHouseDoors = {
    1219, 1221, 1237, 1239, 3538, 3547, 5082, 5084, 5101, 5110, 5119, 5128, 5284, 5286, 5515, 5517, 6198,
    6200, 6255, 6257, 6894, 6903, 7036, 7045, 8547, 8549, 9171, 9173, 9273, 9275, 10274, 10276, 10471, 10480,
    13020, 13022, 18208, 19843, 19852, 19983, 19992, 20276, 20285, 22817, 22826
}

--[[ (Not currently used, but probably useful to keep up to date)
openQuestDoors = {
    1224, 1226, 1242, 1244, 1256, 1258, 3543, 3552, 5106, 5115, 5124, 5133, 5289, 5291, 5746, 5749, 6203,
    6205, 6260, 6262, 6899, 6908, 7041, 7050, 8552, 8554, 9176, 9178, 9278, 9280, 10279, 10281, 10476, 10485,
    10783, 10792, 12098, 12105, 12194, 12203, 19848, 19857, 19988, 19997, 20281, 20290, 22822, 22831, 25163,
    25165, 25289, 25296
}
]]--
closedQuestDoors = {
    1223, 1225, 1241, 1243, 1255, 1257, 3542, 3551, 5105, 5114, 5123, 5132, 5288, 5290, 5745, 5748, 6202,
    6204, 6259, 6261, 6898, 6907, 7040, 7049, 8551, 8553, 9175, 9177, 9277, 9279, 10278, 10280, 10475, 10484,
    10782, 10791, 12097, 12104, 12193, 12202, 19847, 19856, 19987, 19996, 20280, 20289, 22821, 22830, 25162,
    25164, 25288, 25295
}

--[[ (Not currently used, but probably useful to keep up to date)
openLevelDoors = {
    1228, 1230, 1246, 1248, 1260, 1262, 3541, 3550, 5104, 5113, 5122, 5131, 5293, 5295, 6207, 6209, 6264,
    6266, 6897, 6906, 7039, 7048, 8556, 8558, 9180, 9182, 9282, 9284, 10283, 10285, 10474, 10483, 10781,
    10790, 12096, 12103, 12196, 12205, 19846, 19855, 19986, 19995, 20279, 20288, 22820, 22829, 25287, 25294
}
]]--
closedLevelDoors = {
    1227, 1229, 1245, 1247, 1259, 1261, 3540, 3549, 5103, 5112, 5121, 5130, 5292, 5294, 6206, 6208, 6263,
    6265, 6896, 6905, 7038, 7047, 8555, 8557, 9179, 9181, 9281, 9283, 10282, 10284, 10473, 10482, 10780,
    10789, 12095, 12102, 12195, 12204, 19845, 19854, 19985, 19994, 20278, 20287, 22819, 22828, 25286, 25293
}

function getDistanceBetween(firstPosition, secondPosition)
    local xDif = math.abs(firstPosition.x - secondPosition.x)
    local yDif = math.abs(firstPosition.y - secondPosition.y)
    local posDif = math.max(xDif, yDif)
    if firstPosition.z ~= secondPosition.z then
        posDif = posDif + 15
    end
    return posDif
end

function getFormattedWorldTime()
    local worldTime = getWorldTime()
    local hours = math.floor(worldTime / 60)

    local minutes = worldTime % 60
    if minutes < 10 then
        minutes = '0' .. minutes
    end
    return hours .. ':' .. minutes
end

function getLootRandom()
    return math.random(0, MAX_LOOTCHANCE) / configManager.getNumber(configKeys.RATE_LOOT)
end

table.contains = function(array, value)
    for _, targetColumn in pairs(array) do
        if targetColumn == value then
            return true
        end
    end
    return false
end

string.split = function(str, sep)
    local res = {}
    for v in str:gmatch("([^" .. sep .. "]+)") do
        res[#res + 1] = v
    end
    return res
end

string.splitTrimmed = function(str, sep)
    local res = {}
    for v in str:gmatch("([^" .. sep .. "]+)") do
        res[#res + 1] = v:trim()
    end
    return res
end

string.trim = function(str)
    return str:match'^()%s*$' and '' or str:match'^%s*(.*%S)'
end

if not nextUseStaminaTime then
    nextUseStaminaTime = {}
end

function getPlayerDatabaseInfo(name_or_guid)
    local sql_where = ""

    if type(name_or_guid) == 'string' then
        sql_where = "WHERE `p`.`name`=" .. db.escapeString(name_or_guid) .. ""
    elseif type(name_or_guid) == 'number' then
        sql_where = "WHERE `p`.`id`='" .. name_or_guid .. "'"
    else
        return false
    end

    local sql_query = [[
        SELECT
            `p`.`id` as `guid`,
            `p`.`name`,
            CASE WHEN `po`.`player_id` IS NULL
                THEN 0
                ELSE 1
            END AS `online`,
            `p`.`group_id`,
            `p`.`level`,
            `p`.`experience`,
            `p`.`vocation`,
            `p`.`maglevel`,
            `p`.`skill_fist`,
            `p`.`skill_club`,
            `p`.`skill_sword`,
            `p`.`skill_axe`,
            `p`.`skill_dist`,
            `p`.`skill_shielding`,
            `p`.`skill_fishing`,
            `p`.`town_id`,
            `p`.`balance`,
            `gm`.`guild_id`,
            `gm`.`nick`,
            `g`.`name` AS `guild_name`,
            CASE WHEN `p`.`id` = `g`.`ownerid`
                THEN 1
                ELSE 0
            END AS `is_leader`,
            `gr`.`name` AS `rank_name`,
            `gr`.`level` AS `rank_level`,
            `h`.`id` AS `house_id`,
            `h`.`name` AS `house_name`,
            `h`.`town_id` AS `house_town`
        FROM `players` AS `p`
        LEFT JOIN `players_online` AS `po`
            ON `p`.`id` = `po`.`player_id`
        LEFT JOIN `guild_membership` AS `gm`
            ON `p`.`id` = `gm`.`player_id`
        LEFT JOIN `guilds` AS `g`
            ON `gm`.`guild_id` = `g`.`id`
        LEFT JOIN `guild_ranks` AS `gr`
            ON `gm`.`rank_id` = `gr`.`id`
        LEFT JOIN `houses` AS `h`
            ON `p`.`id` = `h`.`owner`
    ]] .. sql_where

    local query = db.storeQuery(sql_query)
    if not query then
        return false
    end

    local info = {
        ["guid"] = result.getNumber(query, "guid"),
        ["name"] = result.getString(query, "name"),
        ["online"] = result.getNumber(query, "online"),
        ["group_id"] = result.getNumber(query, "group_id"),
        ["level"] = result.getNumber(query, "level"),
        ["experience"] = result.getNumber(query, "experience"),
        ["vocation"] = result.getNumber(query, "vocation"),
        ["maglevel"] = result.getNumber(query, "maglevel"),
        ["skill_fist"] = result.getNumber(query, "skill_fist"),
        ["skill_club"] = result.getNumber(query, "skill_club"),
        ["skill_sword"] = result.getNumber(query, "skill_sword"),
        ["skill_axe"] = result.getNumber(query, "skill_axe"),
        ["skill_dist"] = result.getNumber(query, "skill_dist"),
        ["skill_shielding"] = result.getNumber(query, "skill_shielding"),
        ["skill_fishing"] = result.getNumber(query, "skill_fishing"),
        ["town_id"] = result.getNumber(query, "town_id"),
        ["balance"] = result.getNumber(query, "balance"),
        ["guild_id"] = result.getNumber(query, "guild_id"),
        ["nick"] = result.getString(query, "nick"),
        ["guild_name"] = result.getString(query, "guild_name"),
        ["is_leader"] = result.getNumber(query, "is_leader"),
        ["rank_name"] = result.getString(query, "rank_name"),
        ["rank_level"] = result.getNumber(query, "rank_level"),
        ["house_id"] = result.getNumber(query, "house_id"),
        ["house_name"] = result.getString(query, "house_name"),
        ["house_town"] = result.getNumber(query, "house_town")
    }

    result.free(query)
    return info
end

function checkDuplicateStorageKeys(varName)
    local keys = _G[varName]
    if type(keys) ~= "table" then
        return nil, "Error: The provided variable name does not reference a valid table."
    end

    local seen = {}
    local duplicates = {}
    for k, v in pairs(keys) do
        if seen[v] then
            table.insert(duplicates, v)
        else
            seen[v] = true
        end
    end

    if next(duplicates) == nil then
        return false
    else
        return duplicates
    end
end
 
this is the global.lua of the server
O melhor a fazer agora é nos explicar melhor o seu problema, e é melhor fazer um vídeo explicando
The best thing to do now is to explain your problem to us better and it is best to make a video explaining it
 
Just change what's in the commit I linked.

In this file;
Code:
data/scripts/actions/others/doors.lua

Remove
LUA:
or player:getGroup():getAccess()
 
Here is a video that shows how the doors are
O melhor a fazer agora é nos explicar melhor o seu problema, e é melhor fazer um vídeo explicando
The best thing to do now is to explain your problem to us better and it is best to make a video explaining it

Here is a video that shows how the doors are
Post automatically merged:

Just change what's in the commit I linked.

In this file;
Code:
data/scripts/actions/others/doors.lua

Remove
LUA:
or player:getGroup():getAccess()
this is the doors.lua that came with the server


I tried but it didn't work
LUA:
local lockedDoors = {
    1209, 1212, 1231, 1234, 1249, 1252, 3535, 3544, 4913, 4916, 5098, 5107, 5116, 5125, 5134, 5137, 5140,
    5143, 5278, 5281, 5732, 5735, 6192, 6195, 6249, 6252, 6891, 6900, 7033, 7042, 8541, 8544, 9165, 9168,
    9267, 9270, 10268, 10271, 10775, 10784, 12092, 12099, 12188, 12197, 19840, 19849, 19980, 19989, 20273,
    20282, 22814, 22823, 25283, 25290
}

local closedNormalDoors = {
    [1210] = 1211, [1232] = 1233, [1250] = 1251, [3545] = 3546, [4914] = 4915, [5108] = 5109,
    [5126] = 5127, [5141] = 5142, [5144] = 5145, [5282] = 5283, [5736] = 5737, [6193] = 6194,
    [6250] = 6251, [6901] = 6902, [7043] = 7044, [1213] = 1214, [1235] = 1236, [1253] = 1254,
    [3536] = 3537, [4917] = 4918, [5099] = 5100, [5117] = 5118, [5135] = 5136, [5138] = 5139,
    [5279] = 5280, [5733] = 5734, [6196] = 6197, [6253] = 6254, [6892] = 6893, [7034] = 7035,
    [8542] = 8543, [9166] = 9167, [9268] = 9269, [10269] = 10270, [10469] = 10470, [10766] = 10777,
    [12093] = 12094, [12100] = 12101, [12189] = 12190, [19841] = 19842, [19981] = 19982, [20274] = 20275,
    [22815] = 22816, [25284] = 25285
}

local openVerticalDoors = {
    [1211] = 1210, [1233] = 1232, [1251] = 1250, [3546] = 3545, [4915] = 4914, [5109] = 5108,
    [5127] = 5126, [5142] = 5141, [5145] = 5144, [5283] = 5282, [5737] = 5736, [6194] = 6193,
    [6251] = 6250, [6902] = 6901, [7044] = 7043, [8543] = 8542, [9167] = 9166, [9269] = 9268,
    [10270] = 10269, [10470] = 10469, [10777] = 10766, [12094] = 12093, [12101] = 12100, [12190] = 12189,
    [19842] = 19841, [19982] = 19981, [20275] = 20274, [22816] = 22815, [25285] = 25284
}

local openHorizontalDoors = {
    [1214] = 1213, [1236] = 1235, [1254] = 1253, [3537] = 3536, [4918] = 4917, [5100] = 5099,
    [5118] = 5117, [5136] = 5135, [5139] = 5138, [5280] = 5279, [5734] = 5733, [6197] = 6196,
    [6254] = 6253, [6893] = 6892, [7035] = 7034, [8546] = 8545, [9169] = 9168, [9272] = 9271,
    [10273] = 10272, [10479] = 10478, [10786] = 10785, [12101] = 12100, [12199] = 12198, [19851] = 19850,
    [19991] = 19990, [20284] = 20283, [22825] = 22824, [25292] = 25291
}

local levelDoors = {
    [1227] = 1228, [1229] = 1230, [1245] = 1246, [1247] = 1248, [1259] = 1260, [1261] = 1262,
    [3540] = 3541, [3549] = 3550, [5103] = 5104, [5112] = 5113, [5121] = 5122, [5130] = 5131,
    [5292] = 5293, [5294] = 5295, [6206] = 6207, [6208] = 6209, [6263] = 6264, [6265] = 6266,
    [6896] = 6897, [6905] = 6906, [7038] = 7039, [7047] = 7048, [9653] = 9654, [9655] = 9656
}

local questDoors = {
    [1224] = 1223, [1226] = 1225, [1242] = 1241, [1244] = 1243, [1256] = 1255, [1258] = 1257,
    [3543] = 3542, [3552] = 3551, [5106] = 5105, [5115] = 5114, [5124] = 5123, [5133] = 5132,
    [5289] = 5288, [5291] = 5290, [5746] = 5745, [5749] = 5748, [6203] = 6202, [6205] = 6204,
    [6260] = 6259, [6262] = 6261, [6899] = 6898, [6908] = 6907, [7041] = 7040, [7050] = 7049,
    [9650] = 9649, [9652] = 9651
}

local passthrough = {
    [1634] = 1635, [1635] = 1634, [1636] = 1637, [1637] = 1636, [1638] = 1639, [1639] = 1638,
    [1640] = 1641, [1641] = 1640
}

function onUse(player, item, fromPosition, target, toPosition)
    if table.contains(lockedDoors, item:getId()) then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "It is locked.")
        return true
    end

    local closedDoor = closedNormalDoors[item:getId()]
    if closedDoor then
        item:transform(closedDoor, 1)
        return true
    end

    local verticalDoor = openVerticalDoors[item:getId()]
    if verticalDoor then
        local doorCreature = Tile(item:getPosition()):getTopCreature()
        if doorCreature then
            doorCreature:teleportTo(item:getPosition():moveRel(1, 0, 0), true)
        end
        item:transform(verticalDoor, 1)
        return true
    end

    local horizontalDoor = openHorizontalDoors[item:getId()]
    if horizontalDoor then
        local doorCreature = Tile(item:getPosition()):getTopCreature()
        if doorCreature then
            doorCreature:teleportTo(item:getPosition():moveRel(0, 1, 0), true)
        end
        item:transform(horizontalDoor, 1)
        return true
    end

    local levelDoor = levelDoors[item:getId()]
    if levelDoor then
        if item.actionid > 0 and player:getLevel() >= item.actionid - 1000 or player:getGroup():getAccess() then
            player:teleportTo(item:getPosition(), true)
            item:transform(levelDoor, 1)
        else
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You are not worthy.")
        end
        return true
    end

    local questDoor = questDoors[item:getId()]
    if questDoor then
        if player:getStorageValue(item.actionid) ~= -1 or player:getGroup():getAccess() then
            player:sendTextMessage(MESSAGE_INFO_DESCR, "The door seems to be sealed against unwanted intruders.")
            return true
        end

        player:teleportTo(item:getPosition(), true)
        item:transform(questDoor, 1)
        return true
    end

    local door = passthrough[item:getId()]
    if door then
        item:transform(door, 1)
        return true
    end
    return true
end
 
Where did you download this server from? Send me the link and I'll check
You mentioned that you downloaded Windows 10. Show me that link
Post automatically merged:

Just change what's in the commit I linked.

In this file;
Code:
data/scripts/actions/others/doors.lua

Remove
LUA:
or player:getGroup():getAccess()
As he said, this is the solution
I tried but it didn't work
To simplify it for you
goto file data/scripts/actions/others/doors.lua
And copy this code instead of the one you have doors.lua
LUA:
local door = Action()

function door.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local itemId = item:getId()
    if table.contains(closedQuestDoors, itemId) then
        if player:getStorageValue(item.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 table.contains(closedLevelDoors, itemId) then
        if item.actionid > 0 and player:getLevel() >= item.actionid - actionIds.levelDoor then
            item:transform(itemId + 1)
            player:teleportTo(toPosition, true)
        else
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Only the worthy may pass.")
        end
        return true
    elseif table.contains(keys, itemId) then
        local tile = Tile(toPosition)
        if not tile then
            return false
        end
        target = tile:getTopVisibleThing()
        if target.actionid == 0 then
            return false
        end
        if table.contains(keys, target.itemid) then
            return false
        end
        if not table.contains(openDoors, target.itemid) and not table.contains(closedDoors, target.itemid) and not table.contains(lockedDoors, target.itemid) then
            return false
        end
        if item.actionid ~= target.actionid then
            player:sendTextMessage(MESSAGE_STATUS_SMALL, "The key does not match.")
            return true
        end
        local transformTo = target.itemid + 2
        if table.contains(openDoors, target.itemid) then
            transformTo = target.itemid - 2
        elseif table.contains(closedDoors, target.itemid) then
            transformTo = target.itemid - 1
        end
        target:transform(transformTo)
        return true
    elseif table.contains(lockedDoors, itemId) then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "It is locked.")
        return true   
    elseif table.contains(openDoors, itemId) or table.contains(openExtraDoors, itemId) or table.contains(openHouseDoors, itemId) then
        local doorCreatures = Tile(toPosition):getCreatures()
        if doorCreatures and #doorCreatures > 0 then
            player:sendCancelMessage(RETURNVALUE_NOTENOUGHROOM)
            return true
        end
        item:transform(itemId - 1)
        return true   
    elseif table.contains(closedDoors, itemId) or table.contains(closedExtraDoors, itemId) or table.contains(closedHouseDoors, itemId) then
        item:transform(itemId + 1)
        return true
    end
    return false
end

local doorTables = {keys, openDoors, closedDoors, lockedDoors, openExtraDoors, closedExtraDoors, openHouseDoors, closedHouseDoors, closedQuestDoors, closedLevelDoors}
for _, doors in pairs(doorTables) do
    for _, doorId in pairs(doors) do
        door:id(doorId)
    end
end
door:register()
I downloaded the files to test the doors and everything works fine after the modification mentioned by croix
But I discovered an error there that you cannot close the door if a player is standing on it
So you can use my scripts better
LUA:
local positionOffsets = {
    {x = 1, y = 0}, -- east
    {x = 0, y = 1}, -- south
    {x = 1, y = 0}, -- west
    {x = 0, y = 1}, -- north
}

--[[
When closing a door with a creature in it findPushPosition will find the most appropriate
adjacent position following a prioritization order.
The function returns the position of the first tile that fulfills all the checks in a round.
The function loops trough east -> south -> west -> north on each following line in that order.
In round 1 it checks if there's an unhindered walkable tile without any creature.
In round 2 it checks if there's a tile with a creature.
In round 3 it checks if there's a tile blocked by a movable tile-blocking item.
In round 4 it checks if there's a tile blocked by a magic wall or wild growth.
]]
local function findPushPosition(creature, round)
    local pos = creature:getPosition()
    for _, offset in ipairs(positionOffsets) do
        local offsetPosition = pos + offset
        local tile = Tile(offsetPosition)
        if tile then
            local creatureCount = tile:getCreatureCount()
            if round == 1 then
                if tile:queryAdd(creature) == RETURNVALUE_NOERROR and creatureCount == 0 then
                    if not tile:hasFlag(TILESTATE_PROTECTIONZONE) or (tile:hasFlag(TILESTATE_PROTECTIONZONE) and creature:canAccessPz()) then
                        return offsetPosition
                    end
                end
            elseif round == 2 then
                if creatureCount > 0 then
                    if not tile:hasFlag(TILESTATE_PROTECTIONZONE) or (tile:hasFlag(TILESTATE_PROTECTIONZONE) and creature:canAccessPz()) then
                        return offsetPosition
                    end
                end
            elseif round == 3 then
                local topItem = tile:getTopDownItem()
                if topItem then
                    if topItem:getType():isMovable() then
                        return offsetPosition
                    end
                end
            else
                if tile:getItemById(ITEM_MAGICWALL) or tile:getItemById(ITEM_WILDGROWTH) then
                    return offsetPosition
                end
            end
        end
    end
    if round < 4 then
        return findPushPosition(creature, round + 1)
    end
end

local door = Action()

function door.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local itemId = item:getId()
    if table.contains(closedQuestDoors, itemId) then
        if player:getStorageValue(item.actionid) ~= -1 or player:getGroup():getAccess() 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 table.contains(closedLevelDoors, itemId) then
        if item.actionid > 0 and player:getLevel() >= item.actionid - actionIds.levelDoor or player:getGroup():getAccess() then
            item:transform(itemId + 1)
            player:teleportTo(toPosition, true)
        else
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Only the worthy may pass.")
        end
        return true
    elseif table.contains(keys, itemId) then
        local tile = Tile(toPosition)
        if not tile then
            return false
        end
        target = tile:getTopVisibleThing()
        if target.actionid == 0 then
            return false
        end
        if table.contains(keys, target.itemid) then
            return false
        end
        if not table.contains(openDoors, target.itemid) and not table.contains(closedDoors, target.itemid) and not table.contains(lockedDoors, target.itemid) then
            return false
        end
        if item.actionid ~= target.actionid then
            player:sendTextMessage(MESSAGE_STATUS_SMALL, "The key does not match.")
            return true
        end
        local transformTo = target.itemid + 2
        if table.contains(openDoors, target.itemid) then
            transformTo = target.itemid - 2
        elseif table.contains(closedDoors, target.itemid) then
            transformTo = target.itemid - 1
        end
        target:transform(transformTo)
        return true
    elseif table.contains(lockedDoors, itemId) then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "It is locked.")
        return true   
    elseif table.contains(openDoors, itemId) or table.contains(openExtraDoors, itemId) or table.contains(openHouseDoors, itemId) then
        local creaturePositionTable = {}
        local doorCreatures = Tile(toPosition):getCreatures()
        if doorCreatures and #doorCreatures > 0 then
            for _, doorCreature in pairs(doorCreatures) do
                local pushPosition = findPushPosition(doorCreature, 1)
                if not pushPosition then
                    player:sendCancelMessage(RETURNVALUE_NOTENOUGHROOM)
                    return true
                end
                table.insert(creaturePositionTable, {creature = doorCreature, position = pushPosition})
            end
            for _, tableCreature in ipairs(creaturePositionTable) do
                tableCreature.creature:teleportTo(tableCreature.position, true)
            end
        end
    
        item:transform(itemId - 1)
        return true   
    elseif table.contains(closedDoors, itemId) or table.contains(closedExtraDoors, itemId) or table.contains(closedHouseDoors, itemId) then
        item:transform(itemId + 1)
        return true
    end
    return false
end

local doorTables = {keys, openDoors, closedDoors, lockedDoors, openExtraDoors, closedExtraDoors, openHouseDoors, closedHouseDoors, closedQuestDoors, closedLevelDoors}
for _, doors in pairs(doorTables) do
    for _, doorId in pairs(doors) do
        door:id(doorId)
    end
end
door:register()
 
Last edited:
Back
Top