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

Lua Magic doors player stuck on non walkable objects

hotdog1337

Banned User
Joined
Apr 1, 2021
Messages
246
Solutions
3
Reaction score
92
1620942464962.png
Lua:
function onUse(cid, item, frompos, item2, topos)
    -- Are we on pz?
    local isPz = (getTilePzInfo(frompos) == 1)

    -- Get the tile to move the things on the door to
    local nextTile = {x=frompos.x+1, y=frompos.y, z=frompos.z}
    if(isPz and getTilePzInfo(nextTile) == 0) then
        nextTile.x = frompos.x-1
    end

    -- Move all moveable things to the next tile
    doRelocate(frompos, nextTile)

    -- Transform the door
    doTransformItem(item.uid, item.itemid-1)
    return TRUE
end
Lua:
function onUse(cid, item, frompos, item2, topos)
    -- Are we on pz?
    local isPz = (getTilePzInfo(frompos) == 1)

    -- Get the tile to move the things on the door to
    local nextTile = {x=frompos.x, y=frompos.y+1, z=frompos.z}
    if(isPz and getTilePzInfo(nextTile) == 0) then
        nextTile.y = frompos.y-1
    end

    -- Move all moveable things to the next tile
    doRelocate(frompos, nextTile)

    -- Transform the door
    doTransformItem(item.uid, item.itemid-1)
    return TRUE
end

Lua:
function onStepOut(cid, item, pos)
    if(item.actionid == 0) then
        -- This is not a special door
        return TRUE
    end

    local topos = getPlayerPosition(cid)
    doRelocate(pos, topos)

    -- Remove any item that was not moved
    -- Happens when there is an unmoveable item on the door, ie. a fire field
    local tmpPos = {x=pos.x, y=pos.y, z=pos.z, stackpos=-1}
    local tileCount = getTileThingByPos(tmpPos)
    local i = 1
    local tmpItem = {uid = 1}

    while(tmpItem.uid ~= 0 and i < tileCount) do
        tmpPos.stackpos = i
        tmpItem = getTileThingByPos(tmpPos)
        if(tmpItem.uid ~= item.uid and tmpItem.uid ~= 0) then
            doRemoveItem(tmpItem.uid)
        else
            i = i + 1
        end
    end

    doTransformItem(item.uid, item.itemid-1)
    return TRUE
end

Lua:
-- Player with storage value of the item's actionid set to 1 can open

function onUse(cid, item, frompos, item2, topos)
    if(item.actionid == 0) then
        -- Make it a normal door
        doTransformItem(item.uid, item.itemid+1)
        return true
    end

    
    local canEnter = (getPlayerStorageValue(cid, item.actionid) == 1)
    if not(canEnter) then
    doPlayerSendTextMessage(cid,22,'The door is sealed against unwanted intruders.')
    return true
    else
        doTransformItem(item.uid, item.itemid+1)
        topos = {x=topos.x, y=topos.y, z=topos.z}
        doTeleportThing(cid,topos)   
    end

    local canGo = (queryTileAddThing(cid, frompos, bit.bor(2, 4)) == RETURNVALUE_NOERROR) --Veryfies if the player can go, ignoring blocking things
    if not(canGo) then
        return false
    end
    return true
end

this bug only persists on doors that are facing east and south
Post automatically merged:

temporarily fixed by removing
<action itemid="1224" script="doors/door_open_horizontal.lua"/>

<action itemid="1226" script="doors/door_open_vertical.lua"/>

however i still prefer if i could use the doors ( first 2 lua scripts) and it would kick player to last position or position that is not occupied by items that are unwalkable if someone knows how to do that it would be great.
 
Last edited:
Top