Advertisement
RuthvenWillenov

Unsit if not in list, with name to key

Jun 23rd, 2018
446
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Place this script into a furniture object that you would like to restrict to certain users in a white list. When an avatar sits, it will check if the avatar is the owner. If it's not, it will then check if they are in the white list, if not, they will be Unsat
  2.  
  3. //Edit the white list below to include the names of the avatars you would like to allow to use your furniture. No need to include "Resident" in the name, and the functions used below are not case sensitive.
  4. list whitelist = ["some name", "some name 2"];
  5.  
  6. //Do Not Edit Below This Line Unless You Know What You're Doing
  7.  
  8. list keys;
  9. key inq;
  10. integer len;
  11. integer index;
  12. default
  13. {
  14.     state_entry()
  15.     {
  16.         len = llGetListLength(whitelist);
  17.         index = 0;
  18.         inq = llRequestUserKey(llList2String(whitelist,index));
  19.     }
  20.    
  21.     dataserver(key datainq, string data)
  22.     {
  23.         if(datainq == inq)
  24.         {
  25.             if((key)data)
  26.             {
  27.                 keys += [(key)data];
  28.             }
  29.             index++;
  30.             if(index < len)
  31.             inq = llRequestUserKey(llList2String(whitelist,index));
  32.         }
  33.     }
  34.     changed(integer change)
  35.     {
  36.         if(change & CHANGED_LINK)
  37.         {
  38.             key id = llAvatarOnSitTarget();
  39.             if(id)
  40.             {
  41.                 if(id != llGetOwner())
  42.                 {
  43.                     if(llListFindList(keys, [id]) == -1)
  44.                     {
  45.                         llUnSit(id);
  46.                     }
  47.                 }
  48.             }
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement