Recent Avatar Scanner

From Second Life Wiki
Revision as of 19:22, 5 January 2016 by Ackley Bing (talk | contribs) (changed isnt necessary. Use it if you want to.)
Jump to navigation Jump to search

Recent Avatar Scanner by Ackley Bing. Put this script in a prim. Wear the object as a HUD. It notifies you as it collects avatar names. Touch it to see a list of recently collected names. Stored up to 100 names. Adjust 100 to 1000 or whatever you want, just beware of script memory use or you will get a Stack Heap Collision. Modify it to suit your particular use in another Hud, weapon, or whatever you want. <3 --Ackley Bing

list RecentAgents;
integer MaxRecent=100;
Process_Region_Agents()
{
    list RegionAgents=llGetAgentList(AGENT_LIST_REGION,[]);
    integer TotalAgentsInRegion=llGetListLength(RegionAgents);
    integer i;
    for(i=0;i<TotalAgentsInRegion;i++)
    {
        integer Test;
        key Agent = llList2Key(RegionAgents, i);
        Test=llListFindList(RecentAgents,[Agent]);
        if (Test == -1 && Agent!=llGetOwner() )
        {
            llOwnerSay("NEW AVATAR: secondlife:///app/agent/" + (string)Agent + "/inspect added to your list");
            RecentAgents += (key)Agent;
            if (llGetListLength(RecentAgents)>MaxRecent) llDeleteSubList(RecentAgents, 0, 0);
        }
    }
}
default
{
    state_entry()
    {
        llRequestPermissions(llGetOwner(),PERMISSION_TAKE_CONTROLS);
        llSetTimerEvent(5.0);
    }
    timer()
    {
        Process_Region_Agents();
    }
    touch_start(integer index)
    {
        integer TotalRecentAgents=llGetListLength(RecentAgents);
        if (TotalRecentAgents)
        {
            llOwnerSay ((string)TotalRecentAgents+" recent avatars:");
            integer i=0;
            for (i;i<TotalRecentAgents;i++)
            {
                key recentagentskey=llList2Key(RecentAgents,i);
                llOwnerSay ((string)(i+1)+". secondlife:///app/agent/" + (string)recentagentskey + "/inspect ");
            }
        }
        else llOwnerSay("No Recent Avatars");
    }
    //changed(integer change)
    //{
    //    if ( change & CHANGED_REGION ) Process_Region_Agents();
    //}
    run_time_permissions(integer perms)
    {
        if ( perms & PERMISSION_TAKE_CONTROLS ) llTakeControls(CONTROL_BACK, FALSE, TRUE);
    }
}