Jump to content

get agent group key


Cielo Aulder
 Share

You are about to reply to a thread that has been inactive for 1785 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I can't find a way to get the group key of the avatar touching an object.

What i wanna do is making my object work only for people on a certain group. Problem is, to avoid auto-return, my object is set on a different group.

I am pretty sure there's a possible way of doing this, cause i've seen other objects doing it. The owner enters the group key on the description and it only works for that group.

So far all i could find about groups is llDetectedGroup and llSameGroup which are very similar from what i understand, it just returns true or false whether the avatar touching it has the same active group as the object. In my case i don't want to compare the avatar's active group to the object's group but to a key stored on a variable. Is that possible?, if not .. what is it that, the object i've seen with the key on the description, can be doing?

Edited by Cielo Aulder
Link to comment
Share on other sites

There's no way to detect the group that an avatar has active other that by comparing it to the group key of an object.  That's what llSameGroup and llDetectedGroup are for. I can imagine a way to use a stored group key, but it would be indirect.

First, as you say, store the group key that you want to match the avatar's group key (call it my_stored_group_key)  in the Description field of your object.  Then, create an object for members of your "certain group" to wear -- a piece of jewelry named secret_group_jewelry , perhaps.  Then you write a script for your object that looks for the group key of that piece of jewelry.  It's more than a little tricky. 

In the state_entry event of your script, read the value my_stored_group_key from the Description field of your object, where you stored it.  Be sure it's a global key variable so that it will be accessible in your touch_start event later.

Then the touch_start event in your script could look something like this:

touch_start(integer num)
{
    key kAv = llDetectedKey(0);
    list worn = llGetAttachedList(kAv);  // This is a list of UUIDs of all the things that the avatar is wearing
    integer i;
    while( i < llGetListLength(worn) )    // So look through the list, one item at a time
    {
        list details = llGetObjectDetails( llList2Key(worn, i)), [OBJECT_NAME, OBJECT_GROUP])  // Get the item's name and group UUID
        string name = llList2String(details,0);
        if (name == "secret_group_jewelry" && llList2Key(details,1) == my_stored_group_key) // If it's the secret jewelry and in the right group
        {
            llSay(0,"Bingo!  This guy is in my secret group!");
        }
        ++i;
    }
}

 This works because the group key of the secret_group_jewelry will be the same as the active group key of the person wearing it.  You are thus indirectly comparing the avatar's active group key to whatever is stored in your object's Description field.

Edited by Rolig Loon
  • Like 2
Link to comment
Share on other sites

But @Rolig Loon, have you forgotten my explanation about attachments and active groups?

  1. You get a list of the avatar's attachments with llGetAttachedList.
  2. You just take the first attachment from that list, and use llGetObjectDetails with OBJECT_GROUP.
  3. You will now have the group that attachment is in, which will always be the avatar's active group (if any).
  • Like 4
  • Thanks 1
Link to comment
Share on other sites

That's a very good observation.  No, I had forgotten that you ever said that.  The only advantage that my twist on it has is that it adds another layer of security.  if you decide that Avatar X is no longer welcome, you give everyone else a new piece of no-transfer jewelry and tell your script to look for it instead.  Then when Avatar X shows up and is wearing the old jewelry, the object doesn't recognize him.  He may have the right key, but not the right jewelry.

Anyway, except for that potentially valuable wrinkle, your solution suits the OP's need and is easier for the OP to use.  Thanks.

Link to comment
Share on other sites

Two tiny caveats:

  1. It's still theoretically possible for an avatar to have no attachments at all, and
  2. I'm pretty sure an attachment "put on" directly while rezzed in-world (rather than worn or added from inventory) will retain the group setting it had while rezzed unattached, until the avatar changes active group

[ETA a third: If the avatar leaves their active group, their attachments will stay set to that group of which they're no longer a member. I'd guess the same would apply if they were ejected from the group.]

Edited by Qie Niangao
  • Like 2
  • Thanks 1
Link to comment
Share on other sites

Thanks for your help. I think i could check for the group of any attached object on the avatar, and i'm pretty sure it will work most of the times, but it will still have the problems that Qie Niangao mentioned.

I really wonder how, that object i've seen doing this, works. I'll have to buy it and see if i can discover something. Anyway.. thanks so much for your help!

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1785 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...