Jump to content

"Unable to find specified agent to request permissions" error on modified [AV]object script (AVsitter2 open-source)


AdminGirl
 Share

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

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

Recommended Posts

I've been modifying the [AV]object script so that a prop can remain attached and keep animating an avatar even after teleporting to another region. I've managed to get the prop to stay attached and keep animating, but once I'm in a different region, I keep getting the error message "Unable to find specified agent to request permissions".

I'm pretty noob to both SL and scripting.. is this the right place to ask?

 

/*
 * [AV]object - Used in props for attaching, derezzing, etc.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * Copyright © the AVsitter Contributors (http://avsitter.github.io)
 * AVsitter™ is a trademark. For trademark use policy see:
 * https://avsitter.github.io/TRADEMARK.mediawiki
 *
 * Please consider supporting continued development of AVsitter and
 * receive automatic updates and other benefits! All details and user
 * instructions can be found at http://avsitter.github.io
 */

string version = "2.020";
integer comm_channel;
integer local_attach_channel = -2907539;
integer listen_handle;
integer prop_type;
integer prop_id;
integer prop_point;
integer experience_denied_reason;
key originalowner;
key parentkey;
key give_prop_warning_request;
list A = [parentkey]; //OSS::list A; // Force error in LSO

unsit_all()
{
    integer i = llGetNumberOfPrims();
    while (llGetAgentSize(llGetLinkKey(i)) != ZERO_VECTOR)
    {
        llUnSit(llGetLinkKey(i));
        i--;
    }
}

integer verbose = 5;

Out(integer level, string out)
{
    if (verbose >= level)
    {
        llOwnerSay(llGetScriptName() + "[" + version + "] " + out);
    }
}

default
{
    on_rez(integer start)
    {
        if (start)
        {
            state prop;
        }
    }
}

