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

Locked door doesn't close after opening

survivor

New Member
Joined
Mar 20, 2008
Messages
89
Reaction score
4
Hello,

I wanted to give only the player with the key acces to the area, but once the door is opened it doesn't close so everyone can still enter.. How can I help that?

Thanks in advance,
 
You want it to close automaticly after some time?
Code:
local function onCloseDoor(id, pos)
     if getTileItemById(pos, id).uid > 0 then
         doTransformItem(getTileItemById(pos, id).uid, id -1)
     end
end

addEvent(onCloseDoor, 10 * 1000, doors[item.itemid], toPosition)
 
Yes that would be great :)

And thanks for the script, but I don't know how to use it.. I tried to fill in some things but haven't got it working yet..

when I don't fill anything in it gives me this error:

[02/01/2015 22:10:56] data/actions/scripts/poi key.lua:7: attempt to index global 'item' (a nil value)
[02/01/2015 22:10:56] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/poi key.lua)

I'm using tfs 0.3.6..
 
I gave the door the same AID as the key's AID, I didn't use a script..

And then I gave the door the same UID as your script, and then it gives the error message I showed you.

I searched in the server a bit and i guess this is the script wich makes the door open with the key?
Still don't know how to edit it though.. soz.

Code:
   if(isInArray(keys, item.itemid)) then
     if(itemEx.actionid > 0) then
       if(item.actionid == itemEx.actionid and doors[itemEx.itemid] ~= nil) then
         doTransformItem(itemEx.uid, doors[itemEx.itemid])
      
         return true
       end

       doPlayerSendCancel(cid, "The key does not match.")
       return true
     end

     return false
   end
 
Add this above doTranformItem
Code:
addEvent(onCloseDoor, 10 * 1000, doors[itemEx.itemid], toPosition)

Then add the function above function onUse
Code:
local function onCloseDoor(id, pos)
      if getTileItemById(pos, id).uid > 0 then
           doTransformItem(getTileItemById(pos, id).uid, id -1)
      end
end
 
Back
Top