Jump to content

Best way to test if a string is a valid UUID of an avatar (not nearby and/or offline)?


DorianaCele
 Share

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

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

Recommended Posts

Hello,

So I have a string and I wanna see if it is a valid UUID of an avatar. The candidate string may have the following properties:

(1). Its length be less or more than 36 (the length of a UUID)

(2). If its length is 36, it may not be a valid UUID of anything

(3). If it is a valid UUID, it may not be a UUID of an avatar

(4). If it is a UUID of an avatar, the avatar may not be nearby or online. (I guess this preludes usage of llGetDisplayName() and llGetObjectDetails())

And what I want is a function to test if the spot string is a valid UUID of any avatar. Say returns 1 if it is and 0 if it is not. Any good strategy? 

Link to comment
Share on other sites

As Ron suggests, I can only think of using an llRequestAgentData/Username/DisplayName function.

These, however, do not raise a dataserver event if the key isn't a valid agent key, so you might also need to set up a timeout to catch that. I've no idea what a sensible timeout for a dataserver request might be. Maybe a second or two.

Oh, in this post: 

Rolig suggests it might be that agent UUIDs have a "4" as the 15th character. I cannot confirm or refute this, but it might be worth further investigation.

  • Like 1
Link to comment
Share on other sites

32 minutes ago, KT Kingsley said:

Rolig suggests it might be that agent UUIDs have a "4" as the 15th character. I cannot confirm or refute this, but it might be worth further investigation.

Seems to hold true. I wrote a script to check for this condition and went through a dozen of top-traffic sims with it. Wasn't able to find any avatars that didn't have a "4" there. It's a small sample size, but there is a very clear pattern there.

default
{
    touch_start(integer total_number)
    {
        list avatars = llGetAgentList(AGENT_LIST_REGION, []);
        integer i = llGetListLength(avatars);

        llOwnerSay("Checking...");
        while (i--)
        {
            string av = llList2String(avatars, i);

            if (llGetSubString(av, 14, 14) != "4")
                llOwnerSay(llKey2Name(av) + "'s key doesn't match!");
            // else
            //     llOwnerSay(llKey2Name(av) + "'s key matches.");
        }
        llOwnerSay("Done.");
    }
}

But this doesn't prove that objects can't have a "4" there as well. In fact when I went to a pretty empty sandbox and box-selected someone's build of about 155 objects and inspected their keys, there were 11 objects where the 15th character was "4". So just checking for that number doesn't prove that it's an avatar.

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

a way to do this, to avoid the data server event not firing when not a agent uuid, is to use HTTP.  This does respond. And if the server is troubled then the http query key will return NULL_KEY

example

default
{
    state_entry()
    {
        key id = llGetOwner(); // some legit agent key 
        // key id = llGetKey();
            
        key queryAgent = llHTTPRequest("http://world.secondlife.com/resident/" + (string)id, [HTTP_METHOD,"GET"], "");
        if (queryAgent == NULL_KEY) 
            llOwnerSay("HTTP no response");
        
    }
    
    http_response(key id, integer status, list meta, string body)
    {
        // for valid agent key, body will be a profile page
        // or will be a error: page not found
                
        integer isAgent = llSubStringIndex(body, "error-page") != 36;
        llOwnerSay(llList2String(["NOT AGENT", "IS AGENT"], isAgent));       
    }
}

 

 

  • Like 3
Link to comment
Share on other sites

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