Change font size
It is currently Mon Nov 19, 2018 11:06 am

Forum rules


{L_IMAGE}



Post a new topicPost a reply Page 1 of 2   [ 17 posts ]
Go to page 1, 2  Next
Author Message
 Post subject: Deluxe Visitor List
PostPosted: Sat Jul 04, 2009 9:49 pm 
Site Admin
User avatar

Joined: Wed Jul 16, 2008 7:22 pm
Posts: 186
Here's a little something I wrote which uses a few OSSL functions to improve on the typical visitor list script in the following ways:

  • When the owner touches the prim containing the script, it delivers a notecard sorting the visitor list data three ways:

    • By the number of visits each avatar has made to the region, in descending order
    • Alphabetically by avatar name (also showing how many visits each avatar has made)
    • In the order the avatars first visited the region; newest visitors are listed at the bottom
  • Other people touching the prim will simply be told how many people visited the region, and the combined total number of visits that all avatars have made.
  • Rather than using the Sensor functions, which are limited both in range and in the number of avatars they can detect, it uses osGetAgents(), which finds all avatars in the region, regardless of how far they are from the scripted object.
  • It stores its data in a notecard, which means that even if the script is restarted, or the script state file is deleted (e.g. if you do a clean reinstall of OpenSim), the visitor list will retain its data.

Important Note: As a couple of the OSSL functions used by the script exceed the default permission level, you will need to modify OpenSim.ini to explicitly allow the use of these functions by the owner of the object containing the script (which will generally be the owner of the region), then restart the region so the new settings take effect.

In the [XEngine] and [ScriptEngines.DotNetEngine] sections of your OpenSim.ini, include the following lines:

Allow_osMakeNotecard = <your UUID>
Allow_osAvatarName2Key = <your UUID>


Do not include the angle brackets. For example, if your UUID is 54162f1c-383f-489d-8aea-d156680fc173, you would use:

Allow_osMakeNotecard = 54162f1c-383f-489d-8aea-d156680fc173
Allow_osAvatarName2Key = 54162f1c-383f-489d-8aea-d156680fc173


And finally, the script itself:

{L_CODE}:
// Deluxe Visitor Log - keeps track of visitors to the region, storing the information in a notecard to preserve
//                      the data between script resets, region restarts and the like. When touched by the owner,
//                      produces a notecard containing the visitor list sorted by number of visits, alphabetically
//                      by visitor name, and by date of first visit. (If anyone other than the owner touches it,
//                      they are simply told the number of visitors the region has had.)
//
// Requires the following OSSL functions: osMakeNotecard(), osGetAgents(), osAvatarName2Key()
// Make sure they are allowed in OpenSim.ini for the UUID of the avatar owning the object which contains the script.
//
// Version 1.0 by Warin Cascabel (4 July 2009)
// Version 1.1 by Warin Cascabel (6 July 2009) - set object description to visitors/visits info

//======================================== Variables ========================================

// ------------------------------ Configuration variables -----------------------------------

float TimerInterval = 60.0;                // Number of seconds between polling the region for new avatars
string DataNotecard = "Visitor List Data"; // Name of the notecard in which data is stored


// ------------------------- Internal variables - do not change -----------------------------

list     Visitors;      // Data stored in the format [ UUID, Name, Visits [...]]
list     CurrentlyHere; // UUIDs of avatars detected during the previous scan
key      DataRequest;   // Used for reading in the settings notecard
integer  NotecardLine;  // Likewise
//======================================== Functions ========================================

// AddName() adds the provided details to the master list, or updates the visit count if the person is
//           already present in the list.
//
integer AddName( string UUID, string Name )
{
    integer TotalVisits = 1;
    integer IndexPos = llListFindList( Visitors, [ UUID ] ); // Search for the UUID in our master list
    if (IndexPos == -1) // If not found in the list, add them with 1 visit
    {
        Visitors += [ UUID, Name, (string) 1 ];
    }
    else // If they were found in the list, increment their visit count
    {
        integer CountPos = IndexPos + 2;
        TotalVisits = llList2Integer( Visitors, CountPos ) + 1;
        Visitors = llListReplaceList( Visitors, [ (string) TotalVisits ], CountPos, CountPos );
    }
    return 1;
}


// CheckNames() gets the list of agents present in the region, ignores any who were present during the last scan,
//              and adds the remainder to the master list (or increments their visit count if they were already in it)
//
CheckNames()
{
    integer NamesAdded = 0;
    list l = osGetAgents();  // Get the list of all the agents present in the region (better than sensors!)
    list RecentScan;         // To hold the name and UUID of everyone found, but who was not present during last scan
    list RecentUUIDs;        // To hold just the UUIDs of everyone found, but who was not present during last scan
    list AllUUIDsFound;      // To hold the UUIDs of everyone found, regardless of whether or not they were present last time
    integer i = llGetListLength( l ); // general iterator variable
    //
    // First, build a list containing the data of everyone who wasn't found during the previous scan
    //
    while (i--)
    {
        string AvatarName = llList2String( l, i );                     // Get the full name
        list NameParts = llParseString2List( AvatarName, [ " "], [] ); // break it into first and last names
        key UUID = osAvatarName2Key( llList2String( NameParts, 0 ), llList2String( NameParts, 1 )); // Get the UUID
        AllUUIDsFound += [ UUID ];                                     // Add their UUID to the list of all UUIDs found
        if (llListFindList( CurrentlyHere, [ UUID ] ) == -1)           // if we didn't find the person during the previous scan:
        {
            RecentUUIDs += [ UUID ];                                   // Add their UUID to the list of new UUIDs found during this scan
            RecentScan += [ UUID, AvatarName ];                        // Add all their information to the recent scan list
        }
    }
    CurrentlyHere = AllUUIDsFound; // Replace CurrentlyHere with the list of everyone who's present in the region now.
    //
    // Add anyone new from the most recent scan to the master list, or increase their visit counts if they've already been here before
    //
    for (i = llGetListLength( RecentScan ); i > 0; i -= 2)
    {
        string thisUUID = llList2String( RecentScan, i-2 );
        NamesAdded += AddName( thisUUID, llList2String( RecentScan, i-1 ));
    }
    //
    // If we actually did anything, write out a new notecard to save the data.
    //
    if (NamesAdded)
    {
        if (llGetInventoryKey( DataNotecard ) != NULL_KEY) llRemoveInventory( DataNotecard );
        osMakeNotecard( DataNotecard, Visitors );
        llSetObjectDesc( (string) (llGetListLength( Visitors ) / 3) + " visitors / " + (string) CountTotalVisits() + " visits" );
    }
}


// CountTotalVisits() returns the total number of visits recorded by all avatars
//
integer CountTotalVisits()
{
    integer RetVal = 0;
    integer i = llGetListLength( Visitors ) - 1;
    for (i = llGetListLength( Visitors ) - 1; i > 0; i -= 3)
    {
        RetVal += llList2Integer( Visitors, i );
    }
    return RetVal;
}

