Avatar picture display on HUD

Répondre
Partager Rechercher
Hi,
Me again yes ... trying to finish my personal AIO PHONE STYLED HUD:

I have this script to display my profile picture, but when i change profile picture it doesn't change:

Code:
key ppReqID;
key ProfilePic;
getProfilePic(key AvatarKey)
{
    ppReqID = llHTTPRequest( "http://world.secondlife.com/resident/" + (string)AvatarKey,[HTTP_METHOD,"GET"],"");
}
setProfilePic(key Texture)
{
    if (Texture != NULL_KEY)
    {
        llSetTexture(Texture,ALL_SIDES);
    }
    else llOwnerSay("Invalid texture returned!");
}
string Who(key id)
{
    return "secondlife:///app/agent/" + (string)id + "/about";
}
default
{
    state_entry()
    {
        getProfilePic(llGetOwner());
    }
    http_response(key req,integer stat, list meta, string body)
    {
        if (req == ppReqID)
        {
            integer s1  = llSubStringIndex(body,"<meta name=\"imageid\" content=\""); // Find the image in html
            ProfilePic = (key)llGetSubString(body,s1+30,s1+65); // After the search text, and for 35 chars is UUID
            if(s1 == -1) ProfilePic = NULL_KEY; // If it wasn't found, they have no profile pic
            setProfilePic(ProfilePic); // Set the texture
        }
    }
    touch_start(integer num)
    {
        llSay(0, "Open profile " + Who(llDetectedKey(0)) + "." );
    }
changed(integer change)
    {
        if (change & CHANGED_OWNER) 
        {
            llResetScript();
        }
    }}
your script is good, but it request hhtp only once in state_entry....that means on rez or after reset...
this one check the profile pic on each click....but expect sometimes a long refreshing time from LL server, I tested it, sometimes over an hour....



string URL_RESIDENT = "http://world.secondlife.com/resident/";
key owner;
string meta_find = "<meta name="imageid" content="";

default
{
on_rez(integer r)
{
llResetScript();
}

state_entry()
{
owner = llGetOwner();
llSetTexture(TEXTURE_BLANK,ALL_SIDES);
}

touch_start(integer n)
{
if( llDetectedKey(0) == owner)
llHTTPRequest( URL_RESIDENT + (string)owner,[HTTP_METHOD,"GET"],"");
}

http_response(key req,integer stat, list met, string body)
{
integer meta_pos = llSubStringIndex(body, meta_find) + llStringLength(meta_find);
string texture = llGetSubString(body, meta_pos, meta_pos + 35);
llSetTexture(texture, ALL_SIDES);
}

changed(integer change)
{
if (change & CHANGED_OWNER)
{
llResetScript();
}
}
}
Répondre

Connectés sur ce fil

 
1 connecté (0 membre et 1 invité) Afficher la liste détaillée des connectés