Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Get Avatar Name

Underduck Underall
The Dragon
Join date: 21 Mar 2006
Posts: 70
05-18-2008 08:28
Hey, I was wondering how you could make a script that is always scanning for Avatars, and when one avatar comes within a certain amount of meters it sends an email to something?
_____________________
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
05-18-2008 09:01
CODE

default
{

state_entry()
{
llSensorRepeat("", NULL_KEY, AGENT, 5, PI, 5);
}
sensor(integer total_number)
{

llEmai((address),llKey2Name(llDetectedKey(0));
}

}


EDIT:

what next post downs says
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
05-18-2008 13:28
From: Mrc Homewood
added the 2 second delay so it wont constantly be sending the name over and over and flooding the email delay

The 2 second sleep has no effect. It will be 5 seconds between each sensor event in any case because of the period of your llSensorRepeat(). So the results will be that you get a sensor event, pause for 2 seconds (keeping any other events from firing during this time--not that you have any in this script anyway), then return from the event handler and wait 3 more seconds before another (potential) sensor event. I'd just take out the sleep. Make the period of llSensorRepeat() a little longer if you really want to decrease load.
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
05-18-2008 22:14
Have no clue what a delay would be for, sending an email delays the script 20 seconds anyways, as far as not 'spamming' with multiple emails, why not keep a list, and clear it once an hour, something like so:

CODE

string avatar;
float range = 5.0; // set range here
string address = "your_email_address@goes.here"; // replace with your email address
integer resetTime = 3600; // # of seconds between visited list being cleared, 3600 = once per hour
string subject = "Visitor Detected";
list visited;

sendEmail (string name)
{
string message = name + " has been detected";
llEmail (address, subject, message);
return;
}

default
{
state_entry()
{
llSetTimerEvent (resetTime);
llSensorRepeat("", NULL_KEY, AGENT, range, TWO_PI, 5);
}

timer ()
{
visited = [];
}

sensor (integer detected)
{
avatar = llDetectedName (0);
integer check = llListFindList (visited, [avatar]);
if (check == -1)
{
sendEmail(avatar);
visited += avatar;
}
}
}