Anti Spam Greeter ( V1 )

Written by Kitsune

As the name suggests...This is a low spam greeter for use in medium to kinda high traffic areas. To use it place a plain prim in the entrance way of the area being visited. Drop this script onto it. The prim will turn transparent and a type of phantom called "VolumeDetect" which means avatars will pass through it. As they pass through it (even if just a foot dips into it) the script will issue various messages depending on the settings. It can also be used to give a folder of stuff (if wanted) to the visitor. Just add the stuff (LM's, NC's, Freebies etc.) to the prim contents. You can change the contents at any time without needing to do anything to the script (unless you want the messages to change too).

 

 

// V1 //
 
// Edit the strings below to set up the messaging.
 
string personalize = "Welcome to to my shop"; // If empty ( "" ) no personalisation will be used.
// If not empty the personalization will prepend the first name of the visitor and the whole will prepend...
// ..."IM" and/or "DM" if used. E.g. "Welcome to to my shop Fred." would be chatted to me prepending the IM.
// If used, this messages byte count will be added to those of "IM" and "DM".
 
string IM = "This text will be instant messaged to the visitor.";
// If empty ( "" ) no IM will be sent.
// This MUST be limited to less than 1024 bytes ( around 300 characters ).
// If used, this messages byte count will be added to those of "personalize".
 
string DM = "This text will appear on the dialog ( blue dropdown with buttons ).";
// If empty ( "" ) no Dialog will be sent ( unless there are gifts ).
// This MUST be limited to less than 512 bytes ( around 150 characters ).
// If used, this messages byte count will be added to those of "personalize".
 
string GM = "\nSince you're here I wonder if you would like a gift?"; // If there are gifts in the contents...
// ...this will append "DM" ( it can be empty ( "" )). If used this will add to the byte count of "DM".
 
string folder_name = "Folder of Joy!"; // This will be the name of the folder if a gift pack is given.
 
string notification = "has entered your shop.";
// This message with the full name of the visitor prepended will be IMed to you if it is not empty ( "" ).
 
//////////////////////////////////////////////////////////////////////////////////////////////
//////YOU KNOW THE DRILL...DON'T EDIT ANYTHING BELOW UNLESS YOU KNOW WHAT YOU'RE DOING.///////
//////////////////////////////////////////////////////////////////////////////////////////////
 
key owner;
 
list visitors;
 
list DB = ["OK"];
 
list lises;
 
list inventory;
 
integer gifts;
 
integer lis;
 
integer DC;
 
RemoveListens(key k)
{
    if(k != NULL_KEY)
    {
        integer index = llListFindList(lises, [k]);
        if(index != -1)
        {
            llListenRemove(llList2Integer(lises, (index + 1)));
            lises = llDeleteSubList(lises, index, (index + 1));
        }
    }
    else
    {
        llListenRemove(llList2Integer(lises, 1));
        lises = llDeleteSubList(lises, 0, 1);
    }
    if(!llGetListLength(lises))
    {
        llSetTimerEvent(0.0);
        DC = (llRound(llFrand(-91746382)) - 10000);
    }
}
 
default
{
    state_entry()
    {
        owner = llGetOwner();
        llVolumeDetect(TRUE);
        llSetAlpha(0.0, -1);
        DC = (llRound(llFrand(-91746382)) - 10000);
        integer NOI = llGetInventoryNumber(INVENTORY_ALL);
        if(NOI > 1)
        {
            gifts = TRUE;
            DB = ["Gift Pack", "No Thanks"];
            DM += ("\n" + GM);
            string me = llGetScriptName();
            integer count;
            string name;
            do
            {
                name = llGetInventoryName(INVENTORY_ALL, count);
                if(name != me)
                inventory += [name];
            }
            while((++count) < NOI);
        }
    }
    changed(integer change)
    {
        if(change & (CHANGED_INVENTORY | CHANGED_OWNER))
        llResetScript();
    }
    collision_start(integer nd)
    {
        if(llGetListLength(lises) <= 120)
        {
            integer count;
            do
            {
                key id = llDetectedKey(count);
                string name = llDetectedName(count);
                if(llListFindList(visitors, [id]) == -1)
                {
                    string PM = "";
                    if(personalize != "")
                    PM = ("\n" + personalize + " " + llGetSubString(name, 0, (llSubStringIndex(name, " ") - 1)) + ".\n");
                    if(llGetListLength(visitors) > 200)
                    visitors = llDeleteSubList(visitors, 0, 50);
                    visitors += [id];
                    if(DM != "")
                    {
                        if(gifts)
                        {
                            llSetTimerEvent(60.0);
                            lis = llListen((++DC), name, id, "");
                            lises += [id, lis];
                        }
                        llDialog(id, (PM + DM), DB, DC);
                    }
                    if(IM != "")
                    llInstantMessage(id, (PM + IM));
                    if(notification != "")
                    llInstantMessage(owner, (name + " " + notification));
                }
            }
            while((++count) < nd);
        }
    }
    listen(integer chan, string name, key id, string msg)
    {
        if(msg == "Gift Pack")
        llGiveInventoryList(id, folder_name, inventory);
        RemoveListens(id);
    }
    timer()
    {
        RemoveListens(NULL_KEY);
    }
}