CODE
key second = NULL_KEY; // fill in a second key if you want
string active = "deactive";
float range = 25.0;
key nrofnamesoncard;
integer nrofnames;
list names;
list keynameoncard;
string nameoncard;
string storedname;
integer listener;
default
{
state_entry()
{
llOwnerSay("Startup state reading whitelist notecard");
nrofnamesoncard = llGetNumberOfNotecardLines("whitelist"); // reads a notecard with names. called whitelist
}
dataserver (key queryid, string data){
if (queryid == nrofnamesoncard)
{
nrofnames = (integer) data;
llOwnerSay("Found "+(string)nrofnames+ " names in whitelist.");
integer i;
for (i=0;i < nrofnames;i++){
keynameoncard += llGetNotecardLine("whitelist", i);
}
} else
{
integer listlength;
listlength = llGetListLength(keynameoncard);
integer j;
for(j=0;j<listlength;j++) {
if (queryid == (key) llList2String(keynameoncard,j))
{
llOwnerSay("Name added to whitelist: "+data);
names += data;
}
}
}
if (llGetListLength(names) == nrofnames)
{
llOwnerSay ("Done with reading notecard. Starting script now");
state start;
}
}
}
state start
{
state_entry ()
{
llListen(9, "", llGetOwner(), "");
llListen(9, "", second, "");
llSensorRepeat("", NULL_KEY, AGENT, range, PI, 5.0);
}
listen(integer channel, string name, key id, string message)
{
if (message == "activate")
{
active = "active";
llOwnerSay("Activated");
}
if (message == "deactivate")
{
active = "deactive";
llOwnerSay("Deactivated");
}
if (message == "reset")
{
llResetScript();
}
if (llGetSubString(message,0,4) == "range"){
range = (float) llGetSubString(message,6,-1);
llSensorRemove();
llSensorRepeat("", NULL_KEY, AGENT, range, PI, 5.0);
llOwnerSay("Changed range to: "+(string) range);
}
}
sensor(integer nr)
{
if (active == "active")
{
integer i;
for (i = 0; i < nr; i++)
{
string found = "no";
string nametotest = llDetectedName(i);
integer j;
for (j = 0; j < llGetListLength(names); j++)
{
if (llList2String(names, j) == nametotest){
found = "yes";
}
}
if (found == "no")
{
llSay(0, "You will be ejected from this land in 10 seconds. You are on ground you should not be on.");
llSleep(10);
llSay(0, "BYE!");
llInstantMessage(llGetOwner(), "Ejecting from our home: "+llDetectedName(i));
if (second != NULL_KEY)
{
llInstantMessage(second , "Ejecting from our home: "+llDetectedName(i));
}
llEjectFromLand(llDetectedKey(i));
}
}
}
}
}