//Original script by Aaron Linden
//modified by Ramon Kothari
// Global variables change these to match your specifics
float range = 50.0; // search radius, in meters
float rate = 1.0; // time between searches, in seconds
// add your email adress inside the quotes
string email_address = "";
//add the name of the location if you want (the email will have the sim name and cordinates of
// the counter all ready in it
float last_wallclock_time = 0.0;
string location_name = "";
//dont change these
list single_name_list;
list visitor_list;
//end no change
// Returns true if "name" is already on the visitor_list
integer isNameOnList( string name )
{
list single_name_list;
single_name_list += name;
return (-1 != llListFindList( visitor_list, single_name_list ) );
}
// sends email to the address above ,if added
sendEmail()
{
string csv = llList2CSV( visitor_list );
llEmail( email_address, "Visitor List: " + location_name, csv );
}
//self explanatory
resetList()
{
visitor_list = [];
llSay( 0, "Done resetting."

;
llResetScript();
}
// Help commands
sayHelp( integer is_owner )
{
if( is_owner )
{
llSay( 0, "This object records the names of everyone who" );
llSay( 0, "comes within "+ (string)((integer)range) + " meters." );
llSay( 0, "Commands the owner can say:" );
llSay( 0, "'help' - Shows these instructions." );
llSay( 0, "'say list' - Says the names of all visitors on the list."

;
llSay( 0, "'reset list' - Removes all the names from the list." );
llSay( 0, "' email list' - Emails the names on the list." );
}
else
{
llSay( 0, "Sorry, only the owner can use this object." );
}
}
// state the script starts in
default
{
state_entry()
{
llSensorRepeat( "", "", AGENT, range, TWO_PI, rate );
llListen(0, "", llGetOwner(), ""

;
//change this to how often you want the script to email the visitor list to you // (or comment it out if you dont want the email .... by default its set to email you
llSetTimerEvent( 120 );
}
// Sends email and resets list as set in the set timer event above
timer()
{
float time_since_midnight = llGetWallclock();
if( time_since_midnight < last_wallclock_time )
{
sendEmail();
resetList();
}
last_wallclock_time = time_since_midnight;
}
//says help if owner clicks on it
//detects avatars and keeps time
sensor( integer number_detected )
{
integer i;
for( i = 0; i < number_detected; i++ )
{
// Don't ever add the owner to the list.
if( llDetectedKey( i ) != llGetOwner() )
{
string detected_name = llDetectedName( i );
if( isNameOnList( detected_name ) == FALSE )
{
float seconds = llGetWallclock();
float minutes = seconds / 60.0;
float hours = minutes / 60.0;
integer hours_int = (integer) hours;
integer minutes_int = ((integer)minutes) % 60;
if( minutes_int < 10 )
{
visitor_list += (string) hours_int + ":0" + (string) minutes_int + " " + (string) llGetDate();
}
else
{
visitor_list += (string) hours_int + ":" + (string) minutes_int + " " + (string) llGetDate();
}
visitor_list += detected_name;
}
}
}
}
//Listens for cammands from the Owner
listen( integer channel, string name, key id, string message )
{
if( id != llGetOwner() )
{
return;
}
if( message == "help" )
{
sayHelp( TRUE );
}
else
if( message == "say list" )
{
llSay( 0, "Visitor List:" );
integer len = llGetListLength( visitor_list );
integer i;
for( i = 0; i < len; i++ )
{
llSay( 0, llList2String(visitor_list, i) );
}
llSay( 0, "Total = " + (string)len );
}
else
if( message == "email list" )
{
sendEmail();
llSay(0, "Emailing list"

;
}
else
if( message == "reset list" )
{
visitor_list = [];
llSay( 0, "Done resetting."

;
}
}
}