Jump to content
Sign in to follow this  
Clarke Kondor

Key2Names plus profile picture

Recommended Posts

This code will allow you to get the User Name, Display Name and Profile picture UUID all with a single call.  The avatar does not have to be in the same sim as the object and it is super fast.

- Clarke

 

//Clarke Kondor, June 2011;
// Returns the User Name and Profile Picture UUID plus the current Display Name (if one exists) with a single call
// This demo version will say the names to you and put the picture on all sides of the prim

/////////////////////////WARNING//////////////////////////////
// This function uses the SL World API as of June 29, 2011
// LL does not support this API
// If LL changes the format of this API your content may break
//////////////////////////////////////////////////////////////


string TargetKey = "96ce2eec-03c4-46f6-9068-a92444650139"; // put the key of the target avatar here


string URL = "http://world.secondlife.com/resident/";
key kReq;
string UserName;
string DisplayName;
string ProfilePicUUID;

default
{

    touch_start(integer total_number)
    {
        kReq = llHTTPRequest(URL + TargetKey,[],"");
    }

    http_response(key request_id, integer status, list metadata, string body)
    {
        if( request_id == kReq)
        {

            integer StartIndex = llSubStringIndex(body,"<title>");
            integer EndIndex = llSubStringIndex(body,"</title>");

            if(status !=200)
            {
                UserName = "NULL";
                DisplayName = "NULL";
                ProfilePicUUID = "NULL";
            }

            else
            {
                if( StartIndex == -1)
                {
                    UserName = "NULL";
                    DisplayName = "NULL";
                }
                else
                {
                    string tempString = llGetSubString(body,StartIndex+7,EndIndex-1);
                    integer tempIndex = llSubStringIndex(tempString,"(");
                    if( tempIndex >=0) // contains both a UserName and DisplayName
                    {
                        DisplayName = llGetSubString(tempString,0,tempIndex-1);
                        UserName = llGetSubString(tempString,tempIndex+1,-2);
                    }

                    else // contains User Name only
                    {
                        DisplayName = "NULL";
                        UserName = tempString;
                    }
                    tempIndex = llSubStringIndex(body,"imageid")+18;
                    if( tempIndex >17)ProfilePicUUID = llGetSubString(body,tempIndex,tempIndex+35);
                    else ProfilePicUUID = "NULL";
                }
            }

            llOwnerSay("Display Name is " + DisplayName + "\nUser Name is " + UserName + "\nProfile Picture UUID is " + ProfilePicUUID);
            llSetTexture(ProfilePicUUID, ALL_SIDES);
        }


    }
}

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...