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
Security security_orb_script  

security_orb_script

security orb script.lsl
A better script is at http://www.free-lsl-scripts.com/cgi/freescripts.plx?ID=1674 by mangowylder

Category: Security
By : Anonymous
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for security_orb_script
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. security_orb_script_1.lsl
1
2 key second = NULL_KEY; // fill in a second key if you want
3
4 string active = "deactive";
5 float range = 25.0; // Range we will be scanning for for persons to check if they are on the whitellist
6
7 key nrofnamesoncard; // Some variables used to collect all the data from the notecard
8 integer nrofnames;
9 list names;
10 list keynameoncard;
11
12
13
14
15 default // We use the default state to read the notecard.
16 {
18 {
19 llOwnerSay("Startup state reading whitelist notecard");
20 nrofnamesoncard = llGetNumberOfNotecardLines("whitelist"); // Triggers the notecard reading by getting the numer of lines in the notecard
21 }
22
23 on_rez (integer param)
24 {
26 }
27
28 dataserver (key queryid, string data){
29
30 if(queryid == nrofnamesoncard)
31 {
32 // When we receive the number of lines in the notecard we do llGetNotecardLine for each line to get the contents
33 nrofnames = (integer) data;
34 llOwnerSay("Found "+(string)nrofnames+ " names in whitelist.");
35
36 integer i;
37 for (i=0;i < nrofnames;i++){
38 keynameoncard += llGetNotecardLine("whitelist", i);
39 }
40 } else
41 {
42 integer listlength;
43 listlength = llGetListLength(keynameoncard);
44 integer j;
45 for(j=0;j<listlength;j++) {
46 if(queryid == (key) llList2String(keynameoncard,j))
47 { // after checking if this really was an answer to one of our llGetNotecardLines calls (checking the keys we stored earlier)
48 // We add the name to our names list. Which we will use in a later state.
49 llOwnerSay("Name added to whitelist: "+data);
50 names += data;
51 }
52 }
53 }
54
55 if(llGetListLength(names) == nrofnames)
56 {
57 // If we have read all the names (just as many names as there where notecard lines). We switch to our next state "start"
58 // This state will do the actual work
59 llOwnerSay("Done with reading notecard. Starting script now");
60 state start;
61 }
62
63
64
65 }
66
67
68 }
69 state start
70 {
71 state_entry ()
72 {
73 // This is where we enter our state. We start 2 listeneres. One for our owner and one for our second owner..
74 llListen(9, "", llGetOwner(), "");
75 llListen(9, "", second, "");
76 llSensorRepeat("", NULL_KEY, AGENT, range, PI, 5.0); // We also start scanning for people in it's vincinity. This scan scans for AGENS (avatars), in a range we determinded above (first few lines). And PI means a full circle around us. In theory you could just scan parts of it.
77 }
78
79 on_rez(integer param)
80 {
82 }
83
84 listen(integer channel, string name, key id, string message)
85 { // This is our listen event. Here we receive all commands to control the orbs behaviour.
86 if(message == "activate") // Starts the orb
87 {
88 active = "active";
89 llOwnerSay("Activated");
90 }
91 if(message == "deactivate") // Stops the orb
92 {
93 active = "deactive";
94 llOwnerSay("Deactivated");
95 }
96 if(message == "reset") // Resets the script
97 {
99 }
100 if(llGetSubString(message,0,4) == "range"){ // If the command was range. We extract the new range from the command. Stop the sensor and start it again with the new range.
101 range = (float) llGetSubString(message,6,-1);
103 llSensorRepeat("", NULL_KEY, AGENT, range, PI, 5.0);
104 llOwnerSay("Changed range to: "+(string) range);
105 }
106 }
107
108 sensor(integer nr)
109 { // Here is where all people found in its vincinity are returned.
110
111 if(active == "active") // first we make sure the orb is active before we continue
112 {
113 integer i;
114 for (i = 0; i < nr; i++) //Here we start to loop throug all persons we found. We do this one by one.
115 {
116 string found = "no";
117
118 string nametotest = llDetectedName(i);
119 integer j;
120 for (j = 0; j < llGetListLength(names); j++) // We scan through the list of names to see if this person is whitelisted
121 {
122 if(llList2String(names, j) == nametotest){
123 found = "yes"; // When found we set found to true.
124 }
125 }
126 if(found == "no" && llOverMyLand(llDetectedKey(i)) && (llDetectedKey(i) != llGetOwner())) // When the person has not been found we start to check if this person is on our land. And on popuar reques we will never kick the owner ;)
127 {
128 llSay(0, "You will be ejected from this land in 10 seconds. You are on ground you should not be on."); // Let's notify this user that he has a few seconds to leave
129 llSleep(10); // Wait the time we gave him to leave
130 if(llOverMyLand(llDetectedKey(i))) // Ok let's see if he has left.
131 { // If he is still on lets say BYE to him, and tell the owner and second owner someone is kicked off the land
132 llSay(0, "BYE!");
133 llInstantMessage(llGetOwner(), "Ejecting from our home: "+llDetectedName(i));
134 if(second != NULL_KEY)
135 {
136 llInstantMessage(second , "Ejecting from our home: "+llDetectedName(i));
137 }
138 llEjectFromLand(llDetectedKey(i)); //And finaly we really kick him off
139 }
140 }
141 }
142 }
143 }
144
145 }// END //

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