Scripting Permissions..... (of sorts)
|
Lars Bismark
Registered User
Join date: 6 Jun 2004
Posts: 6
|
11-04-2004 21:30
Hi, My LSL skills are pretty poor - and while I can be dangerous editing existing scripts to do my bidding - scripting from scratch eludes me thus far. I have a simple script a friend whipped up for me using the llSetParcelMusicURL function to "change" between Music URL's on my land. The script goes like this: ************************************ integer url = 0; default { state_entry() { } touch_start(integer total_number) { url += 1; if (url == 1) { llSetText("Stream 1", <1,1,1>, 1.5); llSetParcelMusicURL("http://192.182.76.21:8000"  ; } if (url == 2) { llSetText("Stream 2", <1,1,1>, 1.5); llSetParcelMusicURL("http://mystic1.streamguys.net:7150"  ; } if (url == 3) { llSetText("Stream 3", <1,1,1>, 1.5); llSetParcelMusicURL("http://64.236.34.5:80/stream/1040"  ; } if (url == 4) { llSetText("Stream 4", <1,1,1>, 1.5); llSetParcelMusicURL("http://64.202.98.31:2820"  ; } if (url == 5) { url = 0; } } } *********************** Here's my problem: Anyone can click on this script and change the URL. What I'd like to do is have a set of names in the script that have "permission" to click it and change the stream. Anyone who's on the "list" is allowed to click the object and set the URL. If someone not on the "list" clicks it, it does nothing. Any ideas on how I could insert this sort of checking into the script? Thanks in advance! Travis
|
Cristiano Midnight
Evil Snapshot Baron
Join date: 17 May 2003
Posts: 8,616
|
11-04-2004 21:39
In the touch event, add the following:
if(llDetectedKey(0)==llGetOwner()) {
Rest of the touch code here
}
_____________________
Cristiano ANOmations - huge selection of high quality, low priced animations all $100L or less. ~SLUniverse.com~ SL's oldest and largest community site, featuring Snapzilla image sharing, forums, and much more. 
|
Moleculor Satyr
Fireflies!
Join date: 5 Jan 2004
Posts: 2,650
|
11-04-2004 21:43
Enclose all of those if statements in one giant if statement that uses llListFindList to search a list of names you declare as a variable.
If llListFindList != -1, then they're on the list, and the change should be made.
_____________________
</sarcasm>
|
Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
|
11-05-2004 07:59
ok, here's untested code... written based on the temporary Wiki found here but most of the code was what you originally put there... So maybe with a tiny bit of testing... integer url = 0; list auth = ["My name", "Buddys Name", "Additional Name"]; //make sure you use the proper case
default { state_entry() { } touch_start(integer total_number) { list avatar = (list)llDetectedName(0); integer nameFound = llListFindList(auth, avatar); if (nameFound) { url += 1; if (url == 1) { llSetText("Stream 1", <1,1,1>, 1.5); llSetParcelMusicURL("http://192.182.76.21:8000"); } if (url == 2) { llSetText("Stream 2", <1,1,1>, 1.5); llSetParcelMusicURL("http://mystic1.streamguys.net:7150"); } if (url == 3) { llSetText("Stream 3", <1,1,1>, 1.5); llSetParcelMusicURL("http://64.236.34.5:80/stream/1040"); } if (url == 4) { llSetText("Stream 4", <1,1,1>, 1.5); llSetParcelMusicURL("http://64.202.98.31:2820"); } if (url == 5) { url = 0; } } else { llWhisper(0, "You are not on the authorized list"); } } }
I hope that helps.
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts
|
Evil Fool
"==" != "="
Join date: 30 Jul 2004
Posts: 110
|
11-05-2004 12:27
I modified it a bit more, allows for faster running (else ifs) + updating of stuff(colors, etc), and also makes a bit more sense. Of course, the url's could be added to a list and all, but i'm too lazy to do that. integer url = 0; list auth = ["My name", "Buddys Name", "Additional Name"]; //use ALL lowercase...
update(string text, string surl) { llSetText(text, <1,1,1>, 1.0); llSetParcelMusicURL(surl); }
default { touch_start(integer total_number) { integer nameFound = llListFindList(auth, [llToLower(llDetectedName(0))]); if (nameFound != -1) { url += 1; if (url == 1) { update("Stream 1", "http://192.182.76.21:8000"); }else if (url == 2) { update("Stream 2", "http://mystic1.streamguys.net:7150"); }else if (url == 3) { update("Stream 3", "http://64.236.34.5:80/stream/1040"); }else if (url == 4) { update("Stream 4", "http://64.202.98.31:2820"); }else{ url = 0; } }else { llWhisper(0, "You are not on the authorized list"); } } }
From: Samhain Broom ok, here's untested code... written based on the temporary Wiki found here but most of the code was what you originally put there... So maybe with a tiny bit of testing... ... I hope that helps.
|
Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
|
11-05-2004 12:32
hehe I was also going to suggest that the URLS be placed on a notecard for easier manipulation by the non-LSL'er.
I would have added that but did not want to try it without being fairly sure it worked and having an LSL compiler to test it. =)
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts
|
Water Rogers
Registered User
Join date: 1 May 2003
Posts: 286
|
11-05-2004 15:32
No scripting neccessary with this script. You need to notecards... one named "Users", and another named "Music URLs" In the notecards, just seperate the names and URLs with commas (,) An example of the 2 notecards under the script. Hope it helps! //* This script gets the URLs in a notecard and places them into a list //* It also gathers a list of users from a seperate notecard that are allowed to change the music //* It will check to make sure the notecards exist, and let you know if they don't //* It will also cycle through the URL's given, and also add the option of No URL (no music) //* No scripting required... when you save the notecard, the lists automatically update themselves //* Created By Water Rogers
integer gUrlIndex; list gUserList; list gUrlList; key gNotecard1; key gNotecard2;
getLists(){ integer err; string errMessage; if ( llGetInventoryName( INVENTORY_NOTECARD, 0 ) == "Music URLs" ){ gNotecard1 = llGetNotecardLine("Music URLs", 0); } else{ errMessage = "[\"Music URLs\"]"; err = -1; } if ( llGetInventoryName( INVENTORY_NOTECARD, 1 ) == "Users" ){ gNotecard2 = llGetNotecardLine("Users", 0); } else{ errMessage += " [\"Users\"]"; err = -1; } if( err != -1 ){ llSetText( "No Stream", <0,1,1>, 1); llSetParcelMusicURL( "" ); } else{ llInstantMessage( llGetOwner(), "You are missing a notecard. " + errMessage ); } }
default{ state_entry(){ getLists(); } on_rez( integer t ){ getLists(); } dataserver(key q, string id){ if( q == gNotecard1 ){ gUrlList = llCSV2List(id); } if( q == gNotecard2 ){ gUserList = llCSV2List(id); } }
touch_start( integer t ){ integer check = llListFindList( gUserList, [llDetectedName(0)] ); if( check != -1 || llDetectedKey(0) == llGetOwner()){ if( gUrlIndex == llGetListLength( gUrlList ) ){ llSetText( "No Stream", <0,1,1>, 1); llSetParcelMusicURL( "" ); gUrlIndex = 0; return; } integer index = gUrlIndex + 1; llSetText( "Stream " + (string)index + "\n" + llList2String( gUrlList, gUrlIndex ), <1,0,1>, 1); llSetParcelMusicURL( llList2String( gUrlList, gUrlIndex ) ); gUrlIndex++; } else{ llInstantMessage( llDetectedKey( 0 ), "Sorry, you cannot change the station." ); } } changed( integer c ){ if( c == CHANGED_INVENTORY ){ getLists(); } } } This is a notecard named "Users" Torrid Midnight, Mistress Midnight, Gwinivere Grayson And this is the other notecard named "Music URLs" http://192.182.76.21:8000, http://mystic1.streamguys.net:7150, http://64.236.34.5:80/stream/1040, http://64.202.98.31:2820 Also note that if you are the owner of the object, you do not need to put yourself in the access list. This is tested and works well. --Water
_____________________
From: Philip Linden For the more technically minded - the problem is actually NOT the asset server (or 'asshat' as you prefer to affectionately call it herein).
|
Lars Bismark
Registered User
Join date: 6 Jun 2004
Posts: 6
|
Thanks!
11-05-2004 23:52
Thanks, guys - not only did you answer my question, but you took it to the next level  Travis
|
Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
|
11-08-2004 08:10
Yes, thanks Water, I'll probably use that script myself!
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts
|