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

Doors and keys locking behaviour is not right at all (Othire 1.0, 7.72 client version)

Terotrificy

Veteran OT User
Joined
Oct 18, 2020
Messages
401
Solutions
13
Reaction score
254
Location
Santiago, Chile.
Hi, i realized that doors should work in this way:

1. If you have a closed locked door and you use the right key, it unlocks and open.
2. If you have a closed unlocked door and you use the right key, it locks the door and remains closed (obviously).
3. If you have a opened door and you use the right key, it close the door and locks the door, all in one action.

So far, the point 3 is not working, when you have a opened door and you try to lock it with the key, it says "you cannot use this object". It is worth noting that you shouldn't be able to lock and close the door with the key if there is a creature, player or item in the door, you can only "lock" the door if there is nothing on it.

It seems that when you use the key, you're not hitting the door, instead you're hitting the ground or items that are in the same sqm than the door.

Here is the code of the key.lua action:

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)


    if (item.actionid == 0 or
    (isInArray(LOCKED_DOORS, itemEx.itemid) == false and
    isInArray(LOCKED_DOORS, itemEx.itemid-1) == false and
    isInArray(LOCKED_DOORS, itemEx.itemid-2) == false)) then
        return false
    end


    local canOpen = (item.actionid == 10000 or item.actionid == itemEx.actionid)
    if not(canOpen) then
        doPlayerSendCancel(cid, "The key does not match.")
        return true
    end


    -- Verify if you are opening or closing the door
    if isInArray(LOCKED_DOORS, itemEx.itemid) == true then            -- Opening
        doTransformItem(itemEx.uid, itemEx.itemid+2)
    elseif isInArray(LOCKED_DOORS, itemEx.itemid-2) == true then    -- Closing and Locking
        doTransformItem(itemEx.uid, itemEx.itemid-2)
    else                                                 
        doTransformItem(itemEx.uid, itemEx.itemid-1)                -- Locking an already closed door
    end
    doSetItemActionId(itemEx.uid, itemEx.actionid)
    return true
end

I know Xikini solved it for his distro some time ago, but i've been struggling with this issue for a while in Othire.
 
Solution
To anyone having this problem, the problem is client-side instead of server-side.
So anyone using the otclient 7.72 of Peonso (peonso/otclient772 (https://github.com/peonso/otclient772)), i finally managed to fix this issue:

You need to replace this lines of getTopMultiUseThing() in tile.ccp:

C++:
for(uint i = 0; i < m_things.size(); ++i) {
        ThingPtr thing = m_things[i];
        if(!thing->isGround() && !thing->isOnTop())
            return thing;
    }

    return m_things[0];

for this lines:

C++:
for (uint i = 0; i < m_things.size(); ++i) {
        ThingPtr thing = m_things[i];
        if (!thing->isGround() && !thing->isGroundBorder() && !thing->isOnBottom() && !thing->isOnTop()) {
            if (i > 0 &&...
This is a little odd, but I have I think the exact same key.lua, but for doors, its working as you stated for 1, 2, 3. Is it possible, perhaps, your array of Locked Doors has some issues?
 
This is a little odd, but I have I think the exact same key.lua, but for doors, its working as you stated for 1, 2, 3. Is it possible, perhaps, your array of Locked Doors has some issues?
Do you have Othire 1.0 btw? what ot client are you using?
I'm not able to close a door using a key when it's open.
 
I am using the OTHIRE that is from the website here:


However, it has been given much modifications beyond what is listed, but none of that should be related to the doors opening and closing. I also use normal original client with some modifications but nothing to affect doors.

Could you go to your movements doors folder, and show of your onadd lockeddoor, and then in your actions, the door locked and open horizon and vertical, and also of in actions in lib the door arrays?
 
After checking it with evansiruis, we realized using the normal tibia client 7.72, the door behaviour works as expected. However, when i use otclient 7.72, for some reason it never hits the door with the key (use with, crosshair), instead it hits the floor or any item where the opened door is, so it never finds the door when it's open.

Anyone know how to fix it?
 
It seems that when you use the key, you're not hitting the door, instead you're hitting the ground or items that are in the same sqm than the door.
use stackpos 255 -- top thing (item or creature)

local target = getThingFromPos({x = toPosition.x, y = toPosition.y, z = toPosition.z, stackpos = 255})
 
use stackpos 255 -- top thing (item or creature)

local target = getThingFromPos({x = toPosition.x, y = toPosition.y, z = toPosition.z, stackpos = 255})
Sorry but i didn't understand where/how to use it. I get it should get the position of the thing on top of the stack, but i'm just too dumb to understand how to use it rofl
 
To anyone having this problem, the problem is client-side instead of server-side.
So anyone using the otclient 7.72 of Peonso (peonso/otclient772 (https://github.com/peonso/otclient772)), i finally managed to fix this issue:

You need to replace this lines of getTopMultiUseThing() in tile.ccp:

C++:
for(uint i = 0; i < m_things.size(); ++i) {
        ThingPtr thing = m_things[i];
        if(!thing->isGround() && !thing->isOnTop())
            return thing;
    }

    return m_things[0];

for this lines:

C++:
for (uint i = 0; i < m_things.size(); ++i) {
        ThingPtr thing = m_things[i];
        if (!thing->isGround() && !thing->isGroundBorder() && !thing->isOnBottom() && !thing->isOnTop()) {
            if (i > 0 && thing->isSplash())
                return m_things[i - 1];
            return thing;
        }
    }

    return m_things.back();

Leaving the whole function like this:

C++:
ThingPtr Tile::getTopMultiUseThing()
{
    if(isEmpty())
        return nullptr;

    if(CreaturePtr topCreature = getTopCreature())
        return topCreature;

    for(uint i = 0; i < m_things.size(); ++i) {
        ThingPtr thing = m_things[i];
        if(thing->isForceUse())
            return thing;
    }

    for(uint i = 0; i < m_things.size(); ++i) {
        ThingPtr thing = m_things[i];
        if(!thing->isGround() && !thing->isGroundBorder() && !thing->isOnBottom() && !thing->isOnTop()) {
            if(i > 0 && thing->isSplash())
                return m_things[i-1];
            return thing;
        }
    }
    }

    return m_things.back();
}
 
Last edited:
Solution
Back
Top