Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

library: traffic/payment info scanner..

Sindy Tsure
Will script for shoes
Join date: 18 Sep 2006
Posts: 4,103
04-05-2009 14:19
Tried posting this to the library a bit ago but I either screwed it up or Nada is sleepin' on the job.. :P

Script to count unique traffic and payment info stats on an area. Or get the object itself at https://www.xstreetsl.com/modules.php?name=Marketplace&file=item&ItemID=1339636

CODE

float SCAN_WIDTH = 30.0;
float SCAN_INTERVAL = 30.0;

float gScanWidth;
rotation gRotChange;

list gKeysSeen;
list gTodoList;
integer gTodoCount = 0;

key gQueryId;

integer gNoPayInfo = 0;
integer gPayOnFile = 0;
integer gPayUsed = 0;


string GetText()
{
return "\n" +
"scanned avatars = " + (string)llGetListLength (gKeysSeen) + "\n" +
"no payment info on file = " + (string)gNoPayInfo + "\n" +
"payment info on file = " + (string)gPayOnFile + "\n" +
"payment info used = " + (string)gPayUsed + "\n" +
(string)llGetFreeMemory() + " bytes free";
}

DoUpdate()
{
if (gTodoCount == 0)
{
// nothing on the todo list - rotate a little and rescan
llSetRot (llGetRot() * gRotChange);

llSensor ("", "", AGENT, 96.0, SCAN_WIDTH);
}
else
{
// pull one avatar id off the todo list and ask for payment info
key id = llList2Key (gTodoList, 0);

gTodoList = llDeleteSubList (gTodoList, 0, 0);
gTodoCount--;

gQueryId = llRequestAgentData (id, DATA_PAYINFO);

// todo: set a timer to watch for dataserver never responding
// todo: instead of the above, link message to memory scripts
}
}

default
{
state_entry()
{
llOwnerSay ("scanning..");
llSetText ("", ZERO_VECTOR, 1.0);
llSetObjectDesc("");
gScanWidth = SCAN_WIDTH * DEG_TO_RAD;
gRotChange = llEuler2Rot (<0.0, 0.0, gScanWidth>);

DoUpdate();
}

sensor (integer count)
{
integer i;

list todo;

for (i = 0; i < count; i++)
{
key id = llDetectedKey(i);

// seen this avatar before?
if (llListFindList (gKeysSeen, [id]) == -1)
{
gKeysSeen += id;

// already on the todo list?
if (llListFindList (gTodoList, [id]) == -1)
{
//llOwnerSay ("new id: " + (string)id);
gTodoList += id;
gTodoCount++;
}
}
}

if (gTodoCount == 0)
{
// nothing new on the todo list.. rescan after a pause
llSetTimerEvent (SCAN_INTERVAL);
}
else
{
// stuff on the todo list.. start processing it now
DoUpdate();
}
}

no_sensor()
{
// i'm lonely!! schedule a date
llSetTimerEvent (SCAN_INTERVAL);
}

touch_start (integer count)
{
// spam anybody daring to touch me with stats
string text = GetText();

integer i;
for (i = 0; i < count; i++)
{
llInstantMessage (llDetectedKey(i), text);
}
}

dataserver (key id, string data)
{
if (id == gQueryId)
{
gQueryId = "";

integer info = (integer)data;

// update stats based on payment info
if (info == 0)
{
// no payment info on file
gNoPayInfo++;
}
else
{
if ((info & 0x02) != 0)
{
// payment info used
gPayUsed++;
}
else
if ((info & 0x01) != 0)
{
// payment info on file
gPayOnFile++;
}
else
{
// er..
llOwnerSay ("wha?? data = " + data);
}
}

if (llGetFreeMemory() < 1500)
{
// don't want the stack & heap kissing so don't do the next update
llSetText ("full!" + GetText(), <1.0, 1.0, 1.0>, 1.0);
llSetObjectDesc (GetText());
}
else
{
DoUpdate();
}
}
}

on_rez (integer param)
{
llResetScript();
}

timer()
{
llSetTimerEvent (0.0);
DoUpdate();
}
}
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
04-05-2009 21:23
nice
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -