<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.secondlife.com/w/index.php?action=history&amp;feed=atom&amp;title=User%2FDigit_Ditko%2Ffind_group_key_of_avatar</id>
	<title>User/Digit Ditko/find group key of avatar - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.secondlife.com/w/index.php?action=history&amp;feed=atom&amp;title=User%2FDigit_Ditko%2Ffind_group_key_of_avatar"/>
	<link rel="alternate" type="text/html" href="https://wiki.secondlife.com/w/index.php?title=User/Digit_Ditko/find_group_key_of_avatar&amp;action=history"/>
	<updated>2026-06-25T12:28:50Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://wiki.secondlife.com/w/index.php?title=User/Digit_Ditko/find_group_key_of_avatar&amp;diff=1200611&amp;oldid=prev</id>
		<title>Digit Ditko: Created page with &quot;{{TOCright}}  == Get Group Key for an Avatar&#039;s current group == This script demonstrates how to retrieve an avatar&#039;s active group key.  By retrieving the a actual key, a scrip...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.secondlife.com/w/index.php?title=User/Digit_Ditko/find_group_key_of_avatar&amp;diff=1200611&amp;oldid=prev"/>
		<updated>2016-07-06T20:53:52Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{TOCright}}  == Get Group Key for an Avatar&amp;#039;s current group == This script demonstrates how to retrieve an avatar&amp;#039;s active group key.  By retrieving the a actual key, a scrip...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{TOCright}}&lt;br /&gt;
&lt;br /&gt;
== Get Group Key for an Avatar&amp;#039;s current group ==&lt;br /&gt;
This script demonstrates how to retrieve an avatar&amp;#039;s active group key.  By retrieving the a actual key, a script can test for membership on one or more groups.   &lt;br /&gt;
&lt;br /&gt;
To get the active group of an avatar, get the attachment list of the avatar and then get the group for one of the attachments.  Obviously this will fail if the avatar has no attachments, but how many avatars walk around with nothing attached (they would have to wear all system clothes and system hair).&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lsl2&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// Get the active group from the avatar specified by inAvatar.&lt;br /&gt;
// return the group key, a NULL_KEY is returned if the group &lt;br /&gt;
// cannot be determined&lt;br /&gt;
key&lt;br /&gt;
getAvatarGroup (key inAvatar)&lt;br /&gt;
{&lt;br /&gt;
    key result = NULL_KEY;&lt;br /&gt;
    &lt;br /&gt;
    // get the the list of attachments for the avatar &lt;br /&gt;
    list parts = llGetAttachedList (inAvatar);&lt;br /&gt;
    if (llGetListLength (parts) &amp;gt; 0)&lt;br /&gt;
    {&lt;br /&gt;
         // If the avatar has any attachments then just get the &lt;br /&gt;
         // group key for the first attachment.&lt;br /&gt;
         list parts2 = llGetObjectDetails (llList2Key (parts, 0), [OBJECT_GROUP]);  &lt;br /&gt;
         result = llList2Key (parts2, 0);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    return (result);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// ------------------------------------------&lt;br /&gt;
&lt;br /&gt;
default&lt;br /&gt;
{&lt;br /&gt;
    &lt;br /&gt;
    touch_start (integer total_number)&lt;br /&gt;
    {&lt;br /&gt;
        key av = llDetectedKey (0);&lt;br /&gt;
        key groupId = getAvatarGroup (av);&lt;br /&gt;
        &lt;br /&gt;
        llInstantMessage (av, &amp;quot;group = &amp;quot; + (string) groupId);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Digit Ditko</name></author>
	</entry>
</feed>