Rolig Loon Posted March 4, 2011 Share Posted March 4, 2011 We seem to get a lot of requests for a script that will give access to some residents but not others. Here is a generic script that lets the owner give access to (1) Owner only, (2) Group and owner, (3) whitelisted avatars, (4) group and whitelisted avatars, or (5) everyone. All you need to do is drop the script and a notecard with whitelisted names into an object. (Be sure to add your own event in state OK to define the action that people with access are allowed to do -- open a door, receive an object, play a sound .... whatever.) // Generic Whitelist Script -- Rolig Loon -- March 2011 // Put login names (NOT Display names) of avatars to be whitelisted in a notecard, one per line // Spelling and capitalization count list gWhiteList = []; string gCard; integer gLine; key gQuery; list gWho = ["Me Only","Group","List","Group+List","Everyone"]; integer gAccess; integer gDChnl; default // Read Whitelist from notecard, one name per line { state_entry() { if(llGetInventoryNumber(INVENTORY_NOTECARD) == 1) { gCard = llGetInventoryName(INVENTORY_NOTECARD,0); gQuery = llGetNotecardLine(gCard, 0); } else { llOwnerSay("The whitelist notecard is missing."); } } changed(integer change) { if (change & CHANGED_INVENTORY) { llResetScript(); } } dataserver(key QID, string data) { if(gQuery == QID) { if (data != EOF) { gWhiteList += [llStringTrim(data,STRING_TRIM)]; gQuery = llGetNotecardLine(gCard, ++gLine); } else { llOwnerSay("Initialized"); state running; } } } } state running { state_entry() { gDChnl = (integer) ("0xF" + llGetSubString(llGetOwner(),0,6)); } changed(integer change) { if (change & CHANGED_INVENTORY) { llResetScript(); } } touch_start(integer total_number) { llResetTime(); integer idx = llListFindList(gWhiteList,[llDetectedName(0)]); if (llDetectedKey(0) != llGetOwner()) { if ((gAccess == 4) || ((gAccess == 3) && (~idx || llSameGroup(llDetectedKey(0)))) || ((gAccess == 2) && (~idx)) || ((gAccess == 1) && (llSameGroup(llDetectedKey(0))))) { llSay(0,"Access granted."); state OK; } else { llSay(0,"Access denied."); } } } touch_end(integer num) //Mouse button released { if(llDetectedKey(0) == llGetOwner()) { if (llGetTime() < 3.0 ) //Less than 3 seconds after mouse button down { llSay(0,"Access granted."); state OK; } else if (llGetTime() >= 3.0 ) // Owner set access permissions { llListen(gDChnl,"","",""); llDialog(llGetOwner(),"Who should have access?",gWho,gDChnl); } } } listen(integer channel, string name, key id, string msg) { gAccess = llListFindList(gWho,[msg]); string temp; if (gAccess == 0) { temp = "you only."; } else if (gAccess == 1) { temp = "group members only."; } else if (gAccess == 2) { temp = " \n" + llDumpList2String(gWhiteList," \n"); } else if (gAccess == 3) { temp = "this group and " + " \n" +llDumpList2String(gWhiteList, " \n"); } else { temp = "everyone."; } llOwnerSay("Access has been granted to " + temp); } } state OK { state_entry() { llSetTimerEvent(10.0); llSay(0,"You're in!"); } changed(integer change) { if (change & CHANGED_INVENTORY) { llResetScript(); } } // Insert whatever events you want available for people with access // Be sure that there is a path back to state running timer() // Return to previous state if nothing else happens before timer triggers { llSetTimerEvent(0.0); state running; } } 3 2 Link to comment Share on other sites More sharing options...
Swimmie Chaffe Posted May 9, 2011 Share Posted May 9, 2011 Greeting Rolig, just wanted to thank you for sharing this wonderful scirpt. I had been struggling with a whitelist for quite a while, and finally could write a script I wanted by working from your codes. Your generous guidance is much appreciated! Link to comment Share on other sites More sharing options...
Jam Mint Posted June 28, 2011 Share Posted June 28, 2011 Thanks, going to be using this in a few ways Link to comment Share on other sites More sharing options...
Henning Lionheart Posted April 20, 2012 Share Posted April 20, 2012 Oh this is definately something I can use Link to comment Share on other sites More sharing options...
candella1 Posted October 8, 2012 Share Posted October 8, 2012 thanks very much for this script!it is really very usefull!!!but i have something to ask....you have in the object's contents a notecard with avatars names who are allowed to add things in your prim.but when someone puts a second notepad in prim's contents the script doesn't work.can i do something about this??for example there is a way in this script that i can make it to read whitelisted avatars only from a certain notepad ?????? Link to comment Share on other sites More sharing options...
Darkie Minotaur Posted October 8, 2012 Share Posted October 8, 2012 Change the default state_entry to if( llGetInventoryType(gCard) == 7) { gQuery = llGetNotecardLine(gCard, 0); } else { llOwnerSay("The whitelist notecard is missing."); } You must supply the card name in this case - e.g. where it is declared string gCard ="MyWhitelist"; 1 Link to comment Share on other sites More sharing options...
candella1 Posted October 8, 2012 Share Posted October 8, 2012 thank you very much for replying to me so early!!!now my script works perfectly!!! :-) Link to comment Share on other sites More sharing options...
LashElmond Posted December 28, 2012 Share Posted December 28, 2012 Hello, I tried to implement the "Linkable Mulitprim Sliding Door"" script into this one here. Thanks in both cases for the code as I am hard working on getting better in scripting, which rather means that I am spending lots of time with trial and error than really knowing what I am doing. But it could be worse *smirks* Anyways, I could make it work fo me (and only me) that I click the linked multiprim door, then it says the message about Access granted. So as there is also a timer, I have a certain time span during that it is possible to open the door by clicking it again (or close) before the access will be checked again. The problem is, that the login names which I put in the notecard, and this in the same prim´s inventory as the script, do not have access as it is meant to be. I checked the spelling and capitalization twice. I am not sure if I should post the script in here (it´s kind of big), but without doing that there will be no way I guess. So I would be thankful for suggestion what I am doing wrong. // Generic Whitelist Script -- Rolig Loon -- March 2011// Put login names (NOT Display names) of avatars to be whitelisted in a notecard, one per line// Spelling and capitalization count//MEINE NOTIZEN: der erste Klick checkt die Permissions von der Notecard. Dann gibt es einen Zeitraum, während dem man durch Klicken die Tür öffnet und schließt. Die Dauer des Zeitraums kann im state OK Teil geändert werden.list gWhiteList = [];string gCard;integer gLine;key gQuery;list gWho = ["Me Only","Group","List","Group+List","Everyone"];integer gAccess;integer gDChnl;//--- Part of the "Sliding Door in Linkset" Scriptinteger gON = 1; // Change to -1 to reverse the direction of openingfloat gDistance = 0.5; // Adjust to set the distance the door should move long its local Y axis//---default // Read Whitelist from notecard, one name per line{ state_entry() { if(llGetInventoryNumber(INVENTORY_NOTECARD) == 1) { gCard = llGetInventoryName(INVENTORY_NOTECARD,0); gQuery = llGetNotecardLine(gCard, 0); } else { llOwnerSay("The whitelist notecard is missing."); } } changed(integer change) { if (change & CHANGED_INVENTORY) { llResetScript(); } } dataserver(key QID, string data) { if(gQuery == QID) { if (data != EOF) { gWhiteList += [llStringTrim(data,STRING_TRIM)]; gQuery = llGetNotecardLine(gCard, ++gLine); } else { llOwnerSay("Initialized"); state running; } } }}state running{ state_entry() { gDChnl = (integer) ("0xF" + llGetSubString(llGetOwner(),0,6)); } changed(integer change) { if (change & CHANGED_INVENTORY) { llResetScript(); } } touch_start(integer total_number) { llResetTime(); integer idx = llListFindList(gWhiteList,[llDetectedName(0)]); if (llDetectedKey(0) != llGetOwner()) { if ((gAccess == 4) || ((gAccess == 3) && (~idx || llSameGroup(llDetectedKey(0)))) || ((gAccess == 2) && (~idx)) || ((gAccess == 1) && (llSameGroup(llDetectedKey(0))))) { llSay(0,"Access granted."); state OK; } else { llSay(0,"Access denied."); } } } touch_end(integer num) //Mouse button released { if(llDetectedKey(0) == llGetOwner()) { if (llGetTime() < 3.0 ) //Less than 3 seconds after mouse button down { llSay(0,"Access granted."); state OK; } else if (llGetTime() >= 3.0 ) // Owner set access permissions { llListen(gDChnl,"","",""); llDialog(llGetOwner(),"Who should have access?",gWho,gDChnl); } } } listen(integer channel, string name, key id, string msg) { gAccess = llListFindList(gWho,[msg]); string temp; if (gAccess == 0) { temp = "you only."; } else if (gAccess == 1) { temp = "group members only."; } else if (gAccess == 2) { temp = " \n" + llDumpList2String(gWhiteList," \n"); } else if (gAccess == 3) { temp = "this group and " + " \n" +llDumpList2String(gWhiteList, " \n"); } else { temp = "everyone."; } llOwnerSay("Access has been granted to " + temp); }}state OK{ state_entry() { llSetTimerEvent(60.0); llWhisper(0,"You have 60 seconds to open and close the door before your access permissions will be checked again."); } changed(integer change) { if (change & CHANGED_INVENTORY) { llResetScript(); } } // Insert whatever events you want available for people with access // Be sure that there is a path back to state running touch_start(integer total_number) { if (llGetLinkName(llDetectedLinkNumber(0)) == "DOOR") { integer i; for (i=2;i<=llGetNumberOfPrims();++i) { if (llGetLinkName(i) == "DOOR") { list temp = llGetLinkPrimitiveParams(i,[PRIM_POSITION,PRIM_ROT_LOCAL]); rotation local_rot = (rotation)llList2String(temp,1); vector local_pos = ((vector)llList2String(temp,0)- llGetPos())/llGetRot(); llSetLinkPrimitiveParamsFast(i,[PRIM_POSITION,local_pos + (<0.0,gDistance *gON,0.0>*local_rot),PRIM_ROTATION,local_rot/llGetRot()]); } } gON = (-1)*gON; } } //End of Sliding Action timer() // Return to previous state if nothing else happens before timer triggers { llSetTimerEvent(0.0); state running; }} Link to comment Share on other sites More sharing options...
LashElmond Posted December 29, 2012 Share Posted December 29, 2012 Ok, it works now. I took care about the capitalization as Rolig mentioned. But it had to be different than I thought. I typed the login names exactly as shown in my friends list and there have been some with lower case and/or a dot between the two names. Spelling them with capitals and without that dot finally works. Link to comment Share on other sites More sharing options...
Rolig Loon Posted January 2, 2013 Author Share Posted January 2, 2013 Sorry that I didn't see your post until after I got back from the holidays, but I'm glad that you figured out your problem. The many variants of SL names make life interesting for scripters. If you want to be diligent about capturing all of them, you have to write a discouraging mess of extra code. Innula has done just that, so if you dig through scripts she has posted in the forums, you can save yourself a lot of trouble. Incidentally, the LSL Scripting Library is really not the place for this sort of debugging/experimenting conversation. Next time you have something cool like this to discuss, it ought to be in the LSL Scripting forum, where other scripters are more likely to see it. :smileywink: Link to comment Share on other sites More sharing options...
SosuskeAizen Posted July 24, 2014 Share Posted July 24, 2014 Ok i have a question how do i set the modes?? Me only Group only exc Link to comment Share on other sites More sharing options...
Rolig Loon Posted July 25, 2014 Author Share Posted July 25, 2014 Just as it says in the script.... if you're the owner, touch and hold your mouse button down for 3 seconds to activate the permission menu. You could shorten that time if you like, or you could redesign that part of the script to simply offer the owner a different dialog menu than anyone else. Whatever magic appeals to you. This script was in part a demonstration of the way to use time delay to separate user functions from owner functions. Link to comment Share on other sites More sharing options...
Miguelito Shilova Posted February 20, 2015 Share Posted February 20, 2015 Hi Rolig, As always, I appreciate all the help you've given me with scripting, including with this whitelist script. I've used it before with a hot tub cover, and it worked beautifully. I am looking to apply the whitelist function to control access to a boat. Might I ask how one could incorporate the functions to work with the pilot sitting and taking controls? Here's how the code currently is written, which currently only works with the owner. I'm pretty what I have below constitutes the relevant functions of the script that handle pilot seating. integer sit; // declares 'sit' as being either 'TRUE' or 'FALSE,' depending on if the pilot is sitting or notkey pilot; // this declares 'pilot' as placeholder for the pilot's UUID key // DETECT AV SITTING/UNSITTING AND GIVE PERMISSIONS changed(integer change) { key agent = llAvatarOnSitTarget(); if(change & CHANGED_LINK) { if (agent == NULL_KEY && sit) { // // Pilot gets out of vehicle // llSetStatus(STATUS_PHYSICS, FALSE); llSetTimerEvent(0.0); sit = FALSE; llMessageLinked(LINK_SET, 0, "throttle", ""); llMessageLinked(LINK_SET, 0, "unseated", ""); llStopSound(); llReleaseControls(); set_motor(); } else if (agent == llGetOwner() && !sit) { // // Pilot gets into vehicle // sit = TRUE; pilot = agent; llSetStatus(STATUS_PHYSICS,TRUE); llRequestPermissions(pilot, PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION); llSetTimerEvent(TIMER_DELAY); llMessageLinked(LINK_SET, 0, "seated", ""); } } } Mig Link to comment Share on other sites More sharing options...
Rolig Loon Posted February 20, 2015 Author Share Posted February 20, 2015 Try using the whitelist test to set a flag that is either 0 (not authorized) or 1 (authorized). Then wrap a test for that flag around everything in your changed event after if(changed & CHANGED_LINK). So basically, if (toucher_is_authorized){ if ((agent == NULL_KEY) && sit) { // and so forth all the way to the end }} Or, you just put the changed event in state OK, where it's not accessible until after the whitelist test changes state to there. Link to comment Share on other sites More sharing options...
computergeek3k Posted August 20, 2016 Share Posted August 20, 2016 sry to reopen a old thread but i have been trying to figure out for some time now how to get a script to use a access list to set a parcel stream ie: avtarname = landmedia url, now eaither i have not dug far enough or no one has felt it nessary to post a example so i am hoping someone here may be abel to help, I can get the generic whitelist to compile but as for the script (or any script for that matter) seeing a second value like land media ur im at a loss. Link to comment Share on other sites More sharing options...
Rolig Loon Posted August 24, 2016 Author Share Posted August 24, 2016 If you're using this script, all you need to pay attention to is the note in state OK that says: // Insert whatever events you want available for people with access // Be sure that there is a path back to state running So if you need to llSetParcelMedia, figure out whether you want to just do it in the touch_start event or in a new event. As long as your visitor has made it as far as state OK, you can let him do whatever you want. Link to comment Share on other sites More sharing options...
Rivengate Posted June 30, 2023 Share Posted June 30, 2023 (edited) I'm so sorry to be this person but I'm just starting to learn scripting and am not that great at it. I wanted to use this to KEEP people from touching my objects and activating scripts that were already in them? But I can't seem to figure out how to do that as even though it says access denied, anyone can still touch and cause the effect... I tried putting my script in at the end but I just get endless Syntax errors Edited June 30, 2023 by Rivengate Link to comment Share on other sites More sharing options...
Wulfie Reanimator Posted June 30, 2023 Share Posted June 30, 2023 6 hours ago, Rivengate said: I'm so sorry to be this person but I'm just starting to learn scripting and am not that great at it. I wanted to use this to KEEP people from touching my objects and activating scripts that were already in them? But I can't seem to figure out how to do that as even though it says access denied, anyone can still touch and cause the effect... I tried putting my script in at the end but I just get endless Syntax errors The above script is probably a lot more complicated than you need. Let's say you have a script like this, which does something on touch: default { touch_start(integer num_detected) { llWhisper(0, "Only my owner is supposed to hear this!"); } } To prevent others from touching/activating your code, you can check if the detected key (the toucher) is the same as the owner (you), and only then run your code: default { touch_start(integer num_detected) { if (llDetectedKey(0) == llGetOwner()) { llWhisper(0, "Only my owner is supposed to hear this!"); } } } To learn more about llDetectedKey and what it does (or when it can be used), you can refer to the wiki page: https://wiki.secondlife.com/wiki/LlDetectedKey 1 Link to comment Share on other sites More sharing options...
Love Zhaoying Posted June 30, 2023 Share Posted June 30, 2023 6 hours ago, Rivengate said: I wanted to use this to KEEP people from touching my objects and activating scripts that were already in them? @Wulfie Reanimator I don't see how you can prevent users from activating "existing scripts" (scripts you did not write), unless those scripts had an option to check for "Owner" vs. "User in Same Group" (if object were deeded to a Group, for instance). I suppose depending on the "existing script" you could keep it "not running" add your own script that only sets the "existing" script to "running" when touched by the right people.. Link to comment Share on other sites More sharing options...
Wulfie Reanimator Posted June 30, 2023 Share Posted June 30, 2023 4 minutes ago, Love Zhaoying said: @Wulfie Reanimator I don't see how you can prevent users from activating "existing scripts" (scripts you did not write), unless those scripts had an option to check for "Owner" vs. "User in Same Group" (if object were deeded to a Group, for instance). I suppose depending on the "existing script" you could keep it "not running" add your own script that only sets the "existing" script to "running" when touched by the right people.. Yeah, the script itself needs to be smart enough to know when it shouldn't act. 🙂 Rivengate was talking about editing a script, though. Seems like they added Rolig's script alongside their own script at first, and then tried copypasting both scripts into the same file (which caused syntax errors). Link to comment Share on other sites More sharing options...
Love Zhaoying Posted June 30, 2023 Share Posted June 30, 2023 (edited) 37 minutes ago, Wulfie Reanimator said: Rivengate was talking about editing a script, though. Sorry, I thought they meant "adding the functionality" to prims where existing scripts were. ("Not his" scripts!) Since they replied to this thread 6 years after Rolig's post, I didn't assumed they were NOT replying saying they tried Rolig's script (but had the general use-case need). You know me, low comprehension! LOL! Edited June 30, 2023 by Love Zhaoying Logic! Assumed they were NOT arrgh!! 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now