Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. string notecard = "Access List";    //name of notecard to read
  2.  
  3. integer counter;
  4. key query;
  5. list has_access;
  6.  
  7. default {
  8.  
  9.     state_entry() {
  10.         if (llGetInventoryType(notecard) != INVENTORY_NOTECARD) {
  11.             llOwnerSay("Please put a notecard in me");
  12.             return;
  13.         }
  14.         else {
  15.             llOwnerSay("Please wait a moment while I read the card");
  16.             query = llGetNotecardLine(notecard, counter);    //ask for first line of notecard
  17.         }
  18.     }
  19.  
  20.     dataserver(key queryid, string data) {
  21.         if (queryid == query) {    //check it's a reply to this request, since there may be other dataserver things going on in the same object
  22.             if (data != EOF) {    //if it's not saying "nothing more to read"
  23.                 data = llStringTrim(data, STRING_TRIM);    //chop off any leading and trailing spaces, which tend to cause problems
  24.                 if (data != "" && llGetSubString(data, 0, 1) != "//") {    //if it's not an empty line and if it's not commented out in the notecard
  25.                     has_access +=[data];    //add the name to the list
  26.                     //nb -- and very important ... the data is  a string, so if you are reading -- eg -- a list of colours, you have to say colour_list += (vector) data; or it won't work
  27.                 }
  28.                 counter++;    //advance the counter
  29.                 query = llGetNotecardLine(notecard, counter);    //ask for next line of notecard
  30.             }
  31.  
  32.         }
  33.         else {
  34.             llOwnerSay("Finished reading the card now");
  35.  
  36.         }
  37.     }
  38.  
  39.     touch_start(integer n) {
  40.         key av = llDetectedKey(0);
  41.         string name = llDetectedName(0);
  42.         if (~llListFindList(has_access,[name])) {  // is the name on the list?  If so
  43.             llInstantMessage(av, "You are on the access list, and so are the following people:");
  44.             integer i;
  45.             integer max = llGetListLength(has_access);
  46.             for (i = 0; i < max; ++i) {
  47.                 llInstantMessage(av, llList2String(has_access, i));
  48.             }
  49.         }
  50.         else { // it's not on the list
  51.             llInstantMessage(av, "Sorry, but you aren't on the access list");
  52.         }
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement