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();
    }
}