Guest User

Untitled

a guest
Sep 11th, 2018
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. integer locked = 0; //0=FALSE=unlocked, 1=TRUE=locked. Start this as unlocked, so if you run into trouble a simple script reset will clear RLV commands.
  2. integer menuchan = 12345; //Easy way to set the menu channel.
  3. integer menulisten;
  4. key LockerID; //stores who locked the restraint
  5. key ToucherID;
  6.  
  7. default {
  8.     state_entry(){
  9.     //Debug message, lets you know the script is started and is working. Comment it out or delete it when you're done. Hell, comment the whole state_entry event, you don't need it besides this.
  10.     llSay(0, "Debug: Script Started");
  11.     }
  12.  
  13.     on_rez(integer start_param){
  14.         //This is necessary to apply your RLV commands at object rez. Without this, the restrictions won't survive a relog.
  15.         if (locked){
  16.             RLVLock();
  17.         }
  18.            
  19.         else {
  20.             RLVUnlock();
  21.         }
  22.     }
  23.    
  24.     touch_start(integer total) {
  25.         ToucherID = llDetectedKey(0); //uses llDetectedKey to set ToucherID to the key of the person who touched the object.
  26.        
  27.         if (!locked){
  28.         // That's "if not locked"
  29.        
  30.             llDialog(
  31.                 ToucherID,
  32.                 "Locking the device will prevent the wearer from detaching it. Only the person that locks can unlock.",
  33.                 ["Lock"], menuchan);
  34.             //Mir uses a special formatting to pretty up the dialog command. I like this, because otherwise the dialog command gets to be roughly the width of Alaska. Here's what it looks like unformatted:
  35.             //llDialog(llDetectedKey(0),"Locking the device will prevent the wearer from detaching it. Only the person that locks can unlock.",["Lock],menuchan);
  36.             //Lemme step you through what's happening here:
  37.             //The first item is the key of the person you want to send the dialog box to. It uses the variable set above.
  38.             //The second item is a string that shows as the dialog box caption. It's the block of text at the top of the box.
  39.             //Third is the array that determines what the buttons are. If you were to have more than one button, it would go like so: ["button1","button2","button3"] and so on. You can have 12 buttons max in a 3x4 block. Buttons fill out left-to-right, bottom-to-top.
  40.             //Fourth is the integer for the listen channel. You'll be setting up a listen command keyed to this channel.
  41.            
  42.             menulisten = LLlisten(menuchan, "", ToucherID, "");
  43.             //And this sets up your companion listen to the above llDialog command.
  44.             //First item is the menu channel, using the menuchan variable we've set at the beginning.
  45.             //Second item is a string for the name it'll be listening to. We'll be listening to a specific key instead of name, so we can leave this to any name.
  46.             //Third item is the key it'll be listening for. We set it to listen for the key of the person that touched the object. Otherwise it would just listen to everything, which is laggy and bad.
  47.             //Fourth item is the message it will be listening for. Since our dialog is only one item you could set this to only listen for "Lock" but since we've already keyed it only to the toucher's ID that's not really necessary. If you have a dialog with multiple items you want to leave this blank.
  48.             //Also going on is we're keying the listen command to a variable. This lets us end it later and not have open listens lagging up the place.
  49.         }
  50.    
  51.         else if(locked && ToucherID != lockerID){
  52.         //That is "If locked and toucher's ID doesn't match locker's ID"
  53.        
  54.             llDialog{
  55.                 ToucherID,
  56.                 "You don't have access to this restraint!",
  57.                 ["Oh, ok"], menuchan);
  58.             //Just a basic dialog to let the non-locker know they don't have access. We don't even bother with a companion listen for this one.
  59.         }
  60.        
  61.         else if(locked && ToucherID == LockerID){
  62.         // "If locked and toucher ID matches locker ID"
  63.        
  64.             llDialog{
  65.                 ToucherID,
  66.                 "Unlocking the device will allow the wearer to detach it. Only the person that locked it can unlock."
  67.                 [".", "Hud 3", "Hud 4", "Unlock", "Hud 1", "Hud 2"],
  68.                 menuchan);
  69.             //Remember what I said about it filling bottom-to-top? Well that means to format it right you sometimes need to be kinda wierd about it. Look at the button array, that's the stuff between the [] brackets.
  70.             //The first three items are the BOTTOM line of the dialog box. The next three are the second-to-bottom, and so on.
  71.            
  72.             menulisten = llListen(menuchat, "", ToucherID, "");
  73.             //Pretty much identical to the unlocked states' listen call.
  74.         }
  75.        
  76.         llSetTimerEvent(300); //Menu cliker has 5 minutes to use the menu before it times out.
  77.        
  78.     }
  79.    
  80.     listen(integer channel, string name, key id, string message) {
  81.    
  82.     if (message == lock){
  83.         LockerID = ToucherID
  84.         RLVLock();
  85.         llListenRemove(menulisten); //Being responsible and cleaning up our listens after we are done
  86.         }
  87.        
  88.     if (message == unlock){
  89.         LockerID = 0
  90.         RLVUnlock();
  91.         llListenRemove(menulisten); //Being responsible and cleaning up our listens after we are done
  92.         }
  93.     }
  94.    
  95.     timer() {
  96.     //Here we are being responsible and setting a timer to stop our listen if there's no response after 5 minutes.
  97.    
  98.         llListenRemove(menulisten);
  99.         llSetTimerEvent(0.0); //Stops the timer from repeating.
  100.     }
  101. }
  102.  
  103. RLVLock(){
  104.     // Clothing Restrictions
  105.     llOwnerSay( "@defaultwear=n");    
  106.     llOwnerSay( "@detach=n");
  107.     llOwnerSay( "@addoutfit=n");
  108.     llOwnerSay( "@remoutfit=n");
  109.  
  110.     // Attachment Restrictions
  111.     llOwnerSay( "@detach:center 2=n");
  112.     llOwnerSay( "@detach:spine=n");
  113.     llOwnerSay( "@detach:chest=n");
  114.     llOwnerSay( "@detach:stomach=n");
  115.     llOwnerSay( "@remattach:center 2=n");
  116.     llOwnerSay( "@remattach:spine=n");
  117.     llOwnerSay( "@remattach:chest=n");
  118.     llOwnerSay( "@remattach:stomach=n");    
  119.        
  120.     // Movement Restrictions
  121.     llOwnerSay( "@fly=n");
  122.     llOwnerSay( "@alwaysrun=n");
  123.     llOwnerSay( "@temprunz=n");
  124.    
  125.     // Talking Restrictions
  126.     llOwnerSay( "@chatnormal=n");
  127.     llOwnerSay( "@chatshout=n");
  128.     llOwnerSay( "@chatwhisper=y");
  129.    
  130.     // Other Restrictions
  131.     llOwnerSay( "@touchfar=n");
  132.     llOwnerSay( "@fartouch=n");
  133.  
  134.     // Message
  135.     llOwnerSay ( "You are now locked" );
  136. }
  137.  
  138. RLVUnlock(){
  139.     llOwnerSay( "@clear" );
  140.     llOwnerSay ( "/me is now unlocked");
  141. }
Add Comment
Please, Sign In to add comment