Tested with TFS 0.3.6pl1 8.54
creaturescripts.xml
Add this to login.lua
passdoors.lua
How does it work:
1. Add an unique id to the blackboard. The unique id in the blackboard must be the same as the uniqueid in the password line.
Also add an action id to the door (for example 101) to make it locked, so people can't enter on the normal way.
2. If the ids and positions in the script are correct, you can type the password in the blackboard.
3. If the password is correct, the password will be removed from the blackboard, the door goes open and will automaticly close after 10 seconds if no one closed it.
4. If the password isn't correct, you will get a cancel message that it isn't correct.
5. You can add a tp inside for people to go back.
If you want to add more passwords for other doors, you can just add a new line. Don't forget to also add the new unique ids in the local uniqueids then.
Questions or bugs? Let me know.
creaturescripts.xml
XML:
<event type="textedit" name="Password" event="script" value="passdoors.lua"/>
Add this to login.lua
Lua:
registerCreatureEvent(cid, "Password")
passdoors.lua
Lua:
-- Passwords to doors by Limos
local uniqueids = {8049, 8050}
local passwords = {
["hell"] = {doorpos = {x = 1000, y = 1000, z = 7}, doorid = 6253, blackboardpos = {x = 1000, y = 1000, z = 7}, blackboardid = 1811, uniqueid = 8049, doorclosetime = 10},
["stars"] = {doorpos = {x = 1000, y = 1000, z = 7}, doorid = 1213, blackboardpos = {x = 1000, y = 1000, z = 7}, blackboardid = 1811, uniqueid = 8050, doorclosetime = 10}
}
function onTextEdit(cid, item, newText)
local x = passwords[newText]
local function onCloseDoor()
if(getTileItemById(x.doorpos,x.doorid+1).uid) > 0 then
doTransformItem(getTileItemById(x.doorpos,x.doorid+1).uid, x.doorid)
doSendMagicEffect(x.doorpos, CONST_ME_MAGIC_RED)
end
end
for _, check in pairs(uniqueids) do
if item.uid == check then
if x and item.uid == x.uniqueid then
if(getTileItemById(x.doorpos,x.doorid).uid) > 0 then
doTransformItem(getTileItemById(x.doorpos,x.doorid).uid, x.doorid + 1)
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Your password "'..newText..'" is correct, you can now enter.')
addEvent(onCloseDoor,x.doorclosetime*1000)
doRemoveItem(item.uid, 1)
local blackboard = doCreateItem(x.blackboardid,1,x.blackboardpos)
doItemSetAttribute(blackboard, "uid", x.uniqueid)
else
doRemoveItem(item.uid, 1)
local blackboard = doCreateItem(x.blackboardid,1,x.blackboardpos)
doItemSetAttribute(blackboard, "uid", x.uniqueid)
doPlayerSendCancel(cid, 'The door is already open, be quick or wait till it is closed.')
end
else
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
doPlayerSendCancel(cid, 'Your password "'..newText..'" is not correct.')
end
end
end
return true
end
How does it work:
1. Add an unique id to the blackboard. The unique id in the blackboard must be the same as the uniqueid in the password line.
Also add an action id to the door (for example 101) to make it locked, so people can't enter on the normal way.
2. If the ids and positions in the script are correct, you can type the password in the blackboard.
3. If the password is correct, the password will be removed from the blackboard, the door goes open and will automaticly close after 10 seconds if no one closed it.
4. If the password isn't correct, you will get a cancel message that it isn't correct.
5. You can add a tp inside for people to go back.
If you want to add more passwords for other doors, you can just add a new line. Don't forget to also add the new unique ids in the local uniqueids then.
Questions or bugs? Let me know.
Last edited: