Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* This is a free fullperm script to record all visitors to a parcel (or region).
- * Unlike most visitor recorders this is not based on range, but by parcel or region boundaries.
- * Names are only recorded once, no matter how often they visit, so this is not a traffic monitor.
- * Names are listed back as profile links, for easy access to information about your visitors.
- * The owner can either touch the object with the script or say 'list' to see the list,
- * or optionally say 'listPublic' to send the list to public chat.
- * If anyone else touches the object it merely quietly reruns the scan. Otherwise it will scane every 'scanHowOften' seconds.
- * You can freely redistribute this script.
- * by Pussycat Catnap. 11/28/2015
- *
- * UPDATE 01/30/2016
- * On the first visit on avatar makes in day, it will now record
- * the time and up a counter by 1 for that day.
- *
- * UPDATE 03/08/2016
- * Now has a MAX_COUNT that is the maximum number of entries on the list.
- * List now shows newest names first, and clears out oldest names as list hits maximum.
- * Added bars above and below list output to make it easier to see in chat.
- * UPDATE 03/09/2016
- * Fixed bars to only appear above and below whole list and not between each name.
- */
- list visitors; // A global record of all avatars that have visited since last script reset.
- integer scanHowOften = 30; // Rerun the region scan every 'scanHowOften' seconds.
- integer MAX_COUNT = 100; // How many names to keep on the list.
- // Uncomment the desire scanDistance setting.
- // Avatars in this parcel
- integer scanDistance = AGENT_LIST_PARCEL;
- // Avatars in parcels in this region owned by the owner of the parcel this is rezzed in.
- // integer scanDistance = AGENT_LIST_PARCEL_OWNER;
- // All avatars in the region.
- // integer scanDistance = AGENT_LIST_REGION;
- string findTimeEntry()
- {
- string rightNow = llGetTimestamp();
- list piecesOfTime = llParseString2List(rightNow,["T", ".","Z"],[]);
- string theTime = "Last seen on " + llList2String(piecesOfTime, 0) + " at UTC time: " + llList2String(piecesOfTime, 1);
- // llSay( 0,theTime);
- return theTime;
- }
- list ListStridedUpdate(list dest, list src, integer start, integer end, integer stride) {
- return llListReplaceList(dest, src, start * stride, ((end + 1) * stride) - 1 );
- }
- // Compares any ID key to the permanent list to prevent duplicate entries
- integer isIDKeyOnList( key id )
- {
- list listofIDs = llList2ListStrided(visitors,0,-1,3);
- integer len = llGetListLength( listofIDs );
- integer i;
- for( i = 0; i < len; i++ )
- {
- if( llList2Key(listofIDs, i) == id )
- {
- list timeCheck = llParseString2List(llList2String(visitors, (i*3)+2),["Last seen on ", " at UTC time: "],[]);
- // Insert a date and visit count update on first visit of each day.
- // We could do this on every scan, but then it would add to the count 1 entry every 'scanHowOften' seconds.
- // We could also parse the time string out and pick a certain amount of delay, but a day is reasonable for seeing if
- // someone is becomming a regular.
- if (llList2String(timeCheck ,0) != llGetDate( ))
- {
- integer visitCount = llList2Integer(visitors, (i*3)+1);
- visitCount +=1;
- list update = [id, visitCount, findTimeEntry()];
- visitors = ListStridedUpdate(visitors, update, i, i, 3);
- }
- return TRUE;
- }
- }
- return FALSE;
- }
- // Scans the parcel, records any new entries.
- scanRegion(integer touched)
- {
- list visitorsRightNow = llGetAgentList(scanDistance, []);
- integer numOfAvatars = llGetListLength(visitorsRightNow);
- if (!numOfAvatars)
- {
- return;
- }
- integer index;
- while (index < numOfAvatars)
- {
- key id = llList2Key(visitorsRightNow, index);
- if(touched == 3 || (id != llGetOwner()))
- {
- if( isIDKeyOnList(id) == FALSE)
- {
- // visitors += [id, 1, findTimeEntry()];
- visitors = [id, 1, findTimeEntry()] + llList2List(visitors, 0, ((MAX_COUNT-1)*3)-1);
- // Keep the list limited in size.
- }
- }
- ++index;
- }
- visitorsRightNow = []; // null the temp list.
- }
- // Outputs names to the owner, or to public chat depending on request.
- outputNames(integer public)
- {
- list listofIDs = llList2ListStrided(visitors,0,-1,3);
- integer numOfAvatars = llGetListLength(listofIDs);
- integer index;
- if (public == TRUE) llSay( 0,"+--------------------------------------------------------------------------------------+\n");
- else llOwnerSay("+--------------------------------------------------------------------------------------+\n");
- while (index < numOfAvatars)
- {
- key id = llList2Key(listofIDs, index);
- string name = llKey2Name(id);
- string whenLastVisited = llList2String(visitors, (index*3)+2);
- string visitCount = (string)llList2Integer(visitors, (index*3)+1);
- if (public == TRUE)
- llSay( 0,"secondlife:///app/agent/" + (string)id + "/about : Visited " + visitCount + " times. " + whenLastVisited);
- else
- llOwnerSay("secondlife:///app/agent/" + (string)id + "/about : Visited " + visitCount + " times. " + whenLastVisited);
- ++index;
- }
- if (public == TRUE) llSay( 0,"+--------------------------------------------------------------------------------------+\n");
- else llOwnerSay("+--------------------------------------------------------------------------------------+\n");
- }
- // The default LSL function.
- default
- {
- // run when the item is rezed, reset, or the script resaved.
- state_entry()
- {
- visitors = []; // Ensure a blank list at the start.
- scanRegion(3); // First scan is allowed to scan object owner.
- llSetTimerEvent(scanHowOften); // sets how often to scan
- llListen(0, "", llGetOwner(), ""); // enables the owner to use chat commands
- outputNames(FALSE); // Let us see the first pass just to see what it looks like.
- }
- // tells the script to scan the region.
- timer()
- {
- scanRegion(FALSE);
- }
- // allows touching to run the scan, and if touched by owner, sends the list to the owner.
- touch_start(integer total_number)
- {
- scanRegion(TRUE);
- if (llDetectedKey(0) == llGetOwner())
- outputNames(FALSE);
- }
- // The available chat commands:
- // list = sends list to owner.
- // listPublic = sends the list to public chat. Use with caution.
- listen( integer channel, string name, key id, string message )
- {
- if( id != llGetOwner() ) // match the ID of the chatter to the owner, or stop.
- {
- return;
- }
- else
- if( message == "list" )
- {
- scanRegion(FALSE);
- outputNames(FALSE);
- }
- else
- if( message == "listPublic" )
- {
- scanRegion(FALSE);
- outputNames(TRUE);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement