News: SMF - Just Installed!
Welcome, Guest. Please login or register.
Did you miss your activation email?

 Raglan Shire ForumsRaglan ShireThe VaultScriptsTopic: Simple low lag visitor counter with profile pic
Pages: [1]   Go Down
Print
Author Topic: Simple low lag visitor counter with profile pic  (Read 554 times)
Catten Carter
REAG
Friend of the Shire

Offline Offline

Posts: 62



View Profile
« on: June 01, 2009, 07:06:34 AM »

Played around with the profile picture script. Here is a script which will count unique visitors on your place/shop, and display the profile picture of the last visitor on a prim.

Code:
// Script that will record the number of unique visitors (visitors a day)
// and give the possibility to show their profile picture..
// Touch it to get a message with the number of unique visitors.

// If the picture is blank when you rez it, its because it doesn't register
// the owner as a visitor. Also there seems to be cases where no valid picture
// can be found for a resident on the secondlife homepage.

// Face on prim to show picture.
// Use -10 to not show picture, or ALL_SIDES to show on all sides of the prim.
integer face = ALL_SIDES;

// Range to scan for people
float scan_range = 10.0;

// Url to the secondlife website that contains pictures.
// Do not mod here unless site url should change.
string url = "http://world.secondlife.com/resident/";

// Varibles that store the number of visitors.
list todays_visitors = [];
integer unique_visitors = 0;

default
{
    state_entry()  {
        llSensorRepeat("",NULL_KEY,AGENT,scan_range,PI,10);
        llSetTexture("5748decc-f629-461c-9a36-a35a221fe21f",face);
        llSetTimerEvent(86400);
    }

    on_rez(integer rez) {
        llResetScript();
    }
   
    touch_start(integer num_detected) {
        if(llDetectedKey(0) != llGetOwner())
            return;
        llOwnerSay("Total number of unique visitors: "+(string)unique_visitors);
        llOwnerSay("Todays number of unique visitors: "+(string)llGetListLength(todays_visitors));
    }
   
    sensor(integer num_detected) {
        integer i;
        key pic_visitor = NULL_KEY;
        for(i = 0; i < num_detected; ++i) {
            key visitor = llDetectedKey(i);
            if(llListFindList(todays_visitors,[visitor]) == -1 && visitor != llGetOwner()) {
                todays_visitors += visitor;
                ++unique_visitors;
                pic_visitor = visitor;
            }
        }
        if(pic_visitor != NULL_KEY && face != -10)
            llHTTPRequest( url + (string)pic_visitor,[HTTP_METHOD,"GET"],"");
    }
   
    http_response(key request_id, integer status, list metadata, string body) {
        key texture = (key)llGetSubString(body,llSubStringIndex(body,"<img alt=\"profile image\" src=\"http://secondlife.com/app/image/")+llStringLength("<img alt=\"profile image\" src=\"http://secondlife.com/app/image/"),llSubStringIndex(body,"\" class=\"parcelimg\" />")-3);

        if(texture == NULL_KEY)
            return;
         llSetTexture(texture,face);
    }
   
    timer() {
        todays_visitors = [];
    }
}
Logged
Pages: [1]   Go Up
Print
 Raglan Shire ForumsRaglan ShireThe VaultScriptsTopic: Simple low lag visitor counter with profile pic
Jump to: