|
Thorne Kaiser
Nice Guy
Join date: 29 Nov 2005
Posts: 132
|
03-14-2006 16:43
I am trying to find a way to bypass a function if my user list notecard is empty or says 'ANYONE'. Your help is appreciated  touch_start(integer total_number) {
//Somehow before it checks to see if you are on the list, //it should check if the list is empty or says 'ANYONE' //If it is NOT empty or does not say ANYONE, then do this stuff:
string userName = llDetectedName(0); if (llListFindList(users, [llToLower(userName)]) != -1) { llWhisper(0,"You are on the cool people list!"); } else { llWhisper(0, "You are not on the cool people list. Sorry."); } //Else, if it is empty or says 'ANYONE' //then do this instead and skip even checking your name:
llWhisper(0, "OK, anyone can use me."); }
|
|
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
|
03-14-2006 16:57
If you want to skip some code, you need to check for that first. You can't skip doing something after you've already done it  So you have the right idea, you need to add the check in the beginning of the function. I'm assuming that if the notecard says ANYONE, then that will be the only line in the notecard, so the 'users' list will have only one entry, which says ANYONE. This code isn't the most efficient (and it hasn't been compiled/tested), but hopefully it'll give you an idea of how to proceed. touch_start(integer total_number) { integer allow = FALSE; // Start out assuming that permission won't be granted - guilty until proven innocent
if (llGetListLength(users) == 0) { // List is empty, so everyone is allowed access allow = TRUE; } else if (llList2String(users, 0) == "ANYONE") { // First entry in list says 'ANYONE', so everyone is allowed access allow = TRUE; } else { // We have to see if this person is on the allowed list
string userName = llDetectedName(0); if (llListFindList(users, [llToLower(userName)]) != -1) { // He's in the list allow = TRUE; } }
// Now do what you need to do if (allow == TRUE) { llWhisper(0,"You are on the cool people list, or I am set up for free access!"); // Access granted - do whatever needs to be done here } else { llWhisper(0, "You are not on the cool people list. Sorry."); // Access denied - do whatever needs to be done here } }
If you need to distinguish between allowing someone because it's set up for free access vs. allowing him because he's on the list, add another integer that's called foundInList or something, and set it to TRUE only in the final "else" check, when you actually find him in the list. That way you'll know the conditions under which the person was granted access.
|
|
Thorne Kaiser
Nice Guy
Join date: 29 Nov 2005
Posts: 132
|
03-14-2006 19:42
TYVM! Works great 
|