• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Door [Auto close]

Sweetlove

Member
Joined
Jun 22, 2009
Messages
270
Reaction score
14
Location
Sverige
Hey, is there a script like this? lets say i use a key with aid 1234 then i want the door to close automatic after a short while. :p
 
before start be sure the key u using is on this list
[data\actions\actions.xml]
<!-- Keys -->
<action itemid="2086-2092;10032;10091" event="script" value="other/keys.lua"/>
---------------------------------------------------------------------
here it is a edited version of the file
[date/action/script/other/key.lua]
actionid u put the action of the door u wanna to auto close when the key is used.
xtime is the time to auto close.
PHP:
REVERSE_DOORS, CHILD_DOORS = {}, {}
AUTO_CLOSE_DOORS = {
                    actionid = { 7777,777 },    -- actionid list like {1,2,3 }
                    xtime = 5 ,                -- in sec
                    }


for k, v in pairs(DOORS) do
    REVERSE_DOORS[v] = k

    local tmp = getItemInfo(v)
    if(tmp.transformUseTo ~= 0) then
        CHILD_DOORS[tmp.transformUseTo] = k
    end
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(item.aid > 0 and itemEx.aid > 0) then
        if(isPlayerPzLocked(cid) and getTileInfo(toPosition).protection) then
            doPlayerSendDefaultCancel(cid, RETURNVALUE_ACTIONNOTPERMITTEDINPROTECTIONZONE)
            return true
        end

        local doors = DOORS[itemEx.itemid]
        local closed_door = itemEx.itemid
       
        if(not doors) then
            doors = REVERSE_DOORS[itemEx.itemid]
            closed_door= doors
        end

        if(not doors) then
            doors = CHILD_DOORS[itemEx.itemid]
            closed_door= doors
        end
        print ( closed_door )

        if(doors) then
            if(item.actionid ~= itemEx.actionid) then
                doPlayerSendCancel(cid, "The key does not match.")
            else
                if isInArray(AUTO_CLOSE_DOORS.actionid, item.actionid) then
                    addEvent(doPlayerSendCancel, 2*1000, cid, "3" )
                    addEvent(doPlayerSendCancel, 3*1000, cid, "2" )
                    addEvent(doPlayerSendCancel, 5*1000, cid, "1" )

                    local xtime = AUTO_CLOSE_DOORS.xtime*1000
                    addEvent(function () doTransformItem(getThingfromPos(toPosition).uid, closed_door) end, xtime)
                    doTransformItem(itemEx.uid, doors)
                else
                    doTransformItem(itemEx.uid, doors)
                end
            end

            return true
        end
    end

    return false
end
 
Last edited:
the error was at that line -- just replace the line 37.
if(isInArray(AUTO_CLOSE_DOORS.actionid, item.actionid) then
forget to remove ( from the beginer
or add ) to the end
Code:
-- chose une of that line
if(isInArray(AUTO_CLOSE_DOORS.actionid, item.actionid)) then
-- or this other
if isInArray(AUTO_CLOSE_DOORS.actionid, item.actionid) then
 
looks like ur lib is missing some constant. [GOTO]
data\actions\lib\actions.lua
and past this code inside.
PHP:
DOORS = {
    [1209] = 1211, [1212] = 1214, [1231] = 1233, [1234] = 1236, [1249] = 1251, [1252] = 1254, [3535] = 3537, [3544] = 3546, [4913] = 4915, [4916] = 4918,
    [5098] = 5100, [5107] = 5109, [5116] = 5118, [5125] = 5127, [5134] = 5136, [5137] = 5139, [5140] = 5142, [5143] = 5145, [5278] = 5280, [5281] = 5283,
    [5732] = 5734, [5735] = 5737, [6192] = 6194, [6195] = 6197, [6249] = 6251, [6252] = 6254, [6891] = 6893, [6900] = 6902, [7033] = 7035, [7042] = 7044,
    [8541] = 8543, [8544] = 8546, [9165] = 9167, [9168] = 9170, [9267] = 9269, [9270] = 9272, [10268] = 10270, [10271] = 10273, [10468] = 10470,
    [10477] = 10479, [10775] = 10777, [10784] = 10786, [12092] = 12094, [12099] = 12101, [12188] = 12190, [12197] = 12199
}
i have UPDATED the action script, now i tested it ( before i have only write ) test made
OT : 9.81
The Global Server Version: (3.28 - r19) - Codename: (Apocalypse)
 
do u have SKYPE ?
well the door u want to use have to be in the door list !!!
exemple [closed_door_id] = opened_door_id
and actionid for door shall be 4 digit or more that mean 777 will not work !

exemple take the 1st id put that door in ur map
ID : 1209
and test with action id 7777
thoses door list i riped from my OT : 9.81 maybe thoses ids are wrong in ur ot.
i dont know what version u using.
 
Last edited:
Back
Top