// DeliverReportNotecard() builds a notecard containing the visitor list sorted three ways: by frequency of visit (descending),
//                         alphabetically by visitor name, and by date of first visit. It then delivers the notecard to the
//                         owner, and deletes it from inventory.
//
DeliverReportNotecard()
{
    list OrderedList;                         // to store the list ordered by date of visit
    list NameList;                            // to store the list ordered by avatar name
    list VisitList;                           // to store the list ordered by visit count
    list Notecard;                            // to store the report notecard
    integer j = llGetListLength( Visitors );
    integer i;
    integer VisitorsLogged = j/3;
    integer VisitsLogged = CountTotalVisits();
    llOwnerSay( (string) (j/3) + " visitors/" + (string) VisitsLogged + " visits logged. Please wait while the full report is generated." );
    for (i = 0; i < j; i += 3)
    {
        string name    = llList2String( Visitors, i+1 );
        integer visits = llList2Integer( Visitors, i+2 );
        string sss     = "s";
        if (visits == 1) sss = "";
        OrderedList += [ llToLower( name ), name + " (" + (string) visits + " visit" + sss + ")" ];
        VisitList += [ visits, (string) visits + " : " + name ];
    }
    if (VisitorsLogged == 1) // OpenSim screws up llList2ListStrided if there's only one stride in the list.
    {
        OrderedList = llDeleteSubList( OrderedList, 0, 0 );
        NameList = OrderedList;
        VisitList = llDeleteSubList( VisitList, 0, 0 );
    }
    else
    {
        NameList = llList2ListStrided( llDeleteSubList( llListSort( OrderedList, 2, TRUE), 0, 0 ), 0, -1, 2 ); // sort alphabetically
        OrderedList = llList2ListStrided( llDeleteSubList( OrderedList, 0, 0 ), 0, -1, 2 );
        VisitList = llListSort( VisitList, 2, FALSE );                                   // sort by descending visit count
        VisitList = llList2ListStrided( llDeleteSubList( VisitList, 0, 0 ), 0, -1, 2 );  // Get only the text to display
    }
    Notecard =  [ "Total visitors: " + (string) VisitorsLogged ];
    Notecard += [ "Total visits: " + (string) VisitsLogged ];
    Notecard += [ "", "Sorted by number of visits: ", "" ] + VisitList;
    Notecard += [ "", "Sorted by name:", "" ] + NameList;
    Notecard += [ "", "Sorted by date of first visit:", "" ] + OrderedList;
    Notecard += [ "", "Total visitors: " + (string) VisitorsLogged ];
    Notecard += [ "Total visits: " + (string) VisitsLogged ];
    string NotecardName = llGetRegionName() + " visitor list : " + llGetTimestamp();
    osMakeNotecard( NotecardName, Notecard );
    llGiveInventory( llGetOwner(), NotecardName );
    llRemoveInventory( NotecardName );

}

// ================================ default state handler ==================================

default {
   
    state_entry() // Read in the saved visitor list data, if it exists, and switch to the running state.
    {
        Visitors = [];                                                    // clear out the visitors list
        if (llGetInventoryKey( DataNotecard ) == NULL_KEY) state running; // switch to running state if the notecard doesn't exist
        llOwnerSay( "Reading saved visitor list data" );
        NotecardLine = 0;
        DataRequest = llGetNotecardLine( DataNotecard, 0 );
    }
   
    dataserver( key id, string data )
    {
        if (id != DataRequest) return;
        if (data == EOF)
            state running;
        else
        {
            data = llStringTrim( data, STRING_TRIM );
            if (data != "") Visitors += [ data ];
            DataRequest = llGetNotecardLine( DataNotecard, ++NotecardLine );
        }
    }
}

// ================================ running state handler ==================================

state running
{
    // state_entry(): load in notecard, if present, set a timer, and check region immediately.
    //
    state_entry()
    {
        llOwnerSay( "Visitor scanning active" );
        llSetTimerEvent( TimerInterval );  // Set the timer for periodic checks
        CheckNames();                      // Check the region immediately for avatars
    }
   
    // touch_start() will cause the report card to be generated, if the touch was from our
    //               owner; otherwise, it will tell the toucher how many visitors the region
    //               has logged.
    //
    touch_start( integer foo )
    {
        if (llDetectedKey( 0 ) == llGetOwner()) // being lazy, and assuming there's only one touch.
            DeliverReportNotecard();
        else
            llInstantMessage( llDetectedKey( 0 ), (string) (llGetListLength( Visitors ) / 3) + " visitor(s) logged, with a total of " + (string) CountTotalVisits() + " visits." );
    }
   
    // Poll the region every x seconds (as configured by the TimerInterval variable). Rather than using
    // sensors, which are limited both in range and in the number of avatars they can detect, we'll use
    // the OpenSim-only function osGetAgents().
    //
    timer()
    {
        CheckNames();
    }
   
    // Reset the script if the region has restarted. This mainly restarts the timer and clears out the list
    // of people who were detected the last time the region was scanned, but it's good to avoid any other
    // unforeseen consequences.
    //
    changed( integer whatChanged )
    {
        if (whatChanged & 256) llResetScript();
    }
}


