Difference between revisions of "User:Daemonika Nightfire/Scripts/Access Tutorial EN"
(→Listener - Owner: translate) |
m (<lsl> tag to <source>) |
||
(10 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
{{KBcaution| | 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. | ||
< | <source lang="lsl2"> | ||
default | default | ||
{ | { | ||
Line 24: | Line 28: | ||
} | } | ||
} | } | ||
</ | </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. | ||
< | <source lang="lsl2"> | ||
key owner; // global variable for store the OwnerKey. | key owner; // global variable for store the OwnerKey. | ||
Line 55: | Line 59: | ||
} | } | ||
} | } | ||
</ | </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''' | ||
|- | |- | ||
||< | ||<source lang="lsl2"> | ||
touch_start(integer num_detected) | touch_start(integer num_detected) | ||
{ | { | ||
Line 75: | Line 79: | ||
} | } | ||
} | } | ||
</ | </source> | ||
||< | ||<source lang="lsl2"> | ||
touch_start(integer num_detected) | touch_start(integer num_detected) | ||
{ | { | ||
Line 89: | Line 93: | ||
llSay(0, Message); | llSay(0, Message); | ||
} | } | ||
</ | </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. | ||
< | <source lang="lsl2"> | ||
touch_start(integer num_detected) | touch_start(integer num_detected) | ||
{ | { | ||
Line 104: | Line 108: | ||
} | } | ||
} | } | ||
</ | </source> | ||
==Group== | ==Group== | ||
Line 113: | Line 117: | ||
! '''better Method''' | ! '''better Method''' | ||
|- | |- | ||
||< | ||<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: | ||
} | } | ||
} | } | ||
</ | </source> | ||
||< | ||<source lang="lsl2"> | ||
default | default | ||
{ | { | ||
Line 174: | Line 178: | ||
} | } | ||
} | } | ||
</ | </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. | ||
< | <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))))) // | 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: | ||
} | } | ||
} | } | ||
</ | </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. | ||
< | <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)))) // | if(~llListFindList(VIP, llCSV2List(llDetectedKey(0)))) // search the key of the avatar who clicked in the list | ||
</ | </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. | ||
< | <source lang="lsl2"> | ||
default | default | ||
{ | { | ||
Line 248: | Line 252: | ||
} | } | ||
} | } | ||
</ | </source> | ||
==Listener - Owner== | ==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. | 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. | ||
< | <source lang="lsl2"> | ||
default | default | ||
{ | { | ||
Line 286: | Line 290: | ||
} | } | ||
} | } | ||
</ | </source> | ||
==Listener - Group== | ==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. | |||
< | <source lang="lsl2"> | ||
default | default | ||
{ | { | ||
state_entry() | state_entry() | ||
{ | { | ||
// | // here it is impossible to compare the group. | ||
llListen(0, "", "", ""); // | 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) // | if(llSameGroup(id) == TRUE) // is the recognized group of the avatar the same as that of the object RIGHT? | ||
{ | { | ||
if(message == " | if(message == "hello") // Responds to the word 'hello' when it is written in the chat. | ||
{ | { | ||
llSay(0, " | llSay(0, "Hello " + llGetDisplayName(id)); | ||
} | } | ||
} | } | ||
Line 316: | Line 320: | ||
} | } | ||
} | } | ||
</ | </source> | ||
==Listener - Accesslist== | ==Listener - Accesslist== | ||
Like the Script above compares the following script the key of the avatar with the list inside the listener event. | |||
< | <source lang="lsl2"> | ||
// | // 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() | ||
{ | { | ||
// | // 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))) // | if(~llListFindList(VIP, llCSV2List(id))) // is the recognized key of the avatar stored in the list? | ||
{ | { | ||
if(message == "hallo") // | 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: | ||
} | } | ||
} | } | ||
</ | </source> | ||
As mentioned in Example touch, you can also query the name of the avatars. | |||
Replace the corresponding entries for the following examples. | |||
< | <source lang="lsl2"> | ||
// User | // 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"]; | ||
// | // This if compares the name of the person who clicked it with the list. | ||
if(~llListFindList(VIP, llCSV2List(llGetUsername(id)))) // | if(~llListFindList(VIP, llCSV2List(llGetUsername(id)))) // // search the name of the avatar who clicked in the list | ||
</ | </source> | ||
==Changeable authorization example with menu== | ==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. | |||
< | <source lang="lsl2"> | ||
key owner; // | 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"]; | 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) // | menu(key user,string title,list buttons) // this funktion allows you to use endless different dialogs with one timer. | ||
{ | { | ||
llListenRemove(menu_handler); // | llListenRemove(menu_handler); // delete the last known listener (useful when a timer still running) | ||
menu_channel = (integer)(llFrand(9999999.0) * -1); // | menu_channel = (integer)(llFrand(9999999.0) * -1); // random channel from -9999999.0 to 9999999.0 | ||
menu_handler = llListen(menu_channel,"","",""); // | menu_handler = llListen(menu_channel,"","",""); // create a new Listener with new Channel | ||
llDialog(user, title, buttons, menu_channel); // | llDialog(user, title, buttons, menu_channel); // open the dialog for the user | ||
llSetTimerEvent(30.0); // | 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(); // | owner = llGetOwner(); // store the OwnerKey (UUID) | ||
} | } | ||
Line 397: | Line 401: | ||
key Avatar = llDetectedKey(0); | key Avatar = llDetectedKey(0); | ||
if(Avatar == owner) // | if(Avatar == owner) // detected Key == (equal) Owner | ||
{ | { | ||
menu(owner," | menu(owner,"This menue are for the owner.",["Owner","Group","Public","1","2","3","OK"]); | ||
} | } | ||
else if(~llListFindList(VIP, llCSV2List(Avatar))) // | else if(~llListFindList(VIP, llCSV2List(Avatar))) // search the key of the avatar who clicked in the list | ||
{ | { | ||
menu(Avatar," | menu(Avatar,"This menue are for VIP's.",["1","2","3","OK"]); | ||
} | } | ||
Line 412: | Line 416: | ||
if(Group) | if(Group) | ||
{ | { | ||
menu(Avatar," | 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," | 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) | ||
{ | { | ||
// | // These options can be changed only by the owner. | ||
if(message == "Owner") | if(message == "Owner") | ||
{ | { | ||
GroupAccess = FALSE; | GroupAccess = FALSE; | ||
PublicAccess = FALSE; | PublicAccess = FALSE; | ||
llOwnerSay(" | llOwnerSay("Access: Owner"); | ||
} | } | ||
else if(message == "Group") | else if(message == "Group") | ||
Line 435: | Line 439: | ||
GroupAccess = TRUE; | GroupAccess = TRUE; | ||
PublicAccess = FALSE; | PublicAccess = FALSE; | ||
llOwnerSay(" | 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(" | llOwnerSay("Access: All / public"); | ||
} | } | ||
// | // This options can be used by Owner, VIP and Group-Members. | ||
else if(message == "1") | else if(message == "1") | ||
{ | { | ||
llSay(0," | llSay(0,"Owner, VIP or Group-Members pressed '1'."); | ||
} | } | ||
else if(message == "2") | else if(message == "2") | ||
{ | { | ||
llSay(0," | llSay(0,"Owner, VIP or Group-Members pressed '2'."); | ||
} | } | ||
else if(message == "3") | else if(message == "3") | ||
{ | { | ||
llSay(0," | llSay(0,"Owner, VIP or Group-Members pressed '3'."); | ||
} | } | ||
// | // This option can used by all, then public is set. | ||
else if(message == "OK") | else if(message == "OK") | ||
{ | { | ||
llSay(0," | llSay(0,"Someone pressed 'OK'."); | ||
} | } | ||
} | } | ||
Line 467: | Line 471: | ||
timer() | timer() | ||
{ | { | ||
llSetTimerEvent(0.0); // | llSetTimerEvent(0.0); // stop the Timer | ||
llListenRemove(menu_handler); // | llListenRemove(menu_handler); // delete the current Listener | ||
} | } | ||
Line 476: | Line 480: | ||
} | } | ||
} | } | ||
</ | </source> |
Latest revision as of 18:16, 24 January 2015
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
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();
}
}