Knowledgebase
Storm Palace Hosting > Storm Hosting Help Desk > Knowledgebase

Ask a question:


Doorlocks

Solution DoorLocks



One of the greatest mysteries and seems to be the hardest for people to grasp are making lockable doors. There are also different versions of this script out there that will either lock it with a spoken word or a click of your mouse. You can even lock a door ON ALARM if thats what you want to do. The most important thing that most seem to forget to do is you HAVE to make the room PRIVATE for a lock to work.

This is the easiest way I have seen so far to make a lock for a room.

1. Mark the room as PRIVATE in the room info.
2. Make a door and set it as "DON'T MOVE HERE" & "LOCKABLE"
3. Add lock and unlock spot pictures (optional)
4. Add this script.

ON SELECT {
{ ME UNLOCK }
{ ME LOCK } ME ISLOCKED IFELSE
}

Then clicking on that door will lock & unlock the room :-)

Another version with a spoken word "lock" or "unlock" and a statusmsg
Altho Ive never tested this myself, I was told that a single spot locking script like this one below, with the room set to private will keep even a god out.
;Lock the room. The door type must be "Private" and "lockable".
;Only this spot is required to lock a room.
ON ENTER {
"@500,10 Type \"Lock\" or \"Unlock\" to open or close the room" LOCALMSG }

ON OUTCHAT {
{ "Door Locked" statusmsg
ME LOCK
"" CHATSTR = } "lock" CHATSTR == IF
{ "Door Unlocked" statusmsg
ME UNLOCK
"" CHATSTR = } "unlock" CHATSTR == IF
}

-----------------------------------------------------------------

Lock and Unlock scripts explained with pictures or a spoken word:

The design really depends on what you want. IF you want the door to lock
via the .gif's or if you want it to lock via a trigger word. I will give you both methods.

First is for using the chessunl.gif, chesslck.gif

For this one you need two spots, one to put the script in, and then the
actual door. Make you door, wherever you like. Make it a 'lockable door'
and pay attention to its spot number. You need that info later in this script.

Make a second spot, in that one select the pic's you wish to use. I
usually make this spot a deadbolt, althought I have found it is not necessary.
Here is the script I use for them.

ON SELECT {
{ 0 ME SETSPOTSTATE
1 LOCK
}{ 1 ME SETSPOTSTATE
1 UNLOCK
} 1 ME GETSPOTSTATE == IFELSE
}

Notice in the script, the following. 0 ME the 0 is telling the spot (ME) what state or pic to display. The next line is the actual locking part. 1 is the number of the door spot you wish to lock. So in this case, it is 1 LOCK that would be spot id 1 in the door you made, and LOCK it. The 1 will change depending on what the spot number of the door is. Remember earlier I said, pay attention to the spot number of the door. You may lock 2 or 3 doors.. just put in a line for each door. 1 LOCK 2 LOCK etc. The same applies for the unlocking... 1 ME is just telling it what picture to display for the unlock postion ME means 'this spot' not the door.. only this spot. I hope that explains it clearly enough. If not, just ask :-)

------------------------------------------------------------------------------------------

This one is for a door you want to lock or unlock via a trigger word.

The idea is exactly the same. Only, it is done on an OUTCHAT and you can
use two spots as in the script above if you like, but I have found it will work fine
with one.. just the door... and the lock script in that same spot. Your
choice to play with. Here is the script I use.

ON OUTCHAT
{ { 1 LOCK
} CHATSTR LOWERCASE "^lock" GREPSTR IF
{ 1 UNLOCK
} CHATSTR LOWERCASE "^unlock" GREPSTR IF
}

Notice the absence of 0 ME SETSPOTSTATE in this script. That is because
it is not needed. The only purpose for this is to display a picture in a spot.. Which we are not doing here so...
If you have more than one passage in a room, such as one door to go forward and one door to go back, you will have to set BOTH doors to lockable and in this script you would say 1 LOCK 2 LOCK (assuming the second passage is door id 2)... If you have multiple passages like that and only lock one of them, the room will still be open...

Feel free to change the triger word '^lock, or ^unlock' if you like, Add a text to tell people it is locked or not.. This is just the basic script.

------------------------------------------------------------

Contrary to palace mythology, lockable rooms do NOT require ANY
scripts in order to work, as the feature is built in to the pserver. The
only time you'd need to worry about scripts is if you want to a) manipulate
a graphic, such as a door that opens and closes based on a spotstate or b)
want to control the door with chat, as opposed to clicking on a spot.

In order for a locked room to work, the following conditions must be met:

1) The room must selected as 'private'.
2) The controllING spot(s) must be set as a deadbolt (you can have more
than one controlling the same lockable door).
3) The controllED door must be set as a lockable door and have an ID of 100.
4) The controllED door must lead somewhere (as a passage)

If these conditions are met, you can click on a the controlling spot and
the doorway will toggle between open and locked.

---------------------------------------------------------------------
 
Was this article helpful? yes / no
Article details
Article ID: 296
Category: Room Scripts
Date added: 10-05-2011 23:49:12
Views: 511
Rating (Votes): Article not rated yet (0)

 
<< Go back

Powered by Help Desk Software HESK™