The notecard generated upon being touched by the owner looks like this:
{L_CODE}:
Total visitors: 12
Total visits: 155

Sorted by number of visits:

56 : John Hancock
23 : Josiah Bartlett
21 : Samuel Adams
18 : Stephen Hopkins
11 : Roger Sherman
11 : William Floyd
8 : richard stockton
3 : Robert Morris
1 : George Read
1 : Samuel Chase
1 : George Wythe
1 : William Hooper

Sorted by name:

George Read (1 visit)
George Wythe (1 visit)
John Hancock (56 visits)
Josiah Bartlett (23 visits)
richard stockton (8 visits)
Robert Morris (3 visits)
Roger Sherman (11 visits)
Samuel Adams (21 visits)
Samuel Chase (1 visit)
Stephen Hopkins (18 visits)
William Floyd (11 visits)
William Hooper (1 visit)

Sorted by date of first visit:

John Hancock (56 visits)
Samuel Chase (1 visit)
Samuel Adams (21 visits)
William Floyd (11 visits)
Robert Morris (3 visits)
Josiah Bartlett (23 visits)
William Hooper (1 visit)
richard stockton (8 visits)
Stephen Hopkins (18 visits)
Roger Sherman (11 visits)
George Read (1 visit)
George Wythe (1 visit)

Total visitors: 12
Total visits: 155


Shameless plug: This script, as well as other scripts and objects, are available inworld at Quirm (225, 82, 21)


Last edited by Warin Cascabel on Mon Jul 06, 2009 7:31 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Deluxe Visitor List
PostPosted: Sun Jul 05, 2009 3:01 am 

Joined: Mon Jun 22, 2009 7:48 pm
Posts: 4
Thank You.

Nice Script and it work fine for me. :)

_________________
Ingame: Maik Galaxy - El Diablo
www.OpenSimgerman.us - German Help Site


Top
 Profile  
 
 Post subject: Re: Deluxe Visitor List
PostPosted: Sun Jul 05, 2009 4:18 am 
User avatar

Joined: Sat Nov 22, 2008 6:21 pm
Posts: 31
Thank you, works great!

_________________
El presidente of the Republic of Hannaghbha.


Top
 Profile  
 
 Post subject: Re: Deluxe Visitor List
PostPosted: Mon Jul 06, 2009 7:34 am 
Site Admin
User avatar

Joined: Wed Jul 16, 2008 7:22 pm
Posts: 186
I've updated the script above to add a new feature: it now sets the object description to show the visitor/visit counts, so if you have "hover tips" turned on (View -> Hover Tips), you can get a quick look at the numbers by simply hovering your mouse pointer over the object.


Top
 Profile  
 
 Post subject: Re: Deluxe Visitor List
PostPosted: Tue Jul 07, 2009 2:29 am 
Site Admin
User avatar

Joined: Sat Feb 02, 2008 5:27 pm
Posts: 843
This script is awesome thanks Warin, just installed it at my Tower. 8-)

Neb :ugeek:


Top
 Profile  
 
 Post subject: Re: Deluxe Visitor List
PostPosted: Thu Jul 23, 2009 9:06 am 
OSG Elite
User avatar

Joined: Wed Mar 11, 2009 3:57 pm
Posts: 444
This is an Excellent Device !
Great Tool and using it on my regions now.

I did a slight modification for my own purposes and thought I would share that as well.
- Modified to prevent from capturing Owner Visits as this skews total visit counts
- Added a Menu for the Owner to offer choice of Reset System, Display list data, Give list data
- Added that on Owner Change the system Resets the data notecard & description as well
- Added a Script reset for when a Region is restarted, it hung up a couple of times on restart.

