User:Daemonika Nightfire/Scripts/Bot Ejecter

From Second Life Wiki
Jump to navigation Jump to search

*DS* Bot Ejecter v1.0.01

This little script sends every agent with the scritped agent status (usually called bot) home within a second without warning.

/*
    *DS* Bot Ejecter v1.0.00 by Daemonika nightfire
    
    The motivation behind this script is to make it as difficult as possible for data collectors to use bots.
    Bots are teleported home by this script within a second without warning.
    The height at which a bot is located is irrelevant.
    The bot is also ejected at the highest point at 2147483647 metres.
    
    It is expressly permitted and even desired to pass on this script free & fullperm.
    
    Please see https://wiki.secondlife.com/wiki/LlTeleportAgentHome#Ownership_Limitations for details.
*/

integer counter = 0;
Refresh()
{
    string msg = "Ejected Bots: " + (string)counter;
    llSetText(msg, <1,1,1>, 1.0);
    llSetObjectDesc(msg);
}

default
{
    state_entry()
    {
        counter = (integer)llLinksetDataRead("ejects");
        Refresh();
        
        llSetTimerEvent(1.0); // don't set faster than once per second
    }

    timer()
    {
        list agents = llGetAgentList(AGENT_LIST_PARCEL, []); // use AGENT_LIST_REGION if you own the whole region
        integer length = llGetListLength(agents);
        integer i = 0;
        do
        {
            key agent = llList2Key(agents, i);
            integer info = llGetAgentInfo(agent);
            if(info & AGENT_AUTOMATED)
            {
                if(!llSameGroup(agent)) // your own bots are save with the same group
                {
                    llTeleportAgentHome(agent);
                    
                    counter++;
                    llLinksetDataWrite("ejects", (string)counter);
                    Refresh();
                }
            }
        }
        while(++i < length);
    }
    
    on_rez(integer Dae)
    {
        llLinksetDataDelete("ejects");
        llResetScript();
    }
}

*DS* Bot Ejecter v1.0.04

Extended Version with individual statistics.

Chat Output Example:
[09:19:30] *DS* Bot Ejecter v1.0.04 (free to copy) 1. Known bot: osiventhy (1)
[09:19:30] *DS* Bot Ejecter v1.0.04 (free to copy) 2. Known bot: iongensp (1)
[09:19:30] *DS* Bot Ejecter v1.0.04 (free to copy) 3. Known bot: Natalia Porchers (1)
[09:19:30] *DS* Bot Ejecter v1.0.04 (free to copy) 4. Known bot: ecublem (2)
[09:19:30] *DS* Bot Ejecter v1.0.04 (free to copy) 5. Known bot: plishloromb (2)
[09:19:30] *DS* Bot Ejecter v1.0.04 (free to copy) 6. Known bot: oventero (2)
[09:19:30] *DS* Bot Ejecter v1.0.04 (free to copy) 7. Known bot: asiourawfl (2)
[09:19:30] *DS* Bot Ejecter v1.0.04 (free to copy) 8. Known bot: ltiventab (1)
[09:19:30] *DS* Bot Ejecter v1.0.04 (free to copy) 9. Known bot: froaphorc (1)
[09:19:30] *DS* Bot Ejecter v1.0.04 (free to copy) 10. Known bot: erypnoid (1)
[09:19:30] *DS* Bot Ejecter v1.0.04 (free to copy) 11. Known bot: ntudece (1)
[09:19:30] *DS* Bot Ejecter v1.0.04 (free to copy) 12. Known bot: blesequativ (3)
[09:19:30] *DS* Bot Ejecter v1.0.04 (free to copy) 13. Known bot: ychorap (1)
[09:19:30] *DS* Bot Ejecter v1.0.04 (free to copy) 14. Known bot: boatonic (2)
[09:19:30] *DS* Bot Ejecter v1.0.04 (free to copy) 15. Known bot: gadroupb (1)
[09:19:30] *DS* Bot Ejecter v1.0.04 (free to copy) 16. Known bot: pictichea (1)
[09:19:30] *DS* Bot Ejecter v1.0.04 (free to copy) 17. Known bot: DVBT (1)
[09:19:30] *DS* Bot Ejecter v1.0.04 (free to copy) 18. Known bot: Selena Zalivstok (1)
[09:19:31] *DS* Bot Ejecter v1.0.04 (free to copy) 19. Known bot: cononym (1)
/*
    *DS* Bot Ejecter v1.0.04 by Daemonika nightfire
    
    The motivation behind this script is to make it as difficult as possible for data collectors to use bots.
    Bots are teleported home by this script within a second without warning.
    The height at which a bot is located is irrelevant.
    The bot is also ejected at the highest point at 2147483647 metres.
    
    It is expressly permitted and even desired to pass on this script free & fullperm.
    
    Please see https://wiki.secondlife.com/wiki/LlTeleportAgentHome#Ownership_Limitations for details.
*/

list known_bots = [];
integer num = 0;

integer total = 0;
Refresh()
{
    string msg = "Ejected bots: " + (string)total;
    llSetText(msg, <1,1,1>, 1.0);
    llSetObjectDesc(msg);
}

default
{
    state_entry()
    {
        Refresh();
        llSetTimerEvent(1.0); // don't set faster than once per second
    }

    timer()
    {
        llSetTimerEvent(0.0); // stops the timer temporarily to process the list
        
        list agents = llGetAgentList(AGENT_LIST_PARCEL, []); // use AGENT_LIST_REGION if you own the whole region
        integer length = llGetListLength(agents);
        integer i = 0;
        do
        {
            key agent = llList2Key(agents, i);
            integer info = llGetAgentInfo(agent);
            if(info & AGENT_AUTOMATED)
            {
                if(!llSameGroup(agent)) // your own bots are save with the same group
                {
                    if(!~llListFindList(known_bots, [agent]))
                    {
                        known_bots += agent;
                        known_bots += 1;
                        
                        if(llGetFreeMemory() < 10000)
                        {
                            llDeleteSubList(known_bots, 0, 1);
                        }
                        num = llGetListLength(known_bots);
                    }
                    else
                    {
                        integer index = llListFindList(known_bots, [agent]);
                        integer count = llList2Integer(known_bots, index+1);
                        
                        count++;
                        known_bots = llListReplaceList(known_bots, [count], index+1, index+1);
                    }
                    
                    llTeleportAgentHome(agent);
                    total++;
                    Refresh();
                }
            }
        }
        while(++i < length);
        
        llSetTimerEvent(1.0); // restart the timer
    }
    
    touch_start(integer number)
    {
        key user = llDetectedKey(0);
        key current_uuid;
        integer current_number;
        integer counter = 0;
        integer i = 0;
        do
        {
            if(num > 0)
            {
                if(!(i&1))
                {
                    current_uuid = llList2Key(known_bots, i);
                }
                else if(i&1)
                {
                    current_number = llList2Integer(known_bots, i);
                    
                    counter++;
                    llRegionSayTo(user, 0, "/me " + (string)counter + ". Known bot: secondlife:///app/agent/" + (string)current_uuid + "/about (" + (string)current_number + ")");
                }
            }
            else
            {
                llRegionSayTo(user, 0, "Currently no bot stored.");
            }
        }
        while(++i < num);
    }
    
    on_rez(integer Dae)
    {
        llResetScript();
    }
}