Advertisement
Gayngel

Compare group key of avatar without llSameGroup or llDetectedGroup

Jan 29th, 2024 (edited)
1,364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // This script compares the avatar's active group to any specified group in the script and not the group the object has active. To check if an avatar's active group is the same as the object's active group use llSameGroup or llDetectedGroup.
  2.  
  3. // There is no direct way to get the active group key of an avatar but you can get the active group key of one of their attachements which is the same as the avatar's active group.
  4.  
  5. key groupId = "d1228743-d417-938b-db90-52081ed656ba"; // add the key of the group you would like to check if the avatar is a member of
  6.  
  7. default
  8. {
  9.    
  10.  
  11.     touch_end(integer total_number)
  12.     {
  13.         key Toucher =llDetectedKey(0); // get the key of the avatar who touched the prim
  14.         list attachments = llGetAttachedList(Toucher); // get the list of attachments the avatar is wearing
  15.         key a = llList2Key(attachments,0); // get the key of the first attachment in the list  
  16.         list det = llGetObjectDetails(a, [OBJECT_GROUP]);
  17.          // get the active group of the attachment as it will be the same as the active group of the avatar.
  18.        
  19.        key avatarGroupKey = llList2Key(det,0);  // the key will be the first item in the det list
  20.  
  21.      if(avatarGroupKey == groupId) // if the avatar's active group and the groupId are the same
  22.      {
  23.      // do stuff
  24.       llSay(0,"You are a member of the group!");  
  25.          
  26.      }
  27.      
  28.      else
  29.      {
  30.          
  31.      llSay(0,"You are not a member of the group or you haven't got the right group actvated. Please activate the secondlife:///app/group/"+(string)groupId+"/about group. Also please wear at least one attachement. ");    
  32.      }
  33.      
  34.     }
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement