Implementing Basic Security
Some objects will only function when their owner is trying to use them. It is also possible to program an object to only function with group members. The following sections show how to implement basic security both for the owner and for groups.
Implementing Owner Security
Sometimes an object will only work with the owner of that object. This is particularly true of vehicles. The following script shows how to detect if someone, other than the owner, is trying to use the object.
default
{
touch_start(integer total_number)
{
integer i;
for(i=0;i<total_number;i++)
{
if( llDetectedKey(i)!=llGetOwner() )
{
llSay(0, llDetectedName(i)
+ " you are not my owner.");
}
else
{
llSay(0, llDetectedName(i)
+ " you are my owner.");
}
}
}
}When the above script is touched, the above script's touch_start event handler is called. The touch_start event handler is passed a value that indicates how many avatar's are touching it at once. It is very rare that more than one avatar will be touching the object at once. However, if the object is likely to have more than one avatar touching at once, the script should use the total_number parameter.
This script makes use of the total_number parameter. A loop counts through all the avatars that have touched the object. The key to each touching avatar is obtained with llDetectedKey. This key is compared against the owner of the object. If the owner and touching avatar are not the same, the avatar is informed that they are not welcome. This is a quick method to determine whether an avatar is the owner or not.
Implementing Group Security
Sometimes a object will only work with the group of that object. The following script shows how to detect if someone, other than the group, is trying to use the object.
The group that an object is in can be set from the object properties window. Figure 1.2 shows an object with a group set.
Figure 1.2: Setting the Group of an Object

The following script checks to see if the user that touched the object is in the same group as the object being touched.
default
{
touch_start(integer total_number)
{
integer i;
for(i=0;i<total_number;i++)
{
if( llDetectedGroup(i)==FALSE )
{
llSay(0, llDetectedName(i)
+ " you must be in correct group.");
}
else
{
llSay(0, llDetectedName(i)
+ " you are in my group.");
}
}
}
}To detect whether the touching avatar is in the same group as the object, the llDetectGroup function is called. If the avatar is in the same group, a value of TRUE is returned, otherwise FALSE is returned.




