Difference between revisions of "User:Daemonika Nightfire/Scripts/Access Tutorial EN"

From Second Life Wiki
Jump to navigation Jump to search
m (<lsl> tag to <source>)
 
(11 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{KBcaution|''' In translation work. ''' My english are not the best if you find mistyped, wrong or stupid comments feel free and improve it, but please don't change the scripts itself.}}
Language:
[[File:Solution_provider_flag_us.gif|link=User:Daemonika_Nightfire/Scripts/Access_Tutorial_EN]]
[[File:Solution_provider_flag_de.gif|link=User:Daemonika_Nightfire/Scripts/Access_Tutorial]]
 
{{KBcaution|My english are not the best if you find mistyped, wrong or stupid comments feel free and improve it, but please don't change the scripts itself.}}


==General Permissions==
==General Permissions==
The first 4 examples works in all events where you can use llDetectedKey(0) to get the AvatarKey (UUID). For easy understand i just show it with the touch event and for comparisation deeper with the listener event, because there are llDetectedKey(0) impossible.
The first 4 examples works in all events where you can use [[LlDetectedKey|llDetectedKey(0)]] to get the AvatarKey (UUID). For easy understand i just show it with the touch event and for comparisation deeper with the listener event, because there are [[LlDetectedKey|llDetectedKey(0)]] impossible.


==Public==
==Public==
This easy example are the same like a "New Script" which everyone can create in a simple prim. It has no restrictions and can used by everyone.
This easy example are the same like a "New Script" which everyone can create in a simple prim. It has no restrictions and can used by everyone.
<lsl>
<source lang="lsl2">
default
default
{
{
Line 24: Line 28:
     }
     }
}
}
</lsl>
</source>


==Owner==
==Owner==
The following script are a bit different. If someone click, it will check that the Avatar who clicked it is realy the owner.
The following script are a bit different. If someone click, it will check that the Avatar who clicked it is realy the owner.
<lsl>
<source lang="lsl2">
key owner; // global variable for store the OwnerKey.
key owner; // global variable for store the OwnerKey.


Line 55: Line 59:
     }
     }
}
}
</lsl>
</source>
The following alternative examples needs the global stored vatiable 'owner' otherwise it must replaced with llGetOwner().
The following alternative examples needs the global stored vatiable 'owner' otherwise it must replaced with llGetOwner().
{| class="sortable" width="100%" {{Prettytable}}
{| class="sortable" width="100%" {{Prettytable}}
Line 62: Line 66:
! '''Alternative Methode 2'''
! '''Alternative Methode 2'''
|-
|-
||<lsl>
||<source lang="lsl2">
     touch_start(integer num_detected)
     touch_start(integer num_detected)
     {
     {
Line 75: Line 79:
         }
         }
     }
     }
</lsl>
</source>
||<lsl>
||<source lang="lsl2">
     touch_start(integer num_detected)
     touch_start(integer num_detected)
     {
     {
Line 89: Line 93:
         llSay(0, Message);
         llSay(0, Message);
     }
     }
</lsl>
</source>
|-
|-
|}
|}
Line 95: Line 99:
  That will save work and save memory for more important funktions.
  That will save work and save memory for more important funktions.
  Except you want different functions for different users, then you have different course as in the above examples.
  Except you want different functions for different users, then you have different course as in the above examples.
<lsl>
<source lang="lsl2">
     touch_start(integer num_detected)
     touch_start(integer num_detected)
     {
     {
Line 104: Line 108:
         }
         }
     }
     }
</lsl>
</source>


==Group==
==Group==
Line 113: Line 117:
! '''better Method'''
! '''better Method'''
|-
|-
||<lsl>
||<source lang="lsl2">
// This example are just for show whats going on.
// This example are just for show whats going on.


Line 143: Line 147:
     }
     }
}
}
</lsl>
</source>
||<lsl>
||<source lang="lsl2">
default
default
{
{
Line 174: Line 178:
     }
     }
}
}
</lsl>
</source>
|-
|-
|}
|}
Line 181: Line 185:
In this script the whole thing looks completely different. Unlike the first 3 versions where only those of the owner or the entire group be established, you can here more users, regardless of ownership and determine group membership. When the object is clicked, it only checked whether the name of the person who clicked it on the list.
In this script the whole thing looks completely different. Unlike the first 3 versions where only those of the owner or the entire group be established, you can here more users, regardless of ownership and determine group membership. When the object is clicked, it only checked whether the name of the person who clicked it on the list.


<lsl>
<source lang="lsl2">
// User with Resident as second name will be insert "without dot and without second name"
// User with Resident as second name will be insert "without dot and without second name"
list VIP = ["daemonika.nightfire", "jane.doe", "john.doe"];  
list VIP = ["daemonika.nightfire", "jane.doe", "john.doe"];  
Line 194: Line 198:
     touch_start(integer num_detected)
     touch_start(integer num_detected)
     {
     {
         if(~llListFindList(VIP, llCSV2List(llGetUsername(llDetectedKey(0))))) // seach the name of the avatar who clicked in the list
         if(~llListFindList(VIP, llCSV2List(llGetUsername(llDetectedKey(0))))) // search the name of the avatar who clicked in the list
         {
         {
             llSay(0, "Touched.");
             llSay(0, "Touched.");
Line 209: Line 213:
     }
     }
}
}
</lsl>
</source>
----
----
  The use of Displaynames is not recommended, because they are not unique.
  The use of Displaynames is not recommended, because they are not unique.
  It is better to focus on Usernames or AvatarKey's (UUID).
  It is better to focus on Usernames or AvatarKey's (UUID).
  This script also works with keys, replace the corresponding entries for the following examples.
  This script also works with keys, replace the corresponding entries for the following examples.
<lsl>
<source lang="lsl2">
// place here the AvatarKey's, which allowd to use the script.
// place here the AvatarKey's, which allowd to use the script.
list VIP = ["61ee201a-81cf-4322-b9a8-a5eb8da777c2", "00000000-0000-0000-0000-000000000000"];
list VIP = ["61ee201a-81cf-4322-b9a8-a5eb8da777c2", "00000000-0000-0000-0000-000000000000"];


// This if compares the key of the person who clicked it with the list.
// This if compares the key of the person who clicked it with the list.
if(~llListFindList(VIP, llCSV2List(llDetectedKey(0)))) // seach the key of the avatar who clicked in the list
if(~llListFindList(VIP, llCSV2List(llDetectedKey(0)))) // search the key of the avatar who clicked in the list
</lsl>
</source>


==Permissions in listener==
==Permissions in listener==
The Listener version I introduce only because llDetectedKey(0) does not work, but it also can be distinguished because the listener itself recognizes the 'id' (UUID). Furthermore, this method works in all events, where is not a llDetectedKey (0) possible, however, the 'id' (UUID) is the avatar otherwise recognized.
The Listener version I introduce only because [[LlDetectedKey|llDetectedKey(0)]] does not work, but it also can be distinguished because the listener itself recognizes the 'id' (UUID). Furthermore, this method works in all events, where is not a [[LlDetectedKey|llDetectedKey(0)]] possible, however, the 'id' (UUID) is the avatar otherwise recognized.


==Listener - Public==
==Listener - Public==
This script has no restrictions and can used by everyone.  
This script has no restrictions and can used by everyone.  
<lsl>
<source lang="lsl2">
default
default
{
{
Line 248: Line 252:
     }
     }
}
}
</lsl>
</source>


==Listener - Owner==
==Listener - Owner==
In diesem Script wird der Owner gleich im llListen Befehl eingetragen. Dadurch reagiert das Script ausschliesslich auf den Owner und im Listener Event sind keine weiteren Abfragen notwendig.
In this script, the Owner will be entered directly in llListen command. Thus, the script responds exclusively to the owner and the event listener are no further queries necessary.


