Group Add Request

Written by Kitsune

This script can do two things: It will make a list of all that Touch it, except the owner, and it can Instant Message owner the name of each person Touching as it happens... 


What it cannot do is add people to a group. Unfortunately, that is not yet available in LSL as of now (JAN 2007.)

A good way to use this script is to place it inside of a sign like I have at my store. Check it once or twice a day, reseting the list after getting the current names and adding them manually to group.

IMPORTANT: You must Reset the List before it gets to around 125 or the script will stop working.

 

 

integer sendIM = TRUE; //sends IM to Owner


list names;
integer total;

integer menu_handler;
integer menu_channel;
menu(key user,string title,list buttons)
{
    menu_channel = (integer)(llFrand(99999.0) * -1);
    menu_handler = llListen(menu_channel,"","","");
    llDialog(user,title,buttons,menu_channel);
    llSetTimerEvent(15.0);
}

default
{
    on_rez(integer r)
    {
        llResetScript();
    }
    
    state_entry()
    {
        names = [""];
        total = 0;
        llSetText("Touch to join our Group", <0.90196, 0.72549, 0.35294>, 1.0); //Floating Text, edit or remove
        llOwnerSay("Ready... list is reset to 0.");
    }

    touch_start(integer num_detected)
    {
        integer x;
        for(x;x <= num_detected- 1;x++)
        {
            if ( llDetectedKey(x) != llGetOwner() )
        {
                integer find = llListFindList(names,[llDetectedName(x)]);
                if(find < 1)
                {
                    llInstantMessage(llDetectedKey(x), "Your request has been sent. Please be patient and you will be added to the group as soon as possible."); //Message to Toucher
                    names = names+ [llDetectedName(x)];
                    total = total + 1;
                    if (sendIM)
                    {
                        llInstantMessage(llGetOwner(), " " + llDetectedName(x) + " has requested to be added."); //Message to Owner
                    }
                }
                else
                {
                    llInstantMessage(llDetectedKey(x), "You've already requested to be added."); //Message to repeat Toucher
                }
            }
            else if ( llDetectedKey(x) == llGetOwner() )
            {
                llOwnerSay((string)total + " people have Touched me so far!");
                menu(llGetOwner(),"Please Select One",["Show List","Reset", "Turn Off"]);
            }
        }  
    }
    
    timer() 
    {
        llSetTimerEvent(0.0);
        llListenRemove(menu_handler);
    }

    listen(integer channel,string name,key id,string message)
    {
        if (channel == menu_channel) 
        {
            if(message == "Show List")
            {
                integer len = llGetListLength( names );
                integer i;
                for( i = 0; i < len; i++ )
                {
                    integer a = i;
                    llOwnerSay((string)a + " : " + llList2String(names, i));
                }
            }
            else if(message == "Reset")
            {
                llOwnerSay("Clearing List & Reseting Script now.");
                llResetScript();
            }
            else if(message == "Turn Off")
            {
                llOwnerSay("Turning Off Now. Touch again to turn back On.");
                state off;
            }
        }
    }
}

state off
{
    on_rez(integer r)
    {
        llResetScript();
    }
    
    state_entry()
    {
        llSetText("", <0, 0, 0>, 1.0);
    }
    
    touch_start(integer total_number)
    {
        if (llGetOwner())
        {
            llOwnerSay("Turning back On now.");
            llResetScript();
        }
    }
}