Difference between revisions of "Visitor Counter Tracker"

From Second Life Wiki
Jump to navigation Jump to search
(Remove Copyright)
 
(16 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{LSL Header}}
[[Category:LSL_Library]]
[[Category:LSL_Library]]
 
<div>
[[Teleporter_Anywhere]] | [[Language_Scanner]] | [[Visitor_Counter_Tracker]]
[[User:Luxen_Resident]] | [[Teleporter_Anywhere]] | [[Ultimate_Radar]] | [[Language_Scanner]] | [[Visitor_Counter_Tracker]]
 
</div>
==Zx Visitor Counter - Tracker==
<div id="box">
- Daily counter, Monthly counter, Daily report (track, save and display the list of all the visitors names each day)
==Summary==
 
<div style="padding: 0.5em;">
- Land wide (scan all your Land, no distance limit), easy to use, no setup needed and no lag.
Track, save and display the list of all the visitors names each day.
 
* Daily report
- Fully autonomous:
* Land wide (scan all your Land)
No need to reset it, no need to reset the counters, no need to clear the visitors name list.
* Easy to use, no setup needed
This tool will do it for you when needed.
* Fully autonomous.
 
</div></div>
- Copyright (C) 2016 Luxen - [[User:Luxen_Resident|Luxen_Resident]] - version 2.6
<div id="box">
 
== Code: ==
- Optimized, low memory, safe and secure
<div style="padding: 0.5em;">
 
==Code:==
<source lang="lsl2">
<source lang="lsl2">
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//                      Zx Visitor Counter - Tracker v2.6                   //
//                      Zx Visitor Counter - Tracker v3.1                   //
//                                                                          //
//    Copyright (C) 2016 Luxen - Zonyx Technology                          //
//    This program is free software: you can redistribute it and/or modify  //
//    it under the terms of the GNU General Public License version 3, as    //
//    published by the Free Software Foundation.                            //
//                                                                          //
//                                                                          //
//   This program is distributed in the hope that it will be useful,      //
//                       By Luxen - Zonyx Technology                      //
//    but WITHOUT ANY WARRANTY; without even the implied warranty of        //
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        //
//    GNU General Public License for more details.                          //
//                                                                          //
//                                                                          //
//  You should have received a copy of the GNU General Public License      //
//    along with this program.  If not, see <http://www.gnu.org/licenses/>  //
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////


Line 51: Line 40:
     string Ztext = "[D:" + (string)DCount + " - M:" + (string)NVisits + "]";
     string Ztext = "[D:" + (string)DCount + " - M:" + (string)NVisits + "]";
     llSetPrimitiveParams([PRIM_TEXT, Ztext, <0.667, 0.667, 0.667>, 1.0]);
     llSetPrimitiveParams([PRIM_TEXT, Ztext, <0.667, 0.667, 0.667>, 1.0]);
}
string Zreport(integer Ztab, integer Tcount)
{
    string Fname = "";
    integer index2;
    for(index2 = 0; index2 < Tcount ; ++index2)
    {
        if (Ztab) Fname += llList2String(NewTab, index2) + ", ";
        else Fname += "secondlife:///app/agent/" + llList2String(IdTab, index2) + "/username" + ", ";
    }
    return llDeleteSubString(Fname, -2, -1);
}
integer Zadd(key Zkey, string Zname)
{
    if (Zname)
    {
        if (llListFindList(NewTab, [Zname]) == -1) NewTab += [Zname];
        else return FALSE;
    }
    else
    {
        if (llListFindList(IdTab, [Zkey]) == -1) IdTab += [Zkey];
        else return FALSE;
    }
    return TRUE;
}
}


Line 73: Line 87:
     {
     {
         if (llDetectedKey(0) == Zowner)
         if (llDetectedKey(0) == Zowner)
         {  
         {
             integer Tindex;
             llSleep(0.3);
             integer TnumOfAvatars = llGetListLength(NewTab);
             integer TnumOfAvatars = llGetListLength(NewTab);
             string Vname = "";
             string Vname = "--------------------------"
            if (TnumOfAvatars > 0)
            {
                for(Tindex = 0; Tindex < TnumOfAvatars ; ++Tindex)
                {
                    Vname += llList2String(NewTab, Tindex) + ", ";
                }
                Vname = llDeleteSubString(Vname, -2, -1);
            }
            else Vname = "nobody";
           
            integer OnumOfAvatars = llGetListLength(IdTab);
            if (OnumOfAvatars > 0)
            {
                Vname += "\n Others (" + (string)OnumOfAvatars + "): ";
                for(Tindex = 0; Tindex < OnumOfAvatars ; ++Tindex)
                {
                    Vname += "secondlife:///app/agent/" + llList2String(IdTab, Tindex) + "/username" + ", ";
                }
                Vname = llDeleteSubString(Vname, -2, -1);
            }
           
            llOwnerSay("--------------------------"
                       + "\n Visitors Today:"  
                       + "\n Visitors Today:"  
                       + "\n List (" + (string)TnumOfAvatars + "): " + Vname  
                       + "\n List (" + (string)TnumOfAvatars + "): ";
                      + "\n --------------------------");
                     
            if (TnumOfAvatars > 0) Vname += Zreport(TRUE, TnumOfAvatars);
            else Vname += "nobody";
            TnumOfAvatars = llGetListLength(IdTab);
            if (TnumOfAvatars > 0) Vname += "\n Others (" + (string)TnumOfAvatars + "): " + Zreport(FALSE, TnumOfAvatars);
            llOwnerSay(Vname + "\n --------------------------");
         }
         }
     }
     }
Line 132: Line 129:
                 else if (id != Zowner)
                 else if (id != Zowner)
                 {
                 {
                     string VisitorName = llGetUsername(id);
                     integer Znew = Zadd(id, llGetUsername(id));
                     if (VisitorName)
                     if (Znew)
                    {
                        if (llListFindList(NewTab, [VisitorName]) == -1) NewTab += [VisitorName];
                        else jump Next;
                    }
                    else
                     {
                     {
                         if (llListFindList(IdTab, [id]) == -1) IdTab += [id];
                         UpDate = TRUE;
                         else jump Next;
                        ++DCount;
                         ++NVisits;
                     }
                     }
                   
                    UpDate = TRUE;
                    ++DCount;
                    ++NVisits;
                 }
                 }
                @Next;
           
             }
             }
             AvatarsDetect = [];
             AvatarsDetect = [];
Line 166: Line 153:
}
}
</source>
</source>
</div></div>

Latest revision as of 17:47, 18 January 2017

User:Luxen_Resident | Teleporter_Anywhere | Ultimate_Radar | Language_Scanner | Visitor_Counter_Tracker

Summary

Track, save and display the list of all the visitors names each day.

  • Daily report
  • Land wide (scan all your Land)
  • Easy to use, no setup needed
  • Fully autonomous.

Code:

//////////////////////////////////////////////////////////////////////////////
//                      Zx Visitor Counter - Tracker v3.1                   //
//                                                                          //
//                        By Luxen - Zonyx Technology                       //
//                                                                          //
//////////////////////////////////////////////////////////////////////////////

key Zowner;
integer NVisits;
string ZDate;
integer DCount = 0;
list NewTab  = [];
list IdTab = [];

string Ztime()
{
    string DayDate = llGetSubString(llGetDate(), 8, 9);
    return DayDate;
}
Zcount()
{
    string Ztext = "[D:" + (string)DCount + " - M:" + (string)NVisits + "]";
    llSetPrimitiveParams([PRIM_TEXT, Ztext, <0.667, 0.667, 0.667>, 1.0]);
}
string Zreport(integer Ztab, integer Tcount)
{
    string Fname = "";
    integer index2;
    for(index2 = 0; index2 < Tcount ; ++index2)
    {
        if (Ztab) Fname += llList2String(NewTab, index2) + ", ";
        else Fname += "secondlife:///app/agent/" + llList2String(IdTab, index2) + "/username" + ", ";
    }
    return llDeleteSubString(Fname, -2, -1);
}
integer Zadd(key Zkey, string Zname)
{
    if (Zname) 
    {
        if (llListFindList(NewTab, [Zname]) == -1) NewTab += [Zname];
        else return FALSE;
    }
    else 
    {
        if (llListFindList(IdTab, [Zkey]) == -1) IdTab += [Zkey];
        else return FALSE;
    }
    return TRUE;
}

default
{
    state_entry()
    {
        Zowner = llGetOwner();
        NVisits = (integer)llGetObjectDesc();
        ZDate = Ztime();
        Zcount();
        llSetTimerEvent(60.0);
    }
    
    on_rez(integer start_param)
    {
        llSetObjectDesc("0");
        llResetScript(); 
    }
    
    touch_start(integer n) 
    {
        if (llDetectedKey(0) == Zowner)
        {
            llSleep(0.3);
            integer TnumOfAvatars = llGetListLength(NewTab);
            string Vname = "--------------------------"
                       + "\n Visitors Today:" 
                       + "\n List (" + (string)TnumOfAvatars + "): ";
                       
            if (TnumOfAvatars > 0) Vname += Zreport(TRUE, TnumOfAvatars);
            else Vname += "nobody";
            TnumOfAvatars = llGetListLength(IdTab);
            if (TnumOfAvatars > 0) Vname += "\n Others (" + (string)TnumOfAvatars + "): " + Zreport(FALSE, TnumOfAvatars);
            llOwnerSay(Vname + "\n --------------------------");
        }
    }
    
    changed(integer change)
    {
        if (change & CHANGED_REGION_START)
        {
            llSleep(60.0);
            llSetTimerEvent(60.0);
        }
    }
    
    timer()
    {
        integer UpDate = FALSE;
        list AvatarsDetect  = llGetAgentList(AGENT_LIST_PARCEL, []);
        integer numOfAvatars = llGetListLength(AvatarsDetect);
        if (numOfAvatars > 0)
        {
            integer ObjectGroup = FALSE;
            list details = llGetObjectDetails(llGetKey(),[OBJECT_GROUP]);
            if(llList2Key(details, 0)) ObjectGroup = TRUE;
            
            integer index;
            for (index = 0; index < numOfAvatars; ++index)
            {
                key id = llList2Key(AvatarsDetect, index);
                if (llSameGroup(id) && ObjectGroup)  ;
                else if (id != Zowner)
                {
                    integer Znew = Zadd(id, llGetUsername(id));
                    if (Znew)
                    {
                        UpDate = TRUE;
                        ++DCount;
                        ++NVisits;
                    }
                }
            }
            AvatarsDetect = [];
        }
        
        if (ZDate != Ztime())
        {
            llSleep(1.0);
            ZDate = Ztime();
            if (ZDate == "01") llSetObjectDesc("0");
            else llSetObjectDesc((string)NVisits);
            llResetScript();
        }
        else if (UpDate) Zcount();
    }
}