{L_CODE}:
// Deluxe Visitor Log - keeps track of visitors to the region, storing the information in a notecard to preserve
//                      the data between script resets, region restarts and the like. When touched by the owner,
//                      produces a notecard containing the visitor list sorted by number of visits, alphabetically
//                      by visitor name, and by date of first visit. (If anyone other than the owner touches it,
//                      they are simply told the number of visitors the region has had.)
//
// Requires the following OSSL functions: osMakeNotecard(), osGetAgents(), osAvatarName2Key()
// Make sure they are allowed in OpenSim.ini for the UUID of the avatar owning the object which contains the script.
//
// Version 1.0 by Warin Cascabel (4 July 2009)
// Version 1.1 by Warin Cascabel (6 July 2009) - set object description to visitors/visits info
//
// Slight Revision by WhiteStar Magic (July 23 2009)
//  - Modified to prevent from capturing Owner Visits as this skews total visit counts
//  - Added a Menu for the Owner to offer choice of Reset System, Display list data, Give list data
//  - Added that on Owner Change the system Resets the data notecard & description as well
//  - Added a Script reset for when a Region is restarted, it hung up a couple of times on restart.
//
//======================================== Variables ========================================

// ------------------------------ Configuration variables -----------------------------------

float TimerInterval = 60.0;                // Number of seconds between polling the region for new avatars
string DataNotecard = "Visitor List Data"; // Name of the notecard in which data is stored


// ------------------------- Internal variables - do not change -----------------------------

list     Visitors;      // Data stored in the format [ UUID, Name, Visits [...]]
list     CurrentlyHere; // UUIDs of avatars detected during the previous scan
key      DataRequest;   // Used for reading in the settings notecard
integer  NotecardLine;  // Likewise
//======================================== Functions ========================================

// AddName() adds the provided details to the master list, or updates the visit count if the person is
//           already present in the list.
//
integer AddName( string UUID, string Name )
{
    integer TotalVisits = 1;
    integer IndexPos = llListFindList( Visitors, [ UUID ] ); // Search for the UUID in our master list

    if (IndexPos == -1) // If not found in the list, add them with 1 visit
    {
        Visitors += [ UUID, Name, (string) 1 ];
    }
    else // If they were found in the list, increment their visit count
    {
        integer CountPos = IndexPos + 2;
        TotalVisits = llList2Integer( Visitors, CountPos ) + 1;
        Visitors = llListReplaceList( Visitors, [ (string) TotalVisits ], CountPos, CountPos );
    }
    return 1;
}


// CheckNames() gets the list of agents present in the region, ignores any who were present during the last scan,
//              and adds the remainder to the master list (or increments their visit count if they were already in it)
//
CheckNames()
{
    integer NamesAdded = 0;
    list l = osGetAgents();  // Get the list of all the agents present in the region (better than sensors!)
    list RecentScan;         // To hold the name and UUID of everyone found, but who was not present during last scan
    list RecentUUIDs;        // To hold just the UUIDs of everyone found, but who was not present during last scan
    list AllUUIDsFound;      // To hold the UUIDs of everyone found, regardless of whether or not they were present last time
    integer i = llGetListLength( l ); // general iterator variable
    //
    // First, build a list containing the data of everyone who wasn't found during the previous scan
    //
    while (i--)
    {
        string AvatarName = llList2String( l, i );                     // Get the full name
        list NameParts = llParseString2List( AvatarName, [ " "], [] ); // break it into first and last names
        key UUID = osAvatarName2Key( llList2String( NameParts, 0 ), llList2String( NameParts, 1 )); // Get the UUID
        AllUUIDsFound += [ UUID ];                                     // Add their UUID to the list of all UUIDs found
        if (llListFindList( CurrentlyHere, [ UUID ] ) == -1)           // if we didn't find the person during the previous scan:
        {

            if(UUID != llGetOwner()); RecentUUIDs += [ UUID ];  // Add their UUID to the list of new UUIDs found during this scan
            if(UUID != llGetOwner()); RecentScan += [ UUID, AvatarName ];// Add all their information to the recent scan list
        }
    }
    CurrentlyHere = AllUUIDsFound; // Replace CurrentlyHere with the list of everyone who's present in the region now.
    //
    // Add anyone new from the most recent scan to the master list, or increase their visit counts if they've already been here before
    //
    for (i = llGetListLength( RecentScan ); i > 0; i -= 2)
    {
        string thisUUID = llList2String( RecentScan, i-2 );
        NamesAdded += AddName( thisUUID, llList2String( RecentScan, i-1 ));
    }
    //
    // If we actually did anything, write out a new notecard to save the data.
    //
    if (NamesAdded)
    {
        if (llGetInventoryKey( DataNotecard ) != NULL_KEY) llRemoveInventory( DataNotecard );
        osMakeNotecard( DataNotecard, Visitors );
        llSetObjectDesc( (string) (llGetListLength( Visitors ) / 3) + " visitors / " + (string) CountTotalVisits() + " visits" );
    }
}


// CountTotalVisits() returns the total number of visits recorded by all avatars
//
integer CountTotalVisits()
{
    integer RetVal = 0;
    integer i = llGetListLength( Visitors ) - 1;
    for (i = llGetListLength( Visitors ) - 1; i > 0; i -= 3)
    {
        RetVal += llList2Integer( Visitors, i );
    }
    return RetVal;
}

// DeliverReportNotecard() builds a notecard containing the visitor list sorted three ways: by frequency of visit (descending),
//                         alphabetically by visitor name, and by date of first visit. It then delivers the notecard to the
//                         owner, and deletes it from inventory.
//
// mod by WS string action for either display or give
//
DeliverReportNotecard(string action)
{
    list OrderedList;                         // to store the list ordered by date of visit
    list NameList;                            // to store the list ordered by avatar name
    list VisitList;                           // to store the list ordered by visit count
    list Notecard;                            // to store the report notecard
    integer j = llGetListLength( Visitors );
    integer i;
    integer VisitorsLogged = j/3;
    integer VisitsLogged = CountTotalVisits();
    llOwnerSay( (string) (j/3) + " visitors/" + (string) VisitsLogged + " visits logged. Please wait while the full report is generated." );
    for (i = 0; i < j; i += 3)
    {
        string name    = llList2String( Visitors, i+1 );
        integer visits = llList2Integer( Visitors, i+2 );
        string sss     = "s";
        if (visits == 1) sss = "";
        OrderedList += [ llToLower( name ), name + " (" + (string) visits + " visit" + sss + ")" ];
        VisitList += [ visits, (string) visits + " : " + name ];
    }
    if (VisitorsLogged == 1) // OpenSim screws up llList2ListStrided if there's only one stride in the list.
    {
        OrderedList = llDeleteSubList( OrderedList, 0, 0 );
        NameList = OrderedList;
        VisitList = llDeleteSubList( VisitList, 0, 0 );
    }
    else
    {
        NameList = llList2ListStrided( llDeleteSubList( llListSort( OrderedList, 2, TRUE), 0, 0 ), 0, -1, 2 ); // sort alphabetically
        OrderedList = llList2ListStrided( llDeleteSubList( OrderedList, 0, 0 ), 0, -1, 2 );
        VisitList = llListSort( VisitList, 2, FALSE );                                   // sort by descending visit count
        VisitList = llList2ListStrided( llDeleteSubList( VisitList, 0, 0 ), 0, -1, 2 );  // Get only the text to display
    }
    Notecard =  [ "Total visitors: " + (string) VisitorsLogged ];
    Notecard += [ "Total visits: " + (string) VisitsLogged ];
    Notecard += [ "", "Sorted by number of visits: ", "" ] + VisitList;
    Notecard += [ "", "Sorted by name:", "" ] + NameList;
    Notecard += [ "", "Sorted by date of first visit:", "" ] + OrderedList;
    Notecard += [ "", "Total visitors: " + (string) VisitorsLogged ];
    Notecard += [ "Total visits: " + (string) VisitsLogged ];
    string NotecardName = llGetRegionName() + " visitor list : " + llGetTimestamp();
    osMakeNotecard( NotecardName, Notecard );
    if(action == "Display")
    {
        llOwnerSay(NotecardName+"\n"+llDumpList2String(Notecard,"\n"));
    }
    else
    {
        llGiveInventory( llGetOwner(), NotecardName );
        llRemoveInventory( NotecardName );
    }

}
// Modifications by WhiteStar follow
integer CHANNEL;
OPEN_Comms()  // Open Communications Channel only when needed
{
    llListenRemove(CHANNEL);                         // SAFETY Kill CHANNEL incase left over
    CHANNEL = (integer)(llFrand(-1000.0) - 1000.0);  // RANDOM Negative Channel
    llListen(CHANNEL, "", "", "");                   // listen for dialog answers
    llSetTimerEvent(45.0); // to AutoKill CHANNEL
}
MENU_Owner(key id)  // Admin Menu
{
    OPEN_Comms();
    //
    llDialog(id,
        "\nReset System"+
        "\n! Deletes Notecard and resets desciption"+
        "\nDisplay list data"+
        "\nGive list data",
        ["Reset","Display","Give"], CHANNEL);
}
//
// ================================ default state handler ==================================

default {
   
    state_entry() // Read in the saved visitor list data, if it exists, and switch to the running state.
    {
        Visitors = [];                                                    // clear out the visitors list
        if (llGetInventoryKey( DataNotecard ) == NULL_KEY) state running; // switch to running state if the notecard doesn't exist
        llOwnerSay( "Reading saved visitor list data" );
        NotecardLine = 0;
        DataRequest = llGetNotecardLine( DataNotecard, 0 );
    }
   
    dataserver( key id, string data )
    {
        if (id != DataRequest) return;
        if (data == EOF)
            state running;
        else
        {
            data = llStringTrim( data, STRING_TRIM );
            if (data != "") Visitors += [ data ];
            DataRequest = llGetNotecardLine( DataNotecard, ++NotecardLine );
        }
    }
}

// ================================ running state handler ==================================

state running
{
    // state_entry(): load in notecard, if present, set a timer, and check region immediately.
    //
    state_entry()
    {
        llOwnerSay( "Visitor scanning active" );
        llSetTimerEvent( TimerInterval );  // Set the timer for periodic checks
        CheckNames();                      // Check the region immediately for avatars
    }
   
    // touch_start() will cause the report card to be generated, if the touch was from our
    //               owner; otherwise, it will tell the toucher how many visitors the region
    //               has logged.
    //
    touch_start( integer foo )
    {
        if (llDetectedKey( 0 ) == llGetOwner()) // being lazy, and assuming there's only one touch.
        {
            MENU_Owner(llGetOwner());
        }
        else
        {
            llInstantMessage( llDetectedKey( 0 ), (string) (llGetListLength( Visitors ) / 3) + " visitor(s) logged, with a total of " + (string) CountTotalVisits() + " visits." );
        }
    }
   
    // listen event to capture owners menu response and act upon it.
    //
    listen( integer channel, string name, key id, string msg )
    {
        llListenRemove(CHANNEL); // Kill Listen reduce Lag
        //["Reset","Display","Give"]
        if(msg == "Reset")
        {
            llRemoveInventory(DataNotecard);
            llSetObjectDesc("System Reset on "+llGetDate());
            llResetScript();
        }
        else if((msg == "Display")||(msg == "Give")) DeliverReportNotecard(msg);
    }
   
    // Poll the region every x seconds (as configured by the TimerInterval variable). Rather than using
    // sensors, which are limited both in range and in the number of avatars they can detect, we'll use
    // the OpenSim-only function osGetAgents().
    //
    timer()
    {
       
        CheckNames();
    }
   
    // Reset the script if the region has restarted. This mainly restarts the timer and clears out the list
    // of people who were detected the last time the region was scanned, but it's good to avoid any other
    // unforeseen consequences.
    //
    changed( integer change )
    {
        if (change & 256) llResetScript();
        if (change & CHANGED_OWNER) { llRemoveInventory(DataNotecard); llSetObjectDesc("Initialized on "+llGetDate()); llResetScript(); }
    }
}

_________________
No further support of any kind, for any of my materials. Use as/is whereis.
PLEASE UNSTICKY Any Stickied Posting by myself.


Last edited by WhiteStar Magic on Sat Jul 25, 2009 6:14 am, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: Deluxe Visitor List
PostPosted: Thu Jul 23, 2009 11:14 am 
Site Admin
User avatar

Joined: Wed Jul 16, 2008 7:22 pm
Posts: 186
Good call on deleting the notecard when the object changes owners. I had envisioned it as just a script that anyone could drop into one of their own objects, and it didn't occur to me that people might make a nifty container for the script and then distribute that.


Just be aware that llOwnerSay() will truncate the text after 1023 bytes, so the "Display" option will only be useful if there are only a few visitors (which is the reason I went with having it deliver the information via notecard).

You could also use llOwnerSay() for each individual line of the "notecard", which would avoid the truncation issue, but I've noticed a tendency for huge numbers of said lines to occasionally arrive out of order (which kind of defeats the purpose of ordered lists).


Top
 Profile  
 
 Post subject: Re: Deluxe Visitor List
PostPosted: Thu Jul 23, 2009 11:41 am 
OSG Elite
User avatar

Joined: Wed Mar 11, 2009 3:57 pm
Posts: 444
Good point on the llOwnerSay, I have observed that behaviour too. llInstantMessage works quite well.... Changed the posted code to deal with that and use llInstantMessage. Line X Line... eek.....but I have another trick to cope with readabili there and that woudl be to grab obj name store it, rename it to : process text dump, then reset name to stored name. Makes for a much less cluttered screen from the text dump and easy to do. Not applying that in above code though.

_________________
No further support of any kind, for any of my materials. Use as/is whereis.
PLEASE UNSTICKY Any Stickied Posting by myself.


Top
 Profile  
 
 Post subject: Re: Deluxe Visitor List
PostPosted: Thu Jul 01, 2010 9:11 pm 
Furious Typer

Joined: Wed Feb 17, 2010 9:17 pm
Posts: 94
Location: Florida
I am trying to run this script and it continues to throw an error after reset saying that the osAvatarName2Key
does not have permission for this function.

The only installation problem I have is the comment about putting it in both the [XEngine] and [ScriptEngines.DotNetEngine] sections.
My OpenSim.ini does not have a [ScriptEngines.DotNetEngine] section.

I have added the following to the [XEngine} section.
Allow_osMakeNotecard = My UUID
Allow_osAvatarName2Key = My UUID
Allow_osGetAgents = My UUID

The UUID I used was the same one used in the region "MasterAvatarUUID =" field.

I am running on a linux server, and running the current version of todays date.
I am using the revised version by WhiteStar Magic.

Some other questions I have.

Do I have to make this NC and place it into the object with the script?


Top
 Profile  
 
 Post subject: Re: Deluxe Visitor List
PostPosted: Thu Jul 01, 2010 9:23 pm 
OSG Elite
User avatar

Joined: Thu Aug 06, 2009 7:07 am
Posts: 346
Location: B.C. Canada
I have
Allow_osMakeNotecard = UUID
Allow_osAvatarName2Key = UUID

Allow_osGetRegionStats = true
Allow_osGetSimulatorMemory = true
Allow_osSetDynamicTextureData = true

in my .ini file and it works great.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 2   [ 17 posts ]
Go to page 1, 2  Next


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
610nm Style by Daniel St. Jules of Gamexe.net