Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Collision activated home security script

Vares Solvang
It's all Relative
Join date: 26 Jan 2005
Posts: 2,235
09-25-2006 13:55
This is a simple script that can be used for basic home security. I made it one day just for laughs but it really does work.

I put it in a cube that has been stretched to be the width of the door, but is very thin vertically. I place it about waist high just inside the door. That way it's very hard to see, even if they have transparent objects turned on, but they can't walk through the door without hitting it. When they collide with the prim the script will teleport them home (unless they are authorized, in which case it will give them a polite greeting). Yes, there are other ways they can get into your house, but this will block those rude folk that just walk into your house without knocking like they own the place. If you have guests visiting, you must walk through the door first, then it will allow anyone to enter for the next 20 seconds. That way your guests can walk in unmolested when you are there.

This script will only function on land that you personally own, although it could prob be adapted to function on group owned land. The way it is set up below it will allow the owner of the script to enter, and two other people (set to myself and my partner in the script below). You can change who the authorized persons are by replacing our keys with theirs in the strings at the top of the script. An easy way to get a person's UUID (their “key”) is to go to here: http://www.ulrikasheim.org/tools/name2key.html. I am not sure how many authorized persons you can put in this script, so if you are wanting a large list of authorized persons you might want to adapt this script to read a notecard with the names. (Hhmmm...that actually sounds like a fun project that I think I might try.)

There is an optional line to add the “nuked” person to your land's ban list. It is set to ban them indefinitely now, but you can change the float hours at the top of the script to however many hours you want them to be banned.

If you were feeling industrious you could add a scanner to this and turn it into a ranged home security program (be polite though and put in a warning and time delay to allow them to leave on their own).

And yes, I realize that I have way over-commented this script. I wanted it to be a good leaning tool so I commented on things that would be obvious to a seasoned scripter, but might not be so obvious to a newbie.



CODE


// Simple home security script by Vares Solvang with thanks to Phil Spackler for tweeking assistance.
// Do anything you like with this script, I hereby release it to public domain.
// To use this script just place it in a prim (wide and thin works best) and place it across a doorway.
// When someone runs into it, the script will activate. If you want to let guests enter safely,
// you must walk through the door first, they will then have 20 seconds to safely walk in themselves.
// The owner of the prim the script is in may always enter safely.

string eli = "ef87e541-9ccd-4633-b53f-b4bf61115736"; // replace this key with the key of the person you want to authorize entry to.
string vares = "4551f3d7-a82d-429b-af70-c4e25922d496"; // It's important you leave this key in, so that I can walk into your house any time I like. =)
float hours = 0; // time in hours to ban them, 0 = indefinite ban, 0.167 = 10 mins, 1 = 1 hour

NukeEm()
{
llSay(0, "How rude "+ (llDetectedName(0)) + ", this is a private house!"); // Scold them
llTeleportAgentHome(llDetectedKey(0)); // Send them home
//llAddToLandBanList(llDetectedKey(0), hours); // uncomment out this line to ban the person for however long you like.
llSay(0, llDetectedName(0) + " has been sent home for being rude!"); // tell everyone nearby who just got nuked
//llInstantMessage(llGetOwner(), llDetectedName(0) + " has been sent home for being rude!"); // uncomment this line to be notified anytime someone is nuked
}
default
{
state_entry()
{
llOwnerSay( "Intruder detector ready");
}

collision_start(integer num_detected)
{

string detected_key=llDetectedKey(0);

if (detected_key==llGetOwner() || detected_key==vares || detected_key==eli) // Is this person authorized?
{
llSetPrimitiveParams([PRIM_PHANTOM, TRUE]); // makes the prim phantom so you can walk through it
llSay(0, "Welcome home "+(llDetectedName(0))); // says hello to you, how polite!
llSleep (20); // a 20 second delay to let your guests follow you through the door safely.
llSetPrimitiveParams([PRIM_PHANTOM, FALSE]); // resets prim to solid to detect/eject more intruders
}
else
{
NukeEm(); // If the detected person is not authorized, nuke em!
}
}
}
_____________________
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Discussion Thread
09-26-2006 21:53
/54/d7/139798/1.html
_____________________
i've got nothing. ;)
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
09-27-2006 03:23
Hi V, *waves*

Rather than use keys use the names, you already use it elsewhere so would simplify thecode.

CODE

// Simple home security script by Vares Solvang with thanks to Phil Spackler for tweeking assistance.
// Do anything you like with this script, I hereby release it to public domain.
// To use this script just place it in a prim (wide and thin works best) and place it across a doorway.
// When someone runs into it, the script will activate. If you want to let guests enter safely,
// you must walk through the door first, they will then have 20 seconds to safely walk in themselves.
// The owner of the prim the script is in may always enter safely.

// Allowed people
list allowed = ["Vares Solvang","Elise FireFly"];

integer Ban = FALSE; // Auto ban ?
integer IM = FALSE; // be notified anytime someone is nuked ?


float hours = 0; // time in hours to ban them, 0 = indefinite ban, 0.167 = 10 mins, 1 = 1 hour

NukeEm(string name, key id)
{
llSay(0, "How rude "+ () + ", this is a private house!"); // Scold them
llTeleportAgentHome(id); // Send them home
if(Ban)
llAddToLandBanList(id, hours);
llSay(0, llDetectedName(0) + " has been sent home for being rude!"); // tell everyone nearby who just got nuked
if(IM)
llInstantMessage(llGetOwner(), llDetectedName(0) + " has been sent home for being rude!"); }

default
{
state_entry()
{
llOwnerSay( "Intruder detector ready");
}

collision_start(integer num_detected)
{

key id = llDetectedKey(0);
string name = llDetectedName(0);
integer allowed = llListFindList(allowed,[name]);
if (allowed != -1) // Is this person authorized?
{
llSetPrimitiveParams([PRIM_PHANTOM, TRUE]); // makes the prim phantom so you can walk through it
llSay(0, "Welcome home "+(name)); // says hello to you, how polite!
llSleep (20); // a 20 second delay to let your guests follow you through the door safely.
llSetPrimitiveParams([PRIM_PHANTOM, FALSE]); // resets prim to solid to detect/eject more intruders
}
else
{
NukeEm(name,id); // If the detected person is not authorized, nuke em!
}
}
}


I think you could/should use llVolumeDetect which would negate the need for the setting and clearing of PHANTOM.

If you used llVolumeDetect then you could stretch the prim across all/most of the floor space, this would then prevent the camera trick from working.

As it stands you may want to add code to set it non phantom on rez just incase you deleted it while it was in its phantom state.
Pangea Stonewall
Registered User
Join date: 28 Nov 2006
Posts: 0
Avatar Key
12-20-2006 10:32
One aspect of these scripts is that sometimes you need to know the avatar key. How do I find this out about someone or even myself


Help
Nic Agnomen
Registered User
Join date: 29 Jan 2007
Posts: 7
Love this thing
11-10-2007 19:21
Work like a charm, dont set it phantom like I did at first, won't work that way.
Im using it as a detection laser.
Thanks Vares