state prop
{
    state_entry()
    {
        if (llGetLinkNumber() < 2)
        {
            if (llGetStartParameter() <= -10000000)
            {
                string start_param = (string)llGetStartParameter();
                prop_type = (integer)llGetSubString(start_param, -1, -1);
                prop_point = (integer)llGetSubString(start_param, -3, -2);
                prop_id = (integer)llGetSubString(start_param, -5, -4);
                comm_channel = (integer)llGetSubString(start_param, 0, -6);
                listen_handle = llListen(comm_channel, "", "", "");
                llSay(comm_channel, "REZ|" + (string)prop_id);
            }
            else
            {
            }
        }
        if (prop_type != 2 && prop_type != 1)
        {
            if (llGetInventoryType("[AV]sitA") == INVENTORY_NONE)
            {
                llSetClickAction(-1); // OSS::llSetClickAction(CLICK_ACTION_NONE);
            }
        }
        else
        {
            llSetClickAction(CLICK_ACTION_TOUCH);
        }

        //LSL::
        parentkey = llList2String(llGetObjectDetails(llGetKey(), [OBJECT_REZZER_KEY]) + A, 0);
        A = [];

        if(llGetStartParameter() && !llList2Integer(llGetObjectDetails(parentkey, [OBJECT_ATTACHED_POINT]), 0))
        {
            llSetTimerEvent(10);
        }
        else
        {
            llSetTimerEvent(0);
        }
        //::LSL
    }

    attach(key id)
    {
        if (comm_channel)
        {
            if (llGetAttached())
            {
                llListen(local_attach_channel, "", "", "");
                llSay(comm_channel, "ATTACHED|" + (string)prop_id);
                llSay(local_attach_channel, "LOCAT|" + (string)llGetAttached());
                if (experience_denied_reason == 17)
                {
                    if (llGetOwner() == originalowner)
                    {
                        list details = llGetExperienceDetails(""); // OSS::list details;
                        if (llList2String(details, 3) == "17")
                        {
                            llSay(comm_channel, "NAG|" + llList2String(details, 0));
                        }
                    }
                }
            }
            else
            {
                llSay(comm_channel, "DETACHED|" + (string)prop_id);
            }
        }
    }

    touch_start(integer touched)
    {
        if ((!llGetAttached()) && (prop_type == 2 || prop_type == 1))
        {
            llRequestExperiencePermissions(llDetectedKey(0), ""); // OSS::llRequestPermissions(llDetectedKey(0), PERMISSION_ATTACH);
        }
    }

    run_time_permissions(integer permissions)
    {
        if (permissions & PERMISSION_ATTACH)
        {
            if (llGetAttached())
            {
                llDetachFromAvatar();
            }
            else
            {
                llAttachToAvatarTemp(prop_point);
            }
        }
        else
        {
            if (permissions & PERMISSION_ATTACH | PERMISSION_TRIGGER_ANIMATION)
            {
                llStartAnimation(llGetInventoryName(INVENTORY_ANIMATION,0));
            }
        }
    }

    //LSL::
    experience_permissions(key target_id)
    {
        if (llGetAttached())
        {
            llDetachFromAvatar();
        }
        else
        {
            llAttachToAvatarTemp(prop_point);
        }
    }

    experience_permissions_denied(key agent_id, integer reason)
    {
        originalowner = llGetOwner();
        experience_denied_reason = reason;
        llRequestPermissions(agent_id, PERMISSION_ATTACH);
    }
    //::LSL

    on_rez(integer start)
    {
        if (!llGetAttached())
        {
            state restart_prop;
        }
    }

    listen(integer channel, string name, key id, string message)
    {
        list data = llParseString2List(message, ["|"], []);
        string command = llList2String(data, 0);
        if (llList2String(data, 0) == "LOCAT" && llGetOwnerKey(id) == llGetOwner() && llList2String(data, 1) == (string)llGetAttached())
        {
            llRequestPermissions(llDetectedKey(0), PERMISSION_ATTACH);
        }
        else if (command == "ATTACHTO" && prop_type == 1 && (key)llList2String(data, 2) == llGetKey())
        {
            if (llGetAgentSize((key)llList2String(data, 1)) == ZERO_VECTOR)
            {
                llSay(comm_channel, "DEREZ|" + (string)prop_id);
                llDie();
            }
            else
            {
                llRequestExperiencePermissions(llList2Key(data, 1), ""); // OSS::llRequestPermissions(llList2Key(data, 1), PERMISSION_ATTACH);
            }
        }
        else if (llGetSubString(command, 0, 3) == "REM_")
        {
            integer remove;
            if (command == "REM_ALL")
            {
                remove = TRUE;
            }
            else if (command == "REM_INDEX" || (command == "REM_WORLD" && !llGetAttached()))
            {
                if (~llListFindList(data, [(string)prop_id]))
                {
                    remove = TRUE;
                }
            }
            else if (llGetAttached() && command == "REM_WORN" && (key)llList2String(data, 1) == llGetOwner())
            {
                remove = TRUE;
            }
            if (remove)
            {
                if (llGetAttached())
                {
                    llRequestPermissions(llDetectedKey(0), PERMISSION_ATTACH);
                }
                else
                {
                    if (llGetAgentSize(llGetLinkKey(llGetNumberOfPrims())) != ZERO_VECTOR)
                    {
                        unsit_all();
                        llSleep(1);
                    }
                    llSay(comm_channel, "DEREZ|" + (string)prop_id);
                    llDie();
                }
            }
        }
        else if (message == "PROPSEARCH" && !llGetAttached())
        {
            llSay(comm_channel, "SAVEPROP|" + (string)prop_id);
        }
    }

    //LSL::
    timer()
    {
        if(llGetObjectMass(parentkey) == 0)
        {
            if(!llGetAttached())
            {
                llDie();
            }
            else
            {
                llRequestPermissions(llDetectedKey(0), PERMISSION_ATTACH);
            }
        }
    }
    //::LSL
}

state restart_prop
{
    state_entry()
    {
        state prop;
    }
}

 

Edited by AdminGirl
code added
Link to comment
Share on other sites

35 minutes ago, Innula Zenovka said:

This is certainly the place to ask, but without seeing the script it's a bit difficult to diagnose the problem.

You can use the <> toolbar button in the edit window (next to the smiley) to paste your formatted code in messages here.

Thanks for letting me know Innula 🙂

Link to comment
Share on other sites

I'm not sure I quite understand what the [AV]object script is supposed to do... don't temp attached objects remain attached normally through teleports? I thought only a logoff would remove them?

However, I glanced over the code and the first thing that jumps out at me is your use of llDetectedKey(0). That function only returns meaningful results when used in a few very specific events. From the wiki page:

Quote

llDetected* functions only work if called from within Detection events (collision, collision_start, collision_end, sensor, touch, touch_start, touch_end) or in functions called by Detection events. They will fail silently and return unusable values if called during other events.

So your error is probably occurring when you try to feed it into the llRequestPermissions function inside your listen and timer events. Perhaps you could replace that with llDetectedKey in those events with llGetOwner, since an object has to be owned by the avatar wearing it. And in the case of temp attach, ownership is transferred to the new target for the duration of the temp attachment's worn existence.

 

Edited by Fenix Eldritch
  • Thanks 1
Link to comment
Share on other sites

39 minutes ago, Fenix Eldritch said:

I'm not sure I quite understand what the [AV]object script is supposed to do... don't' attached objects remain attached normally?

However, I glanced over the code and the first thing that jumps out at me is your use of llDetectedKey(0). That function only returns meaningful results when used in a few very specific events. From the wiki page:

So your error is probably occurring when you try to feed it into the llRequestPermissions function inside your listen and timer events. Perhaps you could replace that with llDetectedKey in those events with llGetOwner, since an object has to be owned by the avatar wearing it. And in the case of temo attach, ownership is transferred to the new target for the duration of the temp attachment's worn existence.

 

Thanks for your reply Fenix.

The [AV]object script is used so that when an object is touched, a menu appears. When a menu button is selected and if permission to animate is granted, a prop will attach to the avatar. The [AV]object script is for the prop, and two other scripts are dropped into the object that is touched.

I've seen it used in a cake object, and after touching it, an avatar is animated to eat the cake with props and even after teleporting away, the animation and attachment remains.

After changing the llDetectedKey(0) to llGetOwner, the error messages don't appear anymore (yay), but the attachment disappears after teleporting.

Link to comment
Share on other sites

I'm being a bit slow today, having trouble fully comprehending the flow of the code. But there are a few thoughts that come to mind.

Your code has three instances of calling llDie and another three instances that call llDetatchFromAvatar. Either of these will potentially remove the temp attachment. So I would suggest you add some instrumentation code to see if any of those are being called when you teleport. Basically, stick a llOwnerSay("debug message") line immediately before each llDie and llDetatchFromAvatar function call. Give each one a unique message. This will help indicate which (if any) of these lines are being called when you teleport and narrow down where the problem is occurring.

Now if it turns out that none of the above are being called when you teleport, then the issue may be with the other two scripts you say are being added to the prop. You may need to examine them to make sure they're not calling their own llDie or llDetachFromAvatar.

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

45 minutes ago, Fenix Eldritch said:

I'm being a bit slow today, having trouble fully comprehending the flow of the code. But there are a few thoughts that come to mind.

Your code has three instances of calling llDie and another three instances that call llDetatchFromAvatar. Either of these will potentially remove the temp attachment. So I would suggest you add some instrumentation code to see if any of those are being called when you teleport. Basically, stick a llOwnerSay("debug message") line immediately before each llDie and llDetatchFromAvatar function call. Give each one a unique message. This will help indicate which (if any) of these lines are being called when you teleport and narrow down where the problem is occurring.

Now if it turns out that none of the above are being called when you teleport, then the issue may be with the other two scripts you say are being added to the prop. You may need to examine them to make sure they're not calling their own llDie or llDetachFromAvatar.

Oh you genius, it worked!

It was the first llDetachFromAvatar function under run_time_permissions, so I replaced it with llAttachToAvatarTemp(prop_point) and now it stays attached wherever I go. Thank you so much!

  • Like 1
Link to comment
Share on other sites

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