<lsl>
<source lang="lsl2">
default
default
{
{
     state_entry()
     state_entry()
     {
     {
         // Wenn das Script ausschliesslich auf den Owner reagieren soll, ist die llGetOwner() Abfrage im llListen Befehl voellig ausreichend.
         // If the script is only reacting to the Owner, the llGetOwner () query in llListen command is sufficient.
         llListen(0, "", llGetOwner(), ""); // startet den listener
         llListen(0, "", llGetOwner(), ""); // starts the listener
          
          
         // Alternativ kann man auch den Owner Namen direkt eintragen.
         // Alternatively you can also enter the name of the owner directly.
         // Das wuerde ich aber nicht empfehlen, weil es nicht dynamisch ist und im Falle des Weitergebens nicht auf den neuen Besitzer hoert.
         // I would not recommend it because it is not dynamic, and in the case of passing not listens to the new owner.
         //llListen(0, "Daemonika Nightfire", "", ""); // startet den listener
         //llListen(0, "Daemonika Nightfire", "", ""); // starts the listener
     }
     }


     listen(integer chan, string name, key id, string message)
     listen(integer chan, string name, key id, string message)
     {
     {
         // An dieser Stelle habe ich noch die alternative Methode zum abfragen des Owners inaktiv als Beispiel eingetragen.
         // At this point, I still have the alternative method to verify with the owner, listed as inactive example.
         // Diese Methode ist nicht noetig, weil der Listener schon ab dem Befehl oben ausschliesslich auf den Owner reagiert.
         // This method is not necessary because the listener reacts as early as the command above solely to the Owner.


       // Vorraussetzung dafuer ist ein komplett leerer llListen Befehl oben: llListen(0, "", "", "");
       // This requires a completely empty llListen command above: llListen(0, "", "", "");
       //if(id == llGetOwner())
       //if(id == llGetOwner())
       //{
       //{
             if(message == "hallo") // Reagiert auf das wort 'hallo' wenn es im chat geschrieben wird.
             if(message == "hello") // Responds to the word 'hello' when it is written in the chat.
             {
             {
                 llSay(0, "Hallo " + llGetDisplayName(id));
                 llSay(0, "Hello " + llGetDisplayName(id));
             }
             }
       //}
       //}
Line 286: Line 290:
     }
     }
}
}
</lsl>
</source>


==Listener - Group==
==Listener - Group==
Um die Gruppe abzufragen muss man wie im folgenden Beispiel schon anders vorgehen. Hierbei wird erst im Listener Event die Gruppe des Objects mit der aktiven Gruppe des Avatars verglichen und dann erst auf die Message reagiert.
To query the group, you have to proceed differently in the following example. Here compares the script in the 'Listener Event', the group of the object with the active group of the avatar and then respond to the message if the group is the same.


<lsl>
<source lang="lsl2">
default
default
{
{
     state_entry()
     state_entry()
     {
     {
         // hier ist es diesmal nicht moeglich die Gruppe zu vergleichen.
         // here it is impossible to compare the group.
         llListen(0, "", "", ""); // startet den listener
         llListen(0, "", "", ""); // starts the listener
     }
     }


     listen(integer chan, string name, key id, string message)
     listen(integer chan, string name, key id, string message)
     {
     {
         if(llSameGroup(id) == TRUE) // ist die erkannte Gruppe des Avatars die selbe, wie die des  Objekts RICHTIG?
         if(llSameGroup(id) == TRUE) // is the recognized group of the avatar the same as that of the object RIGHT?
         {
         {
             if(message == "hallo") // Reagiert auf das wort 'hallo' wenn es im chat geschrieben wird.
             if(message == "hello") // Responds to the word 'hello' when it is written in the chat.
             {
             {
                 llSay(0, "Hallo " + llGetDisplayName(id));
                 llSay(0, "Hello " + llGetDisplayName(id));
             }
             }
         }
         }
Line 316: Line 320:
     }
     }
}
}
</lsl>
</source>


==Listener - Accesslist==
==Listener - Accesslist==
Wie im vorherigen Script, wird auch hier erst im Listener Event eine Zugangsliste verglichen und dann erst auf die Message reagiert.
Like the Script above compares the following script the key of the avatar with the list inside the listener event.


<lsl>
<source lang="lsl2">
// In diese Liste trage die AvatarKey's ein, welche das Scrirpt ausfuehren duerfen.
// place here the AvatarKey's, which allowd to use the script.
list VIP = ["61ee201a-81cf-4322-b9a8-a5eb8da777c2", "00000000-0000-0000-0000-000000000000"];  
list VIP = ["61ee201a-81cf-4322-b9a8-a5eb8da777c2", "00000000-0000-0000-0000-000000000000"];  


Line 329: Line 333:
     state_entry()
     state_entry()
     {
     {
         // hier ist es ebenfalls nicht moeglich die Liste zu vergleichen.
         // here it is impossible to compare the list.
         llListen(0, "", "", ""); // startet den listener
         llListen(0, "", "", ""); // startet den listener
     }
     }
Line 335: Line 339:
     listen(integer chan, string name, key id, string message)
     listen(integer chan, string name, key id, string message)
     {
     {
         if(~llListFindList(VIP, llCSV2List(id))) // sucht hier in der Liste nach dem Key (UUID) des Avatars
         if(~llListFindList(VIP, llCSV2List(id))) // is the recognized key of the avatar stored in the list?
         {
         {
             if(message == "hallo") // Reagiert auf das wort 'hallo' wenn es im chat geschrieben wird.
             if(message == "hallo") // Responds to the word 'hello' when it is written in the chat.
             {
             {
                 llSay(0, "Hallo " + llGetDisplayName(id));
                 llSay(0, "Hallo " + llGetDisplayName(id));
Line 349: Line 353:
     }
     }
}
}
</lsl>
</source>
  Wie auch oben beim Touch Beispiel kann man auch hier die Namen der Avatare abfragen.
  As mentioned in Example touch, you can also query the name of the avatars.
  Dazu ersetze die entsprechenden Eintraege im Script mit folgenden Beispielen.
  Replace the corresponding entries for the following examples.


<lsl>
<source lang="lsl2">
// User mit Resident als Nachname werden "ohne punkt und ohne Nachname" eingetragen
// User with Resident as second name will be insert "without dot and without second name"
list VIP = ["daemonika.nightfire", "jane.doe", "john.doe"];  
list VIP = ["daemonika.nightfire", "jane.doe", "john.doe"];  


// Diese if vergleicht den Namen des Avatars mit der Liste.
// This if compares the name of the person who clicked it with the list.
if(~llListFindList(VIP, llCSV2List(llGetUsername(id)))) // sucht hier in der Liste nach dem Namen des Avatars
if(~llListFindList(VIP, llCSV2List(llGetUsername(id)))) // // search the name of the avatar who clicked in the list
</lsl>
</source>


==Changeable authorization example with menu==
==Changeable authorization example with menu==
Bevor jetzt wieder jemand meckert, warum ich das Menue so und nicht anders gemacht habe, sollte man sich vor Augen halten, dass dieses nur ein Beispiel ist und es unzaehlige Varianten zum gestalten eines Menues gibt. Hier geht es einzig und allein um die Unterscheidung der Berechtigungen.
Before someone complains again why I have the menu so and not otherwise made​​, it should be borne in mind that this is just an example and there are countless variations of a design for menus. This is solely for the distinction of permissions.


<lsl>
<source lang="lsl2">
key owner; // globale Variable zum speichern des OwnerKey's
key owner; // global variable for store the OwnerKey.


// In diese Liste trage die AvatarKey's ein, welche das Scrirpt ausfuehren duerfen.
// place here the AvatarKey's, which allowd to use the script.
list VIP = ["61ee201a-81cf-4322-b9a8-a5eb8da777c2", "00000000-0000-0000-0000-000000000000"];
list VIP = ["61ee201a-81cf-4322-b9a8-a5eb8da777c2", "00000000-0000-0000-0000-000000000000"];


Line 375: Line 379:
integer menu_handler;
integer menu_handler;
integer menu_channel;
integer menu_channel;
menu(key user,string title,list buttons) // diese Funktion erlaubt dir unentlich viele Dialoge mit einem timer.
menu(key user,string title,list buttons) // this funktion allows you to use endless different dialogs with one timer.
{
{
     llListenRemove(menu_handler); // loescht den letzten bekannten Listener (nuetzlich falls der Timer noch nicht abgelaufen war)
     llListenRemove(menu_handler); // delete the last known listener (useful when a timer still running)
      
      
     menu_channel = (integer)(llFrand(9999999.0) * -1);  // zufaelliger channel von -9999999.0 bis 9999999.0
     menu_channel = (integer)(llFrand(9999999.0) * -1);  // random channel from -9999999.0 to 9999999.0
     menu_handler = llListen(menu_channel,"","","");    // erstellt hier einen neuen Listener mit dem neuen Channel
     menu_handler = llListen(menu_channel,"","","");    // create a new Listener with new Channel
     llDialog(user, title, buttons, menu_channel);      // oeffnet hier das Dialog-Fenster fuer den Benutzer
     llDialog(user, title, buttons, menu_channel);      // open the dialog for the user
      
      
     llSetTimerEvent(30.0); // startet hier den Timer, der nach ablauf der Zeit den Listener loescht.
     llSetTimerEvent(30.0); // starts the timer which after expiration of the time deletes the listener.
}
}


Line 390: Line 394:
     state_entry()
     state_entry()
     {
     {
         owner = llGetOwner(); // speichert den OwnerKey (UUID)
         owner = llGetOwner(); // store the OwnerKey (UUID)
     }
     }


Line 397: Line 401:
         key Avatar = llDetectedKey(0);
         key Avatar = llDetectedKey(0);
          
          
         if(Avatar == owner) // erkannter Key == (gleich) Owner
         if(Avatar == owner) // detected Key == (equal) Owner
         {
         {
             menu(owner,"Dieses Menue ist fuer den Besitzer.",["Owner","Group","Public","1","2","3","OK"]);
             menu(owner,"This menue are for the owner.",["Owner","Group","Public","1","2","3","OK"]);
         }
         }
          
          
         else if(~llListFindList(VIP, llCSV2List(Avatar))) // sucht hier in der Liste nach dem Key (UUID) des klickenden
         else if(~llListFindList(VIP, llCSV2List(Avatar))) // search the key of the avatar who clicked in the list
         {
         {
             menu(Avatar,"Dieses Menue ist fuer VIP's.",["1","2","3","OK"]);
             menu(Avatar,"This menue are for VIP's.",["1","2","3","OK"]);
         }
         }
          
          
Line 412: Line 416:
             if(Group)
             if(Group)
             {
             {
                 menu(Avatar,"Dieses Menue ist fuer Gruppenmitglieder",["1","2","3","OK"]);
                 menu(Avatar,"This menue are for group-members",["1","2","3","OK"]);
             }
             }
         }
         }
