Table of Contents

Shortnote

The following script will scan all the visitors on a region using the new LSL llGetAgentList function. The functionality of this script is essentially the same as the simple visitor script except that it is able to scan an entire region.

Thanks

Created on request for Beto Brandi thanks for the pointer to llGetAgentList.

Code

region_visitors.lsl
//////////////////////////////////////////////////////////
//     WaS (c) grimore.org - 2013, License: GPLv3            //
// Please see: http://www.gnu.org/licenses/gpl.html     //
// for legal details, rights of fair usage and          //
// the disclaimer and warranty conditions.              //
//////////////////////////////////////////////////////////
 
list vList = [];
integer comHandle = 0;
integer comChannel = 0;
integer scanInterval = 2;
integer scanRange = 10;
 
default {
 
    state_entry() {
        llSetTimerEvent(scanInterval);
    }
 
    touch_start(integer total_number) {
        if (llDetectedKey(0) != llGetOwner()) return;
        comChannel = ((integer)("0x" + llGetSubString((string) llGetOwner(), -8, -1)) + (integer)("0x" + llGetSubString((string) llGetKey(), -8, -1)) & 0x3FFFFFFF) ^ 0xBFFFFFFF;
        comHandle = llListen(comChannel, "", llGetOwner(), "");
        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(llGetOwner(), "\n[K] Visitor list: Please select a scanning interval in seconds.\n", ["2s", "4s", "8s", "16s", "32s", "64s"], comChannel);
            return;
        }
        if (mes == "View") {
            llInstantMessage(id, "----------------------- Visitors -------------------------");
            integer aPtr = llGetListLength(vList) - 1;
            do {
                llInstantMessage(id, llList2String(vList, aPtr) + " @ " + llList2String(vList, aPtr - 1));
                aPtr -= 2;
            } while (aPtr > -1);
            llInstantMessage(id, "------------------------------------------------------------");
            jump eot;
        }
        if (mes == "Reset") {
            vList = [];
            jump eot;
        }
        integer iMes = (integer) mes;
        if (iMes == 0) jump eot;
        if (iMes >= 2 && (!iMes & (iMes - 1))) {
            scanInterval = iMes;
            jump eot;
        }
@eot;
        llListenRemove(comHandle);
    }
    timer() {
        list avs = llGetAgentList(AGENT_LIST_REGION, []);
        do {
            key av = llList2Key(avs, 0);
            avs = llDeleteSubList(avs, 0, 0);
            string name = llKey2Name(av);
            if(llListFindList(vList, (list)name) != -1) jump continue;
            if (llGetFreeMemory() < 2048 && llGetListLength(vList) != 0) vList = llDeleteSubList(vList, 0, 0);
            vList += [ llGetTimestamp() ] + [ name ];
@continue;
        } while(avs);
    }
}