Advertisement
Gayngel

[AV]root-security.lsl with group joiner sayer

Feb 18th, 2020
1,270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. /*
  3.  
  4.  * [AV]root-security - Specify who can sit and/or use the menu
  5.  
  6.  *
  7.  
  8.  * This Source Code Form is subject to the terms of the Mozilla Public
  9.  
  10.  * License, v. 2.0. If a copy of the MPL was not distributed with this
  11.  
  12.  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  13.  
  14.  *
  15.  
  16.  * Copyright © the AVsitter Contributors (http://avsitter.github.io)
  17.  
  18.  * AVsitter™ is a trademark. For trademark use policy see:
  19.  
  20.  * https://avsitter.github.io/TRADEMARK.mediawiki
  21.  
  22.  *
  23.  
  24.  * Please consider supporting continued development of AVsitter and
  25.  
  26.  * receive automatic updates and other benefits! All details and user
  27.  
  28.  * instructions can be found at http://avsitter.github.io
  29.  
  30.  */
  31.  
  32.  
  33.  
  34. string product = "AVsitter™ Security 2.2";
  35.  
  36. string script_basename = "[AV]sitA";
  37.  
  38. string menucontrol_script = "[AV]root-control";
  39.  
  40. string RLV_script = "[AV]root-RLV";
  41.  
  42. key active_sitter;
  43.  
  44. integer active_prim;
  45.  
  46. integer active_script_channel;
  47.  
  48. integer menu_channel;
  49.  
  50. integer menu_handle;
  51.  
  52. list SIT_TYPES = ["ALL", "OWNER", "GROUP"];
  53.  
  54. integer SIT_INDEX;
  55.  
  56. integer MENU_INDEX;
  57.  
  58. string lastmenu;
  59.  
  60. list MENU_TYPES = [lastmenu]; //OSS::list MENU_TYPES; // Force error in LSO
  61.  
  62.  
  63.  
  64. integer pass_security(key id, string context)
  65.  
  66. {
  67.  
  68.     integer ALLOWED = FALSE;
  69.  
  70.     string TYPE = llList2String(SIT_TYPES, SIT_INDEX);
  71.  
  72.     if (context == "MENU")
  73.  
  74.     {
  75.  
  76.         TYPE = llList2String(MENU_TYPES, MENU_INDEX);
  77.  
  78.     }
  79.  
  80.     if (TYPE == "GROUP")
  81.  
  82.     {
  83.  
  84.         if (llSameGroup(id) == TRUE)
  85.  
  86.         {
  87.  
  88.             ALLOWED = TRUE;
  89.  
  90.         }
  91.  
  92.     }
  93.  
  94.     else if (id == llGetOwner() || TYPE == "ALL")
  95.  
  96.     {
  97.  
  98.         ALLOWED = TRUE;
  99.  
  100.     }
  101.  
  102.     return ALLOWED;
  103.  
  104. }
  105.  
  106.  
  107.  
  108. check_sitters()
  109.  
  110. {
  111.  
  112.     integer i = llGetNumberOfPrims();
  113.  
  114.     while (llGetAgentSize(llGetLinkKey(i)) != ZERO_VECTOR)
  115.  
  116.     {
  117.  
  118.         key av = llGetLinkKey(i);
  119.  
  120.         if (pass_security(av, "SIT") == FALSE)
  121.  
  122.         {
  123.  
  124.             llUnSit(av);
  125.  
  126.             llDialog(av, product + "\n\nSorry, Sit access is set to: " + llList2String(SIT_TYPES, SIT_INDEX), ["OK"], -164289491);
  127.  
  128.         if(llList2String(SIT_TYPES, SIT_INDEX) == "GROUP")
  129.         {
  130.            
  131.            list det = llGetObjectDetails(llGetKey(),[OBJECT_GROUP]);
  132.            key group = llList2Key(det,0);
  133.            
  134.            llInstantMessage(av,"To sit please join this group: secondlife:///app/group/"+(string)group+"/about");
  135.            
  136.         }
  137.  
  138.         }
  139.  
  140.         i--;
  141.  
  142.     }
  143.  
  144. }
  145.  
  146.  
  147.  
  148. back_to_adjust(integer SCRIPT_CHANNEL, key sitter)
  149.  
  150. {
  151.  
  152.     llMessageLinked(LINK_SET, 90101, (string)SCRIPT_CHANNEL + "|[ADJUST]|", sitter);
  153.  
  154. }
  155.  
  156.  
  157.  
  158. list order_buttons(list menu_items)
  159.  
  160. {
  161.  
  162.     return llList2List(menu_items, -3, -1) + llList2List(menu_items, -6, -4) + llList2List(menu_items, -9, -7) + llList2List(menu_items, -12, -10);
  163.  
  164. }
  165.  
  166.  
  167.  
  168. register_touch(key id, integer animation_menu_function, integer active_prim, integer giveFailedMessage)
  169.  
  170. {
  171.  
  172.     if (pass_security(id, "MENU"))
  173.  
  174.     {
  175.  
  176.         if (llGetInventoryType(menucontrol_script) == INVENTORY_SCRIPT)
  177.  
  178.         {
  179.  
  180.             if (check_for_RLV())
  181.  
  182.             {
  183.  
  184.                 llMessageLinked(LINK_THIS, 90012, (string)active_prim, id);
  185.  
  186.             }
  187.  
  188.             else
  189.  
  190.             {
  191.  
  192.                 llMessageLinked(LINK_THIS, 90007, "", id);
  193.  
  194.             }
  195.  
  196.         }
  197.  
  198.         else
  199.  
  200.         {
  201.  
  202.             llMessageLinked(LINK_SET, 90005, (string)animation_menu_function, id);
  203.  
  204.         }
  205.  
  206.     }
  207.  
  208.     else if (giveFailedMessage)
  209.  
  210.     {
  211.  
  212.         llDialog(id, product + "\n\nSorry, Menu access is set to: " + llList2String(MENU_TYPES, MENU_INDEX), ["OK"], -164289491);
  213.  
  214.     }
  215.  
  216. }
  217.  
  218.  
  219.  
  220. main_menu()
  221.  
  222. {
  223.  
  224.     list buttons = (list)"Sit" + "Menu";
  225.  
  226.     if (active_sitter) // OSS::if (osIsUUID(active_sitter) && active_sitter != NULL_KEY)
  227.  
  228.     {
  229.  
  230.         buttons = "[BACK]" + buttons;
  231.  
  232.     }
  233.  
  234.     dialog("Sit access: " + llList2String(SIT_TYPES, SIT_INDEX) + "\nMenu access: " + llList2String(MENU_TYPES, MENU_INDEX) + "\n\nChange security settings:", buttons);
  235.  
  236.     lastmenu = "";
  237.  
  238. }
  239.  
  240.  
  241.  
  242. dialog(string text, list menu_items)
  243.  
  244. {
  245.  
  246.     llListenRemove(menu_handle);
  247.  
  248.     menu_handle = llListen((menu_channel = ((integer)llFrand(0x7FFFFF80) + 1) * -1), "", llGetOwner(), ""); // 7FFFFF80 = max float < 2^31
  249.  
  250.     llDialog(llGetOwner(), product + "\n\n" + text, order_buttons(menu_items), menu_channel);
  251.  
  252.     llSetTimerEvent(600);
  253.  
  254. }
  255.  
  256.  
  257.  
  258. integer check_for_RLV()
  259.  
  260. {
  261.  
  262.     if (llGetInventoryType(RLV_script) == INVENTORY_SCRIPT)
  263.  
  264.     {
  265.  
  266.         return TRUE;
  267.  
  268.     }
  269.  
  270.     return FALSE;
  271.  
  272. }
  273.  
  274.  
  275.  
  276. default
  277.  
  278. {
  279.  
  280.     state_entry()
  281.  
  282.     {
  283.  
  284.         MENU_TYPES = SIT_TYPES;
  285.  
  286.         llMessageLinked(LINK_SET, 90202, (string)check_for_RLV(), "");
  287.  
  288.     }
  289.  
  290.  
  291.  
  292.     timer()
  293.  
  294.     {
  295.  
  296.         llSetTimerEvent(0);
  297.  
  298.         llListenRemove(menu_handle);
  299.  
  300.     }
  301.  
  302.  
  303.  
  304.     link_message(integer sender, integer num, string msg, key id)
  305.  
  306.     {
  307.  
  308.         if (num == 90201)
  309.  
  310.         {
  311.  
  312.             llMessageLinked(LINK_SET, 90202, (string)check_for_RLV(), "");
  313.  
  314.         }
  315.  
  316.         else if (num == 90006)
  317.  
  318.         {
  319.  
  320.             if (llGetInventoryType(menucontrol_script) != INVENTORY_SCRIPT)
  321.  
  322.             {
  323.  
  324.                 register_touch(id, (integer)msg, sender, FALSE);
  325.  
  326.             }
  327.  
  328.         }
  329.  
  330.         else if (num == 90100)
  331.  
  332.         {
  333.  
  334.             list data = llParseString2List(msg, ["|"], []);
  335.  
  336.             if (llList2String(data, 1) == "[SECURITY]")
  337.  
  338.             {
  339.  
  340.                 if (id == llGetOwner())
  341.  
  342.                 {
  343.  
  344.                     active_prim = sender;
  345.  
  346.                     active_script_channel = llList2Integer(data, 0);
  347.  
  348.                     active_sitter = llList2Key(data, 2);
  349.  
  350.                     main_menu();
  351.  
  352.                 }
  353.  
  354.                 else
  355.  
  356.                 {
  357.  
  358.                     llRegionSayTo(id, 0, "Sorry, only the owner can change security settings.");
  359.  
  360.                     llMessageLinked(sender, 90101, llList2String(data, 0) + "|[ADJUST]|" + (string)id, llList2Key(data, 2));
  361.  
  362.                 }
  363.  
  364.             }
  365.  
  366.         }
  367.  
  368.         else if (num == 90033)
  369.  
  370.         {
  371.  
  372.             llListenRemove(menu_handle);
  373.  
  374.         }
  375.  
  376.     }
  377.  
  378.  
  379.  
  380.     listen(integer listen_channel, string name, key id, string msg)
  381.  
  382.     {
  383.  
  384.         if (msg == "Sit")
  385.  
  386.         {
  387.  
  388.             dialog("Sit security:", SIT_TYPES);
  389.  
  390.             lastmenu = msg;
  391.  
  392.             return;
  393.  
  394.         }
  395.  
  396.         else if (msg == "Menu")
  397.  
  398.         {
  399.  
  400.             dialog("Menu security:", MENU_TYPES);
  401.  
  402.             lastmenu = msg;
  403.  
  404.             return;
  405.  
  406.         }
  407.  
  408.         else
  409.  
  410.         {
  411.  
  412.             if (msg == "[BACK]")
  413.  
  414.             {
  415.  
  416.                 llMessageLinked(LINK_SET, 90101, (string)active_script_channel + "|[ADJUST]|" + (string)id, active_sitter);
  417.  
  418.             }
  419.  
  420.             else if (lastmenu == "Sit")
  421.  
  422.             {
  423.  
  424.                 SIT_INDEX = llListFindList(SIT_TYPES, [msg]);
  425.  
  426.                 main_menu();
  427.  
  428.                 check_sitters();
  429.  
  430.                 return;
  431.  
  432.             }
  433.  
  434.             else if (lastmenu == "Menu")
  435.  
  436.             {
  437.  
  438.                 MENU_INDEX = llListFindList(MENU_TYPES, [msg]);
  439.  
  440.                 main_menu();
  441.  
  442.                 return;
  443.  
  444.             }
  445.  
  446.         }
  447.  
  448.         llListenRemove(menu_handle);
  449.  
  450.     }
  451.  
  452.  
  453.  
  454.     changed(integer change)
  455.  
  456.     {
  457.  
  458.         if (change & CHANGED_LINK)
  459.  
  460.         {
  461.  
  462.             check_sitters();
  463.  
  464.         }
  465.  
  466.     }
  467.  
  468.  
  469.  
  470.     touch_end(integer touched)
  471.  
  472.     {
  473.  
  474.         if (check_for_RLV() || llGetAgentSize(llGetLinkKey(llGetNumberOfPrims())) != ZERO_VECTOR)
  475.  
  476.         {
  477.  
  478.             register_touch(llDetectedKey(0), 0, llDetectedLinkNumber(0), TRUE);
  479.  
  480.         }
  481.  
  482.     }
  483.  
  484. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement