Code: Visitor with Multiple Managers and Re-Logging

Yet another variation on the same script is one which re-logs visitors. For example, you have a shop and a customer visits your shop. The scripts above would log their first visit but they would not log a second visit to the shop. The version below will re-log visitors if they visit the shop again after a configurable time difference. So, in the previous example, if that visitor leaves and comes back any time after a configurable amount of time, the script below will log that visitor again.

The factory default for re-logging visitors is 60 seconds. To change that, simply change the line:

integer REVISIT_INTERVAL = 60; 

Please note that the time is in seconds. For example, to change it to a one hour interval, you would modify that line to:

integer REVISIT_INTERVAL = 3600; 

Code

This script was tested and works on OpenSim version 0.7.4!

visitor_relogging.lsl
///////////////////////////////////////////////////////////////////////////
//  Copyright (C) Wizardry and Steamworks 2011 - License: GNU GPLv3      //
//  Please see: http://www.gnu.org/licenses/gpl.html for legal details,  //
//  rights of fair usage, the disclaimer and warranty conditions.        //
///////////////////////////////////////////////////////////////////////////
 
// Time in seconds before a a visiting avatar is considered
// a revisiting avatar. For example, when avatars come back
// after this time interval, they will be logged again.
integer REVISIT_INTERVAL = 60; 
 
list vList = [];
list aList = [];
key aQuery = NULL_KEY;
integer comHandle = 0;
integer comChannel = 0;
integer scanInterval = 2;
integer scanRange = 10;
 
///////////////////////////////////////////////////////////////////////////
//    Copyright (C) 2013 Wizardry and Steamworks - License: GNU GPLv3    //
///////////////////////////////////////////////////////////////////////////
integer wasDateToStamp(integer year, integer month, integer day, integer hour, integer minute, integer second) {
    month -= 2;
    if (month <= 0) {
        month += 12;
        --year;
    }
    return ((((year / 4 - year / 100 + year / 400 + (367 * month) / 12 + day) + year * 365 - 719499) * 24 + hour) * 60 + minute) * 60 + second;
}
 
///////////////////////////////////////////////////////////////////////////
//    Copyright (C) 2011 Wizardry and Steamworks - License: GNU GPLv3    //
///////////////////////////////////////////////////////////////////////////
list wasListReverse(list lst) {
    if(llGetListLength(lst)<=1) return lst;
    return wasListReverse(llList2List(lst, 1, llGetListLength(lst))) + llList2List(lst,0,0);
}
 
default {
 
    state_entry() {
        aQuery = llGetNotecardLine("Access List",comHandle);
        llSensorRepeat("",NULL_KEY,1,scanRange,3.14159274,scanInterval);
    }
 
    changed(integer change) {
        if (change & CHANGED_INVENTORY) {
            aList = [];
            comHandle = 0;
            aQuery = llGetNotecardLine("Access List",comHandle);
        }
    }
 
    touch_start(integer total_number) {
        if (llListFindList(aList, (list) llDetectedName(0)) == -1) return;
        comChannel = ((((integer)("0x" + llGetSubString(((string) llGetKey()), -8, -1))) & 1073741823) ^ -1073741825);
        comHandle = llListen(comChannel,"",llDetectedKey(0),"");
        llDialog(llDetectedKey(0),"\n[K] Visitor list: Please select an option. \n",["Reset","View","Range","Interval"],comChannel);
    }
 
    listen(integer chan,string name,key id,string mes) {
        if (mes == "Interval") {
            llDialog(id,"\n[K] Visitor list: Please select a scanning interval in seconds.\n",["2s","4s","8s","16s","32s","64s"],comChannel);
            return;
        }
        if ((mes == "Range")) {
            llDialog(id,"\n[K] Visitor: Please select a scanning distance in meters.\n",["5","10","15","30","35","40","45","50","60","70","80","90"],comChannel);
            return;
        }
        if (mes == "Reset") {
            vList = [];
            jump zout;
        }
        if (mes == "View") {
            integer aPtr = llGetListLength(vList) - 1;
            llInstantMessage(id,"----------------------- Visitors -------------------------");
            do {
                llInstantMessage(id,((llList2String(vList,aPtr) + " @ ") + llList2String(vList,(aPtr - 1))));
                aPtr -= 2;
            } while(aPtr>-1);
            llInstantMessage(id,"------------------------------------------------------------");
            jump zout;
        }
        integer iMes = (integer) mes;
        if (iMes == 0) jump zout;
        if (iMes && !(iMes & (iMes - 1))) {
            scanInterval = iMes;
            llSensorRepeat("",NULL_KEY,1,scanRange,3.14159274,scanInterval);
            jump zout;
        }
        if (iMes % 5 == 0) {
            scanRange = iMes;
            llSensorRepeat("",NULL_KEY,1,scanRange,3.14159274,scanInterval);
            jump zout;
        }
@zout;
        llListenRemove(comHandle);
    }
 
    sensor(integer num) {
        --num;
        do {
            if (llListFindList(vList,(list)llDetectedName(num)) != -1) jump revisit;
            if (llGetFreeMemory() < 2048 && llGetListLength(vList) != 0) vList = llDeleteSubList(vList, 0, 0);
            vList += [ llGetTimestamp() ] + [ llDetectedName(num) ];
@revisit;
            list dateNow = llParseString2List(llGetTimestamp(), ["-", "T", ":", "."], []);
            integer now = wasDateToStamp(llList2Integer(dateNow, 0), 
                llList2Integer(dateNow, 1), 
                llList2Integer(dateNow, 2),
                llList2Integer(dateNow, 3),
                llList2Integer(dateNow, 4),
                llList2Integer(dateNow, 5));
            list dateThen = llParseString2List(llList2String(wasListReverse(vList), llListFindList(wasListReverse(vList), (list)llDetectedName(num))+1),["-", "T", ":", "."],[]);
            integer then = wasDateToStamp(llList2Integer(dateNow, 0), 
                llList2Integer(dateThen, 1), 
                llList2Integer(dateThen, 2),
                llList2Integer(dateThen, 3),
                llList2Integer(dateThen, 4),
                llList2Integer(dateThen, 5));
            if(now-then <= REVISIT_INTERVAL) jump continue;
            if (llGetFreeMemory() < 2048 && llGetListLength(vList) != 0) vList = llDeleteSubList(vList, 0, 0);
            vList += [ llGetTimestamp() ] + [ llDetectedName(num) ];
@continue;
        } while(--num>-1);
    }
 
    dataserver(key query_id,string data) {
        if (query_id != aQuery) return;
        if (data == EOF) return;
        aList += (list)data;
        aQuery = llGetNotecardLine("Access List",++comHandle);
    }
}

secondlife/visitors/multiple_managers/relogging.txt ยท Last modified: 2022/11/24 07:46 by 127.0.0.1

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.