Group Information v1.0

From Second Life Wiki
Jump to navigation Jump to search

With this script you can retrieve information about the group that is set on the prim. This information is downloaded from the official Second Life Search page.
Here you can see what kind of information the script retrieves.

  • The name of the group
  • What the content of the group is. (PG, Mature or Adult)
  • What the group enrollment is. (open or closed)
  • How much an avatar needs to pay to get into the group. (Group fee)
  • And last but not least, How many members there are in the group.


Below here are 2 scripts, the first one says the information on local chat. The second gives you a dialog with all the information and a print option that prints all information on the local chat.


Group Information Without Dialog)

<lsl> //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=// // // // Group Information script v1.0 // // Without dialog menu // // Created by: Tyrennic Rivera // // Finished on: June 10 2009 // // All Rights Reserved // // // // This script is free software: you can redistribute it and/or modify // // it under the terms that you share this script with other people. // // - You are allowed to use this script in your products however the // // script may not be sold stand alone under any circumstance. // // - If you give this script to other people please give the original // // script with this license. // // // // http://creativecommons.org/licenses/by-sa/3.0/ // // // //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//

key GroupKey; // Key of the group. string GroupName; // The name of the group. string GroupEnroll; // The group enrollment (open or closed). string GroupContent; // Group contents (PG, Mature or Adult). integer GroupFee; // Group fee, How much to pay to join the group. integer GroupCount; // The number of members in the group (Includes owners).

default {

   state_entry()
   {
       llSetObjectName("Group Information");
   }
   
   touch_start(integer total_number)
   {
       // Save the group key for later use.
       GroupKey = llList2Key(llGetObjectDetails(llGetKey(), [OBJECT_GROUP]), 0);
       
       // If a group has been set on the object request group information.
       if(GroupKey != NULL_KEY)
       {
           llHTTPRequest("http://world.secondlife.com/group/" + (string)GroupKey, [], "");
       }
       
       // If no group has been set give a error message.
       else
       {
           llSay(0, "No group has been set. You can set this in build mode under the \"general\" tab.");
       }
   }
       
   http_response(key request_id, integer status, list metadata, string body)
   {
       // This means the page has succesfully loaded.
       if(status == 200)
       {
           // Dont edit this unless you know what you are doing!!
           integer s1 = llSubStringIndex(body, "<title>");
           integer s2 = llSubStringIndex(body, "</title>");
           integer s3 = llSubStringIndex(body, "<meta name=\"member_count\" content=\"");
           integer s4 = llSubStringIndex(body, "<meta name=\"open_enrollment\" content=\"");
           integer s5 = llSubStringIndex(body, "<meta name=\"membership_fee\" content=\"");
           integer s6 = llSubStringIndex(body, "<meta name=\"mat\" content=\"");
           
           // All the group information is saved in these variables.
           GroupName = llGetSubString(body, s1+7, s2-1);
           GroupEnroll = llGetSubString(body, s4+38, s4+38);
           GroupCount = (integer)llGetSubString(body, s3+35, s4-14);
           GroupFee = (integer)llGetSubString(body, s5+37, s6-8);
           GroupContent = llGetSubString(body, s6+26, s1-14);
           
           // When a group contains non-mature content.
           if(GroupContent == "PG_NOT")
           {
               GroupContent = "PG";
           }
           
           // When a group contains mature content.
           else if(GroupContent == "M_NOT")
           {
               GroupContent = "Mature";
           }
           
           // When a group contains adult content.
           else if(GroupContent == "M_AO")
           {
               GroupContent = "Adult";
           }
           
           // If the group enrollment is open.
           if(GroupEnroll == "Y")
           {
               GroupEnroll = "Open";
           }
           
           // Else if the group enrollment is closed.
           else if(GroupEnroll == "N")
           {
               GroupEnroll = "Closed";
           }
           
           // Make a temporary list with the group variables.
           list info = [GroupName, "Content: " + GroupContent, "Enrollment: " + GroupEnroll, "Join fee: L$" + (string)GroupFee, "Members: " + (string)GroupCount];
           
           // Say the group information plus the link to the group.
           llSay(0, llDumpList2String(info, " || ") + "\nsecondlife:///app/group/" + (string)GroupKey + "/about");
       }
       // Triggered when show in search is disabled.
       else if(status == 404)
       {
           llSay(0, "This group has \"Show in search\" disabled, Information cannot be retrieved.");
       }
       
       // If the request has timed out (60 Seconds).
       else if(status == 499)
       {
           llSay(0, "Group information request has timed out.");
       }
   }

} </lsl>