Difference between revisions of "Under Age Boot"

From Second Life Wiki
Jump to navigation Jump to search
m (uups, forgot the header template)
 
(One intermediate revision by one other user not shown)
Line 14: Line 14:
# No special instructions. It operates stand alone once installed.
# No special instructions. It operates stand alone once installed.


<lsl>
<source lang="lsl2">
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//
//
Line 52: Line 52:


     result += llList2Integer(days, (llList2Integer(parse_date, 1) - 1));
     result += llList2Integer(days, (llList2Integer(parse_date, 1) - 1));
     if (year/4 == llRound(year/4)) result += 1;
      
    //Fixed the leap year calculation below  ~Casper Warden, 28/10/2015.
    //if (year/4 == llRound(year/4)) result += 1;
    result += llFloor((year-2000) / 4);
 
     result += llList2Integer(parse_date, 2);
     result += llList2Integer(parse_date, 2);


Line 156: Line 160:
     }
     }
}
}
</lsl>
</source>




{{LSLC|Library}}
{{LSLC|Library}}

Latest revision as of 09:18, 28 October 2015

Security device example to teleport home accounts below a minimum age limit; can be useful in combating free griefer accounts.

Place this script into a single prim and decorate to taste.

Requirements:

  1. Deed to match the land group
  2. Place the prim reasonably close to the parcel landing point
  3. Set the prim description field to be the minimum age accounts; must be in days

Operation:

  1. No special instructions. It operates stand alone once installed.
//////////////////////////////////////////////////////////////////////////////////////
//
//    Version 1.0 Release
//    Copyright (C) 2007, Chance Unknown
//
//    This library is free software; you can redistribute it and/or
//    modify it under the terms of the GNU Lesser General Public License
//    as published by the Free Software Foundation; either
//    version 2.1 of the License, or (at your option) any later version.
//
//    This library is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU Lesser General Public License for more details.
//
//    You should have received a copy of the GNU Lesser General Public License
//    along with this library; if not, write to the Free Software
//    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//
//////////////////////////////////////////////////////////////////////////////////////

// Set the age in the description field of the prim to reflect the SL account age
// of individuals to boot.

integer AGE_LIMIT;
list agent_list;

integer date2days(string data)
{
    integer result;
    list parse_date = llParseString2List(data, ["-"], []);
    integer year = llList2Integer(parse_date, 0);

    result = (year - 2000) * 365; // Bias Number to year 2000 (SL Avatars Born After Date)
    list days = [ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 ];

    result += llList2Integer(days, (llList2Integer(parse_date, 1) - 1));
    
    //Fixed the leap year calculation below  ~Casper Warden, 28/10/2015.
    //if (year/4 == llRound(year/4)) result += 1;
    result += llFloor((year-2000) / 4);

    result += llList2Integer(parse_date, 2);

    return result;
}

default
{
    on_rez(integer param)
    {
        llResetScript();
    }

    state_entry()
    {
        AGE_LIMIT = (integer)llGetObjectDesc();

        if (AGE_LIMIT < 2)
        {
            AGE_LIMIT = 2;
        }

        llSetObjectName("Unknown Underage Boot - " + llGetRegionName());
        llVolumeDetect(TRUE);
        if (llOverMyLand(llGetKey()) == FALSE)
        {
            llSay(0, "Requires proper group deeds to work on this land.");
        }
        llSensorRepeat("", "", AGENT, 100.0, PI, 1.0);
        llOwnerSay("Set Avatar age in the description, currently it is set for " +
            (string)AGE_LIMIT + " days.");
    }

    sensor(integer num_detected)
    {
        if (llOverMyLand(llGetKey()) == FALSE)
        {
            return;
        }

        integer i;

        for (i = 0; i < num_detected; i++)
        {
            key agent = llDetectedKey(i);
            if (llSameGroup(agent) == FALSE)
            {
                if (llListFindList(agent_list, [ agent ]) < 0)
                {
                    if (llGetListLength(agent_list) == 0)
                    {
                        agent_list += agent;
                        llRequestAgentData(llList2Key(agent_list, 0), DATA_BORN);
                    }
                    else
                    {
                        agent_list += agent;
                    }
                }
            }
        }
    }

    dataserver(key queryid, string data)
    {
        AGE_LIMIT = (integer)llGetObjectDesc();

        integer today = date2days(llGetDate());
        integer age = date2days(data);
        key agent = llList2Key(agent_list, 0);
        string name = llKey2Name(agent);

        if (AGE_LIMIT < 2)
        {
            AGE_LIMIT = 2;
            llSetObjectDesc((string)AGE_LIMIT + " : SET AGE LIMIT HERE");
        }

        if (name != "")
        {
            if ((today - age) < AGE_LIMIT)
            {
                if (llOverMyLand(agent))
                {
                    llSay(0, name + ", you are too young to be here.");
                    llTeleportAgentHome(agent);
                }
            }
            else
            {
            }
        }
        else
        {
            llTeleportAgentHome(agent);
        }

        agent_list = llDeleteSubList(agent_list, 0, 0);
        if (llGetListLength(agent_list) != 0)
        {
            llRequestAgentData(llList2Key(agent_list, 0), DATA_BORN);
        }
    }
}