Advertisement
Dorex

Profile picture

Oct 10th, 2024 (edited)
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. //##############################################################################
  3. //
  4. // Get Profile Picture
  5. //
  6. // Dorex Delicioso 2023
  7. //
  8. // YouTube: https://www.youtube.com/@SecondLifeSimplyScripting
  9. // Marketplace: https://marketplace.secondlife.com/stores/173632
  10. //
  11. //#############################################################################
  12.  
  13. //
  14. // Pass an avatar id into getProfilePic and the picture key will be sent to setProfilePicture
  15. //
  16. // ############################## VARIABLES ####################################
  17.  
  18. key ppReqID;    
  19.  
  20. // ############################## FUNCTIONS ####################################
  21. //
  22. getProfilePic(key avId)
  23. {
  24.     ppReqID = llHTTPRequest( "http://world.secondlife.com/resident/" + (string)avId, [HTTP_METHOD, "GET"], "");
  25. }
  26.  
  27. setProfilePicture(key pictureKey)
  28. {
  29.     llSetTexture(pictureKey, ALL_SIDES );
  30. }
  31.  
  32. // ############################## DEFAULT STATE ##############################
  33. // ############################## DEFAULT STATE ##############################
  34. // ############################## DEFAULT STATE ##############################
  35.  
  36. default
  37. {
  38.     state_entry()
  39.     {
  40.         getProfilePic(llGetOwner());
  41.     }
  42.  
  43.     http_response(key req,integer stat, list meta, string body)
  44.     {
  45.         if (req == ppReqID)
  46.         {
  47.             //https://wiki.secondlife.com/wiki/Profile_Picture_Retrieval
  48.            
  49.             integer index  = llSubStringIndex(body,"<meta name=\"imageid\" content=\""); // Find the image in html
  50.             key pictureKey = (key)llGetSubString(body, index + 30, index + 65);          // After the search text, and for 35 chars is UUID
  51.             if(index == -1) pictureKey = NULL_KEY;                                       // If it wasn't found, they have no profile pic
  52.             setProfilePicture(pictureKey);
  53.         }
  54.     }
  55.  
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement