Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
Visitor Counter Visitor_Tracker_by_Meghan_Eldrich  

Visitor_Tracker_by_Meghan_Eldrich

Visitor Tracker by Meghan Eldrich.lsl

Category: Visitor Counter
By : Meghan Eldrich
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for Visitor_Tracker_by_Meghan_Eldrich
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Visitor_Tracker_by_Meghan_Eldrich_1.lsl
1
2 //********************************************************
3 //This Script was pulled out for you by YadNi Monde from the SL FORUMS at http://forums.secondlife.com/forumdisplay.php?f=15, it is intended to stay FREE by it s author(s) and all the comments here in ORANGE must NOT be deleted. They include notes on how to use it and no help will be provided either by YadNi Monde or it s Author(s). IF YOU DO NOT AGREE WITH THIS JUST DONT USE!!!
4 //********************************************************
5
6
7
8
9
10
11
12 //Useful Shop Visitor Tracker by Meghan Eldrich
13 //This thing started out pretty simple and sort of mushroomed on me. I wanted a way to track visitors entering my shop and tell me when they came and the time and so forth. But then I released it capped my IM's so I included an on-line/off-line state tracking thing to shut off the IM's. Then I sort of went nuts with toggling features on and off without hosing the stats to make simple changes. The code now includes a way to toggle IM's off period and just keep the last visitor list.
14 //
15 //Setting this up is simple and straight forward (I think). Simply create a prim that your visitor comes in contact with (preferably only once) when entering your shop. You can then adjust the time between when that visitor will be counted as a new hit. It does have some quirks but without making the script a lot more complex that I already made it, this is the best solution I could think of. You can toggle on-line/off-line polling if you wish as hitting the dataserver can be laggy. As the script sits now, it will poll for your online status once a minute (+/-) which seems like a good duration to me.
16
17
18
19
20 //************************************************** ***********
21 //***** Visitor Tracker V1.10 *****
22 //***** Written by Meghan Eldrich *****
23 //***** 09/09/2006 *****
24 //***** IM Meghan Eldrich for Support *****
25 //************************************************** ***********
26 // This script is free to use and copy, and is released under
27 // The GNU General Public License -- Please leave the header
28 // INTACT! Thank you. This script _MAY NOT_ be used in a
29 // commecial product!
30
31 integer iStateTracker = TRUE; // Set this to false to not track your online state (helps with lag a little)
32 integer hitter = 900; // Time in seconds between same visitor entering, and being counted again
33 integer iGetIMS = TRUE; // Set this to False to not get IMs when visitors enter your shop
34 integer iGreet = TRUE; // Get a nice welcome back when you return and not visits, FALSE to not get a greeting (Can be spammy with lots of shops)
35 integer iMyChannel = 5050; // The default channel for this (can be changed while running!
36 key xOl;
37 key MyKey;
38 integer iIsOn;
39 list visits;
40 list afkvisits;
41 integer afkhits;
42 integer hits;
43 string lasthit;
44 integer tracked;
45 string lastvisit;
46 integer iJust = TRUE;
47
48 string HackTime()
49 {
51 string x;
52 integer i;
53 // First process date out of xt
54 i = llSubStringIndex(xt, "T");
55 x = llGetSubString(xt, 0, i - 1);
56 // Get rid of the date
57 xt = llGetSubString(xt, i + 1, -1);
58 // Second process time
59 i = llSubStringIndex(xt, ".");
60 x += " " + llGetSubString(xt, 0, i - 1) + "GMT";
61 return x;
62 }
63
64 DoListThing(string x)
65 {
66 hits++;
67 string y = (string)hits + "> " + x + " @ " + HackTime();
68 if(hits > 19)
69 {
70 visits = llDeleteSubList(visits,0,0);
71 }
72 visits += y;
73 }
74 default
75 {
77 {
80 MyKey = llGetOwner();
81 llListen(iMyChannel, "", MyKey, "");
83 if(iStateTracker)
84 {
85 xOl = llRequestAgentData(MyKey, DATA_ONLINE);
86 }
87 llOwnerSay("*** Visit tracker for \"" + llGetObjectDesc() + "\" now RUNNING");
88 llOwnerSay("*** Type \"/" + (string)iMyChannel + " help\" for a list of commands");
89 }
91 {
93 }
95 {
97 {
99 string y = x;
100 if(x != lasthit)
101 {
102 lasthit = x;
103 tracked = llGetUnixTime();
104 DoListThing(x);
105 lastvisit = HackTime();
106 x += " Just entered \"" + llGetObjectDesc() + "\" (" + HackTime() + ")";
107 if(iIsOn)
108 {
109 // Owner is online send an IM
110 if(iGetIMS) { llInstantMessage(MyKey, x);}
111 }
112 else
113 {
114 // Owner is offline store the name
115 ++afkhits;
116 if(afkhits > 9) { afkvisits = llDeleteSubList(afkvisits,0,0);}
117 afkvisits += y;
118 }
119 }
120 }
121 }
122 listen(integer chan, string name, key id, string msg)
123 {
124 if(msg == "showme")
125 {
126 integer i;
127 llOwnerSay("*** Visits So far: " + (string)hits + " (last: " + lastvisit + ")");
128 for (i = 0; i < llGetListLength(visits); i ++)
129 {
130 llOwnerSay(llList2String(visits, i));
131 }
132 llOwnerSay("*** END of List ***");
133 }
134 else if(msg == "clearme")
135 {
136 hits = 0;
137 visits = [];
138 lasthit = "";
139 tracked = 0;
140 llOwnerSay("Stats Cleared");
141 }
142 else if(msg == "imtoggle")
143 {
144 if(iGetIMS)
145 {
146 iGetIMS = FALSE;
147 llOwnerSay("No longer Sending IMs!");
148 }
149 else
150 {
151 iGetIMS = TRUE;
152 llOwnerSay("Now Sending IMs!");
153 }
154 }
155 else if(msg == "statetrack")
156 {
157 if(iStateTracker)
158 {
159 iStateTracker = FALSE;
160 llOwnerSay("No longer tracking on-line state!");
161 }
162 else
163 {
164 iStateTracker = TRUE;
165 llOwnerSay("Now tracking on-line state!");
166 }
167 }
168 else if(msg == "greettoggle")
169 {
170 if(iGreet)
171 {
172 iGreet = FALSE;
173 llOwnerSay("No longer sending greetings!");
174 }
175 else
176 {
177 iGreet = TRUE;
178 llOwnerSay("Now sending greetings!");
179 }
180 }
181 else if(msg == "help")
182 {
183 llOwnerSay("The tracker has the following commands:");
184 llOwnerSay("showme .............. Shows you the last 19 visitors");
185 llOwnerSay("clearme ............. clears all the current stats");
186 llOwnerSay("imtoggle ............ Toggles sending IMs On & Off");
187 llOwnerSay("statetrack .......... Toggles tracking your online/offline states");
188 llOwnerSay("greettoggle ......... Toggles sending an on-line greeting to you");
189 llOwnerSay("help ................ This help list");
190 }
191 }
192 timer()
193 {
194 if(tracked != 0)
195 {
196 if((llGetUnixTime() - tracked) > hitter)
197 {
198 tracked = 0;
199 lasthit = "";
200 }
201 }
202 if(iStateTracker)
203 {
204 xOl = llRequestAgentData(MyKey, DATA_ONLINE);
205 }
206 }
207 dataserver(key req, string data)
208 {
209 if(req == xOl)
210 {
211 // Testing Online Status
212 if(data == "1")
213 {
214 if(!iIsOn && llGetListLength(afkvisits) > 0 && iGetIMS)
215 {
216 llInstantMessage(MyKey, "Welcome Back! You've had " + (string)afkhits + " @ \"" + llGetObjectDesc() + "\" while you were offline");
217 string x = llList2CSV(afkvisits);
218 llInstantMessage(MyKey, "Last 10: " + x);
219 }
220 else if(!iIsOn && iGetIMS && iGreet && !iJust)
221 {
222 llInstantMessage(MyKey, "Welcome Back from \"" + llGetObjectDesc() + "\" - No activity while you were away");
223 }
224 iJust = FALSE;
225 afkvisits = [];
226 afkhits = 0;
227 iIsOn = TRUE;
228 }
229 else
230 {
231 iIsOn = FALSE;
232 }
233 }
234 }
235 }// END //

Back to the Best Free Tools in Second Life and OpenSim.