Jump to content

Attach / Detach Via Experience Permissions


Northmani
 Share

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

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

Recommended Posts

Hi everyone, I'm a beginner scripter, looking for some advice. I've created a HUD that I am looking to attach to visiting Avatars to my sim, then to detach when they leave the sim.

Im wondering how this could be made possible. Any advice welcome, I have experiences set up on my region already just need the attach and detach assist please.

Link to comment
Share on other sites

5 minutes ago, Northmani said:

Hi everyone, I'm a beginner scripter, looking for some advice. I've created a HUD that I am looking to attach to visiting Avatars to my sim, then to detach when they leave the sim.

Im wondering how this could be made possible. Any advice welcome, I have experiences set up on my region already just need the attach and detach assist please.

Well the script can do a change event for detatch and then die. Never tried it though.

  • Like 1
Link to comment
Share on other sites

I did it with an old combat system. My method was as follows :

 

Put the hud inside a box A

Have Box A scan the sim and create a list of avatars on a timer....we will call this list "Scan"

Check that list against another list of people who are already in the sim we will call this list "InSim"

Anyone who is already in the "InSim" list is deleted from the "Scan" list

You then loop through the "Scan" list (Only people who are new will remain)

For each person in the list you :

    -Set the Box A description as their key

    -Rez the HUD

    -Have the HUD grab the person key from the description of Box A using llGetObjectDetails. 

    -Request for experience permissions using llRequestExperiencePermissions.....

    -When accepted in the experience_permissions event you use llAttachToAvatarTemp..

    -Also dont forget to move the persons key from the list "Scan" to the list "InSim"

You might also want to compare "InSim" to "Scan" to remove people from "InSim" who are no longer in the sim

 

 

Link to comment
Share on other sites

3 hours ago, steph Arnott said:

Well the script can do a change event for detatch and then die. Never tried it though.

That's certainly how I would do it

changed (integer change){
	if(change & CHANGED_REGION){
		llDetachFromAvatar();
	}
}

As far as I remember, that works even if the new region doesn't support the experience.  Since temp attach items die when detached , that should be all that's needed

  • Thanks 2
Link to comment
Share on other sites

Just now, Innula Zenovka said:

That's certainly how I would do it


changed (integer change){
	if(change & CHANGED_REGION){
		llDetachFromAvatar();
	}
}

As far as I remember, that works even if the new region doesn't support the experience.  Since temp attach items die when detached , that should be all that's needed

Fastest way i can think of.

Link to comment
Share on other sites

6 hours ago, Innula Zenovka said:

That's certainly how I would do it


changed (integer change){
	if(change & CHANGED_REGION){
		llDetachFromAvatar();
	}
}

As far as I remember, that works even if the new region doesn't support the experience.  Since temp attach items die when detached , that should be all that's needed

Thanks for the help everyone, though I'm fairly sure I'm putting this in the wrong place since I'm getting; (38, 0 ) : ERROR : Syntax error,

default
{
    state_entry()
    {
        llRequestPermissions( llGetOwner(), PERMISSION_ATTACH );
    }
 
    run_time_permissions( integer vBitPermissions )
    {
        if( vBitPermissions & PERMISSION_ATTACH )
        {
            llAttachToAvatarTemp( ATTACH_HUD_TOP_RIGHT  );
        }
        else
        {
            llOwnerSay( "Permission to attach denied" );
        }
    }
 
    on_rez(integer rez)
    {
        if(!llGetAttached())
        { //reset the script if it's not attached.
            llResetScript();
        }
    }
 
    attach(key AvatarKey)
    {
        if(AvatarKey)
        {//event is called on both attach and detach, but Key is only valid on attach
            integer test = llGetAttached();
            if (test) {
                llOwnerSay( "The object is attached" );
            } else {
                llOwnerSay( "The object is not attached");
            }
        }
changed (integer change){
    if(change & CHANGED_REGION){
        llDetachFromAvatar();
            }
        }
    }
}

 

Link to comment
Share on other sites

1 hour ago, Qie Niangao said:

I think you have the "changed" event handler just inside the "attach" handler, instead of a level further out, just inside the "default()" state. (So try moving a "}" from below to above "changed".)

That's great thank you. It now attaches when its rezzed, then it detaches when you leave sim. But it doesn't auto reattach when you re-enter (if having accepted experience permissions), any ideas?

default
{
    state_entry()
    {
        llRequestPermissions( llGetOwner(), PERMISSION_ATTACH );
    }
 
    run_time_permissions( integer vBitPermissions )
    {
        if( vBitPermissions & PERMISSION_ATTACH )
        {
            llAttachToAvatarTemp( ATTACH_HUD_TOP_RIGHT  );
        }
        else
        {
            llOwnerSay( "Permission to attach denied" );
        }
    }
 
    on_rez(integer rez)
    {
        if(!llGetAttached())
        { //reset the script if it's not attached.
            llResetScript();
        }
    }
 
    attach(key AvatarKey)
    {
        if(AvatarKey)
        {//event is called on both attach and detach, but Key is only valid on attach
            integer test = llGetAttached();
            if (test) {
                llOwnerSay( "The object is attached" );
            } else {
                llOwnerSay( "The object is not attached");
            }
        }
    }
changed (integer change){
    if(change & CHANGED_REGION){
        llDetachFromAvatar();
            }
        }
    }

 

Link to comment
Share on other sites

Oh, hmm, several problems here. (One thing to note: a temp-attached item will vanish when detached, so it's not around to re-attach itself to anybody, so something will need to rez a new one and tell it to whom it should try to attach.)

I think you're following the wiki examples for llAttachToAvatarTemp(), but those are based on non-Experience permissions. Inasmuch as you're using an Experience you may fare better starting from the llRequestExperiencePermissions() example for attaching a HUD.

To get an item to "auto reattach", though, you presumably don't want to wait for the collision event that's used in that example. Still, you'll need some sort of trigger for rezzing that item again when the avatar re-appears on the scene. ( @chibiusa Ling mentioned scanning avatars on the sim for victims targets; that might involve a timer() calling llGetAgentList() to look for new or returning candidates.)

In passing, if you do temp-attach using Experience permissions, the following note from the wiki's llAttachToAvatarTemp() doc describes how such items  can auto-detach without needing any explicit scripting:

Quote
  • If attached via a Land Scope Experience script, the object will be forced detached by the server if the owner enters a parcel that does not have the Experience allowed.

 

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

@Qie Niangao  I know it's supposed to detach automatically when you enter a parcel that doesn't have the Experience allowed but, at least in my experience, that's not wholly reliable.

At least it certainly wasn't particularly reliable during the early days of Experience Tools, shortly after they were released.   Then I ran into all sorts of difficulties with HUDs not detaching after people left the region, so I got into the habit of including some code to ensure that they would definitely detach even if the expected automatic detach didn't work.

That, however, may now be redundant.  I don't know because I've always -- possibly now unnecessarily -- included similar code since then to ensure things work at expected.

Edited by Innula Zenovka
  • Thanks 1
Link to comment
Share on other sites

22 minutes ago, Innula Zenovka said:

That, however, may now be redundant.  I don't know because I've always -- possibly now unnecessarily -- included similar code since then to ensure things work at expected.

For the sake of a few lines i would rather be 100% sure.

Edited by steph Arnott
  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1859 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...