Jump to content

Lost in getting owner ID


Reivan
 Share

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

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

Recommended Posts

Hello i want to make hud with two buttons that show hide obiects wearing by avatar.

Avatar have weared not linked two objects A and B, hud have two buttons A and B, when i click A button it shows A object and hide B object, When i click B button it shows B object and hide A object.

I managed to make this hud button script:

default
{
    on_rez(integer rez)
    {  
        if 
        (!llGetAttached() )  
        llResetScript();      
    }
    state_entry()
    {  
       llRequestPermissions( llGetOwner(), PERMISSION_ATTACH); 
    }
    touch_start(integer total_number)
    { 
            llRegionSay( -20,"off" );
    }
}

And this object script:

string ANIM = "animation";
integer an = 0;

default
{
    state_entry()
    { 
        llListen(-20, "", NULL_KEY, "");
        llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
    }
       
    listen(integer channel, string name, key id, string message)
    { 
    if (llGetOwner() == llGetOwnerKey(id) ) 
    {
        if(message == "off")
      {  
        llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
        llSetLinkAlpha(LINK_THIS, 0.0, ALL_SIDES);
        an=1;
      }
      if(message == "on")
      {  
        llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
        llSetLinkAlpha(LINK_THIS, 1.0, ALL_SIDES);
        an=0;
      }
    }
    }
        run_time_permissions(integer perm)
    {
        if (perm & PERMISSION_TRIGGER_ANIMATION)
        {
            if (an)
                llStartAnimation(ANIM);
            else
                llStopAnimation(ANIM);
        }
    }
}

And it somehow work but with one problem, i tested it on my friend avatar and when i use hud my friend avatar is also controled, i spend couple of hours on this and nothing i tried works, anyone willing to help me with this making it to work only on owner avatar?

Edited by Reivan
Link to comment
Share on other sites

Yup.

If the new owner manually reset the scripts, that would fix it too, but you shouldn't ever count on the new owner doing that.  If your script ever relies on knowing who llGetOwner is, it's best to reset it if you expect the owner to change.

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

FWIW, this is why it's very useful to put something like

changed(integer c)
{   if(c&CHANGED_OWNER)
    {   llResetScript();
    }
}

in most scripts in things intended to be given to someone else. It also often saves you from passing along 'personal settings' that may have changed from default values.

  • Like 3
  • Thanks 2
Link to comment
Share on other sites

On 5/2/2023 at 9:55 PM, Quistess Alpha said:

FWIW, this is why it's very useful to put something like

changed(integer c)
{   if(c&CHANGED_OWNER)
    {   llResetScript();
    }
}

in most scripts in things intended to be given to someone else. It also often saves you from passing along 'personal settings' that may have changed from default values.

I now just do llResetScript() on_rez.

Then the thing just pulls its previous state from LSD and all is well.

  • Like 1
Link to comment
Share on other sites

Either way works. If you don't want to force a restart for some reason,  you can also use Tessa's way to just change the owner. 

if (c&CHANGED_OWNER)

Owner = llGetOwner();

Where you are using a global key variable to hold the UUID. 

Link to comment
Share on other sites

1 hour ago, Rolig Loon said:

Either way works. If you don't want to force a restart for some reason,  you can also use Tessa's way to just change the owner. 

if (c&CHANGED_OWNER)

Owner = llGetOwner();

Where you are using a global key variable to hold the UUID. 

and remember to remove and reset any owner-only listens, and re-set important config values if applicable.

  • Like 2
Link to comment
Share on other sites

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