De DigiWiki.
// Credit goes to Jana Kamachi/Solar Alter
// for discovering this concept first
// and taking it beyond just displaying the profile picture
// see http://forums.secondlife.com/showthread.php?t=225460
// and https://wiki.secondlife.com/wiki/User:Jana_Kamachi/Profile
// for further information
string RESIDENT_URL = "http://world.secondlife.com/resident/";
key WHITE_DEFAULT_TEXTURE = "5748decc-f629-461c-9a36-a35a221fe21f";
integer DIALOG_CHANNEL = -123654;
string DIALOG_MSG = "By hitting the I Agree button below, you give permission for this script to access your profile texture UUID.";
list KILLJOY_MENU = ["I Agree", "I Disagree"];
integer Dialog_Handle;
default
{
state_entry()
{
llSetText("", <1,0,0>, 1.0); // Erase hover text
llSetTexture(WHITE_DEFAULT_TEXTURE, ALL_SIDES); // Set to default texture
}
touch_start(integer num_detected)
{
// Set up dialog menu to get avatar approval before displaying their
// profile pick. Only listen to the avatar that touched me.
Dialog_Handle = llListen(DIALOG_CHANNEL, "", llDetectedKey(0), "");
// Display dialog popup
llDialog(llDetectedKey(0), DIALOG_MSG, KILLJOY_MENU, DIALOG_CHANNEL);
}
listen(integer channel, string name, key id, string message)
{
if (message == "I Agree")
{ // They agreed so continue to get their avatar profile picture
// Get page from new search engine for the avatar that touched me
llHTTPRequest( RESIDENT_URL + (string)id,[HTTP_METHOD,"GET"],"");
llSetText(name, <1,0,0>, 1.0); // Display avatar name as hover text
}
llListenRemove(Dialog_Handle); // Shut down dialog listener
}
on_rez(integer start_param)
{
llSetText("", <1,0,0>, 1.0); // Erase hover text
llSetTexture(WHITE_DEFAULT_TEXTURE, ALL_SIDES); // Set to default texture
}
http_response(key request_id,integer status, list metadata, string body)
{
// If the profile has no picture the image name will be
// http://world.secondlife.com/images/blank.jpg
if (llSubStringIndex(body, "blank.jpg") == -1) // If a profile picture exists
{
// Find starting point of the profile picture UUID
integer start_of_UUID = llSubStringIndex(body,"<img alt=\"profile image\" src=\"http://secondlife.com/app/image/") + llStringLength("<img alt=\"profile image\" src=\"http://secondlife.com/app/image/");
// Find ending point of profile picture UUID
integer end_of_UUID = llSubStringIndex(body,"\" class=\"parcelimg\" />") - 3;
// Parse out profile picture UUID from the body
string profile_pic = llGetSubString(body, start_of_UUID, end_of_UUID);
// Set the sides of the prim to the picture
llSetTexture((key)profile_pic, ALL_SIDES);
}
else
{
llWhisper(0, "You have no profile picture"); // Tell the avatar they have no picture
llSetTexture(WHITE_DEFAULT_TEXTURE, ALL_SIDES); // Set to default texture
}
}
}