Line 418: Line 422:
         else if(PublicAccess == TRUE)
         else if(PublicAccess == TRUE)
         {
         {
             menu(Avatar,"Dieses Menue ist oeffentlich",["OK"]);
             menu(Avatar,"This menue is bublic",["OK"]);
         }
         }
     }
     }
Line 424: Line 428:
     listen(integer channel, string name, key id, string message)
     listen(integer channel, string name, key id, string message)
     {
     {
         // Diese Optionen koennen nur durch den Besitzer geaendert werden.
         // These options can be changed only by the owner.
         if(message == "Owner")
         if(message == "Owner")
         {
         {
             GroupAccess = FALSE;
             GroupAccess = FALSE;
             PublicAccess = FALSE;
             PublicAccess = FALSE;
             llOwnerSay("Berechtigung: Besitzer");
             llOwnerSay("Access: Owner");
         }
         }
         else if(message == "Group")
         else if(message == "Group")
Line 435: Line 439:
             GroupAccess = TRUE;
             GroupAccess = TRUE;
             PublicAccess = FALSE;
             PublicAccess = FALSE;
             llOwnerSay("Berechtigung: Besitzer & Gruppenmitglieder.");
             llOwnerSay("Access: Owner & Group-Members.");
         }
         }
         else if(message == "Public")
         else if(message == "Public")
Line 441: Line 445:
             GroupAccess = FALSE;
             GroupAccess = FALSE;
             PublicAccess = TRUE;
             PublicAccess = TRUE;
             llOwnerSay("Berechtigung: Alle / oeffentlich");
             llOwnerSay("Access: All / public");
         }
         }
          
          
         // Diese Optionen stehen sowohl Besitzer und VIP's als auch Gruppenmitgliedern zur verfuegung.
         // This options can be used by Owner, VIP and Group-Members.
         else if(message == "1")
         else if(message == "1")
         {
         {
             llSay(0,"Besitzer, VIP o. Gruppenmitglied hat die '1' gedrueckt.");
             llSay(0,"Owner, VIP or Group-Members pressed '1'.");
         }
         }
         else if(message == "2")
         else if(message == "2")
         {
         {
             llSay(0,"Besitzer, VIP o. Gruppenmitglied hat die '2' gedrueckt.");
             llSay(0,"Owner, VIP or Group-Members pressed '2'.");
         }
         }
         else if(message == "3")
         else if(message == "3")
         {
         {
             llSay(0,"Besitzer, VIP o. Gruppenmitglied hat die '3' gedrueckt.");
             llSay(0,"Owner, VIP or Group-Members pressed '3'.");
         }
         }
          
          
         // Diese Option stehen allen zur verfuegung.
         // This option can used by all, then public is set.
         else if(message == "OK")
         else if(message == "OK")
         {
         {
             llSay(0,"Es wurde auf 'OK' gedrueckt.");
             llSay(0,"Someone pressed 'OK'.");
         }
         }
     }
     }
Line 467: Line 471:
     timer()
     timer()
     {
     {
         llSetTimerEvent(0.0); // stoppt den Timer
         llSetTimerEvent(0.0); // stop the Timer
         llListenRemove(menu_handler); // loescht den aktuellen Listener
         llListenRemove(menu_handler); // delete the current Listener
     }
     }
      
      
Line 476: Line 480:
     }
     }
}
}
</lsl>
</source>

Latest revision as of 18:16, 24 January 2015

Language: Solution provider flag us.gif Solution provider flag de.gif

KBcaution.png Important: My english are not the best if you find mistyped, wrong or stupid comments feel free and improve it, but please don't change the scripts itself.

General Permissions

The first 4 examples works in all events where you can use llDetectedKey(0) to get the AvatarKey (UUID). For easy understand i just show it with the touch event and for comparisation deeper with the listener event, because there are llDetectedKey(0) impossible.

Public

This easy example are the same like a "New Script" which everyone can create in a simple prim. It has no restrictions and can used by everyone.

default
{
    state_entry()
    {
        
    }

    touch_start(integer total_number)
    {
        llSay(0, "Touched.");
    }
    
    on_rez(integer Dae)
    {
        llResetScript();
    }
}

Owner

The following script are a bit different. If someone click, it will check that the Avatar who clicked it is realy the owner.

key owner; // global variable for store the OwnerKey.

default
{
    state_entry()
    {
        owner = llGetOwner(); // store the OwnerKey (UUID)
    }

    touch_start(integer num_detected)
    {
        if(llDetectedKey(0) == owner) // detected Key == (equal) Owner
        {
            llSay(0, "Touched.");
        }
        else if(llDetectedKey(0) != owner) // detected Key != (not equal) Owner
        {
            llSay(0,"You are not the Owner.");
        }
    }
    
    on_rez(integer Dae)
    {
        llResetScript();
    }
}

The following alternative examples needs the global stored vatiable 'owner' otherwise it must replaced with llGetOwner().

Alternative Methode 1 Alternative Methode 2
    touch_start(integer num_detected)
    {
        key Avatar = llDetectedKey(0);
        if(Avatar == owner) // detected Key == (equal) Owner
        {
            llSay(0, "You are the Owner.");
        }
        else if(Avatar != owner) // detected Key == (not equal) Owner
        {
            llSay(0,"You are not the Owner.");
        }
    }
    touch_start(integer num_detected)
    {
        key Avatar = llDetectedKey(0);
        string Message = "You are not the Owner.";
        // Message will not be changed, so long not the owner click.
        if(Avatar == owner)
        {
            // Message will be replaced, when the owner click.
            Message = "You are the Owner.";
        }
        llSay(0, Message);
    }
A reverse proof with 'else if' are not needed if you just want to use it for owner only.
That will save work and save memory for more important funktions.
Except you want different functions for different users, then you have different course as in the above examples.
    touch_start(integer num_detected)
    {
        key Avatar = llDetectedKey(0);
        if(Avatar == owner) // detected Key == (equal) Owner
        {
            llSay(0, "You are the Owner.");
        }
    }

Group

This script looks different again. When someone click, it will check for the group of the avatar who clicked it. It compares the activ group of the avatar with the group with which it is rezzed.

Example 1 better Method
// This example are just for show whats going on.

default
{
    state_entry()
    {
        
    }
    
    touch_start(integer num_detected)
    {
        // the avatar wear the same group like the object?
        if(llSameGroup(llDetectedKey(0)) == TRUE)
        {
            llSay(0, "Touched.");
        }

        // the avatar don't wear the same group like the object?
        else if(llSameGroup(llDetectedKey(0)) == FALSE)
        {
            llSay(0,"You are not wearing the correct group-tag.");
        }
    }
    
    on_rez(integer Dae)
    {
        llResetScript();
    }
}
default
{
    state_entry()
    {
        
    }
    
    touch_start(integer num_detected)
    {
        key Avatar = llDetectedKey(0);
        integer Group = llSameGroup(Avatar);
        
        // the avatar wear the same group like the object?
        if(Group)
        {
            llSay(0, "Touched.");
        }
        // the avatar don't wear the same group like the object?
        else if(!Group)
        {
            llSay(0,"You are not wearing the correct group-tag.");
        }
    }
    
    on_rez(integer Dae)
    {
        llResetScript();
    }
}

Accesslist

In this script the whole thing looks completely different. Unlike the first 3 versions where only those of the owner or the entire group be established, you can here more users, regardless of ownership and determine group membership. When the object is clicked, it only checked whether the name of the person who clicked it on the list.

// User with Resident as second name will be insert "without dot and without second name"
list VIP = ["daemonika.nightfire", "jane.doe", "john.doe"]; 

default
{
    state_entry()
    {
        
    }

    touch_start(integer num_detected)
    {
        if(~llListFindList(VIP, llCSV2List(llGetUsername(llDetectedKey(0))))) // search the name of the avatar who clicked in the list
        {
            llSay(0, "Touched.");
        }
        else //if(!~llListFindList(VIP, llCSV2List(llGetUsername(llDetectedKey(0)))))
        {
            llSay(0,"You are not listed");
        }
    }
    
    on_rez(integer Dae)
    {
        llResetScript();
    }
}

The use of Displaynames is not recommended, because they are not unique.
It is better to focus on Usernames or AvatarKey's (UUID).
This script also works with keys, replace the corresponding entries for the following examples.
// place here the AvatarKey's, which allowd to use the script.
list VIP = ["61ee201a-81cf-4322-b9a8-a5eb8da777c2", "00000000-0000-0000-0000-000000000000"];

// This if compares the key of the person who clicked it with the list.
if(~llListFindList(VIP, llCSV2List(llDetectedKey(0)))) // search the key of the avatar who clicked in the list

Permissions in listener

The Listener version I introduce only because llDetectedKey(0) does not work, but it also can be distinguished because the listener itself recognizes the 'id' (UUID). Furthermore, this method works in all events, where is not a llDetectedKey(0) possible, however, the 'id' (UUID) is the avatar otherwise recognized.

Listener - Public

This script has no restrictions and can used by everyone.

default
{
    state_entry()
    {
        llListen(0, "", "", ""); // starts the listener
    }

    listen(integer chan, string name, key id, string message)
    {
        if(message == "hello") // Responds to the word 'hello' when it is written in the chat.
        {
            llSay(0, "Hello " + llGetDisplayName(id));
        }
    }
    
    on_rez(integer Dae)
    {
        llResetScript();
    }
}

Listener - Owner

In this script, the Owner will be entered directly in llListen command. Thus, the script responds exclusively to the owner and the event listener are no further queries necessary.

default
{
    state_entry()
    {
        // If the script is only reacting to the Owner, the llGetOwner () query in llListen command is sufficient.
        llListen(0, "", llGetOwner(), ""); // starts the listener
        
        // Alternatively you can also enter the name of the owner directly.
        // I would not recommend it because it is not dynamic, and in the case of passing not listens to the new owner.
        //llListen(0, "Daemonika Nightfire", "", ""); // starts the listener
    }

    listen(integer chan, string name, key id, string message)
    {
        // At this point, I still have the alternative method to verify with the owner, listed as inactive example.
        // This method is not necessary because the listener reacts as early as the command above solely to the Owner.

      // This requires a completely empty llListen command above: llListen(0, "", "", "");
      //if(id == llGetOwner())
      //{
            if(message == "hello") // Responds to the word 'hello' when it is written in the chat.
            {
                llSay(0, "Hello " + llGetDisplayName(id));
            }
      //}
    }
    
    on_rez(integer Dae)
    {
        llResetScript();
    }
}

Listener - Group

To query the group, you have to proceed differently in the following example. Here compares the script in the 'Listener Event', the group of the object with the active group of the avatar and then respond to the message if the group is the same.

default
{
    state_entry()
    {
        // here it is impossible to compare the group.
        llListen(0, "", "", ""); // starts the listener
    }

    listen(integer chan, string name, key id, string message)
    {
        if(llSameGroup(id) == TRUE) // is the recognized group of the avatar the same as that of the object RIGHT?
        {
            if(message == "hello") // Responds to the word 'hello' when it is written in the chat.
            {
                llSay(0, "Hello " + llGetDisplayName(id));
            }
        }
    }
    
    on_rez(integer Dae)
    {
        llResetScript();
    }
}

Listener - Accesslist

Like the Script above compares the following script the key of the avatar with the list inside the listener event.

// place here the AvatarKey's, which allowd to use the script.
list VIP = ["61ee201a-81cf-4322-b9a8-a5eb8da777c2", "00000000-0000-0000-0000-000000000000"]; 

default
{
    state_entry()
    {
        // here it is impossible to compare the list.
        llListen(0, "", "", ""); // startet den listener
    }

    listen(integer chan, string name, key id, string message)
    {
        if(~llListFindList(VIP, llCSV2List(id))) // is the recognized key of the avatar stored in the list?
        {
            if(message == "hallo") // Responds to the word 'hello' when it is written in the chat.
            {
                llSay(0, "Hallo " + llGetDisplayName(id));
            }
        }
    }
    
    on_rez(integer Dae)
    {
        llResetScript();
    }
}
As mentioned in Example touch, you can also query the name of the avatars.
Replace the corresponding entries for the following examples.
// User with Resident as second name will be insert "without dot and without second name"
list VIP = ["daemonika.nightfire", "jane.doe", "john.doe"]; 

// This if compares the name of the person who clicked it with the list.
if(~llListFindList(VIP, llCSV2List(llGetUsername(id)))) // // search the name of the avatar who clicked in the list

Changeable authorization example with menu

Before someone complains again why I have the menu so and not otherwise made​​, it should be borne in mind that this is just an example and there are countless variations of a design for menus. This is solely for the distinction of permissions.

key owner; // global variable for store the OwnerKey.

// place here the AvatarKey's, which allowd to use the script.
list VIP = ["61ee201a-81cf-4322-b9a8-a5eb8da777c2", "00000000-0000-0000-0000-000000000000"];

integer GroupAccess = FALSE;
integer PublicAccess = FALSE;

integer menu_handler;
integer menu_channel;
menu(key user,string title,list buttons) // this funktion allows you to use endless different dialogs with one timer.
{
    llListenRemove(menu_handler); // delete the last known listener (useful when a timer still running)
    
    menu_channel = (integer)(llFrand(9999999.0) * -1);  // random channel from -9999999.0 to 9999999.0
    menu_handler = llListen(menu_channel,"","","");     // create a new Listener with new Channel
    llDialog(user, title, buttons, menu_channel);       // open the dialog for the user
    
    llSetTimerEvent(30.0); // starts the timer which after expiration of the time deletes the listener.
}

default
{
    state_entry()
    {
        owner = llGetOwner(); // store the OwnerKey (UUID)
    }

    touch_start(integer num_detected)
    {
        key Avatar = llDetectedKey(0);
        
        if(Avatar == owner) // detected Key == (equal) Owner
        {
            menu(owner,"This menue are for the owner.",["Owner","Group","Public","1","2","3","OK"]);
        }
        
        else if(~llListFindList(VIP, llCSV2List(Avatar))) // search the key of the avatar who clicked in the list
        {
            menu(Avatar,"This menue are for VIP's.",["1","2","3","OK"]);
        }
        
        else if(GroupAccess == TRUE)
        {
            integer Group = llSameGroup(Avatar);
            if(Group)
            {
                menu(Avatar,"This menue are for group-members",["1","2","3","OK"]);
            }
        }
        
        else if(PublicAccess == TRUE)
        {
            menu(Avatar,"This menue is bublic",["OK"]);
        }
    }
    
    listen(integer channel, string name, key id, string message)
    {
        // These options can be changed only by the owner.
        if(message == "Owner")
        {
            GroupAccess = FALSE;
            PublicAccess = FALSE;
            llOwnerSay("Access: Owner");
        }
        else if(message == "Group")
        {
            GroupAccess = TRUE;
            PublicAccess = FALSE;
            llOwnerSay("Access: Owner & Group-Members.");
        }
        else if(message == "Public")
        {
            GroupAccess = FALSE;
            PublicAccess = TRUE;
            llOwnerSay("Access: All / public");
        }
        
        // This options can be used by Owner, VIP and Group-Members.
        else if(message == "1")
        {
            llSay(0,"Owner, VIP or Group-Members pressed '1'.");
        }
        else if(message == "2")
        {
            llSay(0,"Owner, VIP or Group-Members pressed '2'.");
        }
        else if(message == "3")
        {
            llSay(0,"Owner, VIP or Group-Members pressed '3'.");
        }
        
        // This option can used by all, then public is set.
        else if(message == "OK")
        {
            llSay(0,"Someone pressed 'OK'.");
        }
    }
    
    timer()
    {
        llSetTimerEvent(0.0); // stop the Timer
        llListenRemove(menu_handler); // delete the current Listener
    }
    
    on_rez(integer Dae)
    {
        llResetScript();
    }
}