Jump to content

Simple Online Logger


Rolig Loon
 Share

You are about to reply to a thread that has been inactive for 2995 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

From time to time, people ask for a way to record how long they have been logged in to SL.  There are many ways to save that information, but here's one simple approach.

//Simple Online Logger -- Rolig Loon -- July 2014
//Released for free public use provided that these two top lines are kept intact.

list gWhen;
key gOwnerStatus;
integer gOnLine;

default
{
	state_entry()
	{
		llSetObjectName("");
		llSetTimerEvent(60.0);  //Check once a minute
	}

	timer()
	{
		gOwnerStatus = llRequestAgentData(llGetOwner(),DATA_ONLINE); //Ask if owner is online
	}

	dataserver (key id, string data)
	{
		if (gOwnerStatus == id)
		{
			if (  !gOnLine && ((integer)data == 1))	//Owner wasn't on line, but is now
			{
				llResetTime();
				gOnLine = TRUE;
				gWhen += ["I: " + llGetTimestamp()]; //Record on-line start time
			}
			else if (gOnLine && ((integer)data == 0)) //Owner was on line but is not now
			{
				integer time = (integer)llGetTime();
				integer mins = time / 60;
				integer secs = time % 60;
				integer hours = mins / 60;
				mins = mins % 60;
				gOnLine = FALSE;
				// Record on-line end time
				gWhen += ["O: " + llGetTimestamp() + " >"+(string)hours+":"+(string)mins+":"+(string)secs];
			}
		}
	}

	touch_start(integer num)
	{
		if (llDetectedKey(0) == llGetOwner())  //Owner clicked
		{
			integer i;
			while( i < llGetListLength(gWhen))  //List records
			{
				llRegionSayTo(llGetOwner(),0,"/me "+ llList2String(gWhen,i));
				++i;
			}
		}
	}
}

Put that script in a prim someplace where you have permission to rez things and leave them (like your house).

When you click on it, the script will list all the recorded times when you entered and left SL, like this:

 I: 2014-07-05T19:44:15.652835Z
 O: 2014-07-05T19:46:15.663015Z >0:2:0

The lines that start with "I:" give times when you entered SL, in the UTC time zone (Greenwich mean time), so that first line says I entered SL on July 5, 2014 at 7:44:15 p.m.

The lines that start with "O:" give times when you logged out of SL, in the same format.  The three numbers after the ">" sign tell you your elapsed time in world in hr:min:sec . I stayed in SL for 2 minutes.

You'll have to convert times to your own time zone if you really need that information, or you can go to the trouble of writing a conversion routine into this script.  I obviously didn't.

I suggest deliberately resetting the script every few months.  If you don't, the list of times will get unbearably long and -- worse yet -- the script will run out of memory and stall.  Again, you can write fancier ways to clear its memory or erase old records selectively, but I leave that to you.

  • Like 2
Link to comment
Share on other sites

  • 1 year later...
You are about to reply to a thread that has been inactive for 2995 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...