Jump to content

Help with Texture swap Script w/Whitelist!!!


Rowan00
 Share

You are about to reply to a thread that has been inactive for 3980 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hi, I been working on trying to create a simple texture change script with a whitelist but for some reason no matter how hard I try I cannot get it to work just right. The whitelist isnt picking up or something. 

 

Here is what I have been working with:

 

// 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();
        }
    }
         touch_start(integer total_number)
    {
        integer number = llGetInventoryNumber(INVENTORY_TEXTURE);
        float rand = llFrand(number);
        integer choice = (integer)rand;
        string name = llGetInventoryName(INVENTORY_TEXTURE, choice);
        if (name != "")
            llSetTexture(name, ALL_SIDES);
    }
}  
 

 Thanks for any input and please be aware, Im extremely new to this and have been stumbling through it so ... yea

Link to comment
Share on other sites

I appriciate the reply. Sadly as I said before, Im completely clueless when it comes to scripting. Ive just been trying to piece two scripts together and I have NO clue what your speaking of to fix this script. As much as I hate to ask, is there anyway I can get a more detailed reply in correcting this script? I want to learn its just, I look at this thing and its like trying to read sanskrit sadly.

Link to comment
Share on other sites

There's nothing wrong with the top 3/4 of the script.  You just cut & pasted it from the library and seem to have done that correctly.  The gAccess variable is assigned a value when you respond to the dialog box prompt.  If you are having trouble getting a response, my best guess is that the notecard you are using for input was typed incorrectly.  That card should simply have one avatar name per line.  The name must be (1) spelled correctly and (2) the person's username (NOT a Display name).

Beyond that, your final state OK should work fine.  You haven't provided any way to get out of state OK, however, so once someone has managed to get access the script will stay in state OK forever.  The llSetTimerEvent function that you have in the state_entry event of that state would do the trick, if you had provided a timer event that redirects the script to state running.  If you decide to do that, I'd suggest setting the timer event to something longer than 10 seconds, and probably resetting it again in the touch_start event so that it doesn't dump the user out too quickly.

  • Like 1
Link to comment
Share on other sites

I understand what you said in my head. There needs to be a timed event in the script that allows for when someone on the whitelist clicks the block that it allows them access to the texture swap script, then it goes back to a secured mode. Correct?

 

What my problem is, I have NO clue how to do that. I know im asking for a handout here, but ive been beating my head on this single script for MONTHS and just at my limit LOL Is there anyway you can show me the script snipit that I need and where it belongs?

 

Thanks so much

Link to comment
Share on other sites

It should be quite easy.  As I said, all you need to do is add a timer event in your state OK so that the script pops back to state running when the timer is triggered. I'd suggest making the timer trigger after 30 seconds instead of 10, and I'd also suggest resetting the timer when you touch the object.  With those tiny changes, your state OK should look something like this ....

state OK{    state_entry()    {        llSetTimerEvent(30.0);   //Trigger after 30 seconds.        llSay(0,"You're in!");     }    changed(integer change)    {        if (change & CHANGED_INVENTORY)        {            llResetScript();        }    }         touch_start(integer total_number)    {        llSetTimerEvent(30.0);   //Reset timer to trigger after another 30 seconds.        integer number = llGetInventoryNumber(INVENTORY_TEXTURE);        float rand = llFrand(number);        integer choice = (integer)rand;        string name = llGetInventoryName(INVENTORY_TEXTURE, choice);        if (name != "")            llSetTexture(name, ALL_SIDES);    }    timer()    {        llSetTimerEvent(0.0);    //Turn the timer off        state running;    // Go to state running    }}

 

 

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3980 days.

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
 Share

×
×
  • Create New...