Ultimate Radar

From Second Life Wiki
Jump to navigation Jump to search

Teleporter_Anywhere | Ultimate_Radar | Language_Scanner | Visitor_Counter_Tracker

Zx Ultimate Radar

An advanced radar to detect users and their language on an entire region without any lag. You can test it in Full Sim: it's not a problem for it.

  • Copyright (C) 2017 Luxen - Luxen_Resident - version 5.0
  • Optimized: tested with more 90 users, low memory, safe and secure

History

  • I created the first version 4 years ago and I sold different versions on MarketPlace.
  • Optimized and tested for 4 years.

Code:

//////////////////////////////////////////////////////////////////////////////
//                      Zx Ultimate Radar Hud   v5                          //
//                                                                          //
//    Copyright (C) 2017 Luxen - Zonyx Technology                           //
//    This program is free software: you can redistribute it and/or modify  //
//    it under the terms of the GNU General Public License version 3, as    //
//    published by the Free Software Foundation.                            //
//                                                                          //
//    This program 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 General Public License for more details.                          //
//                                                                          //
//   You should have received a copy of the GNU General Public License      //
//    along with this program.  If not, see <http://www.gnu.org/licenses/>  //
//////////////////////////////////////////////////////////////////////////////

integer counter = 0;
key owner = NULL_KEY;
integer RStat = TRUE;

set_time(float Stime, string Stext, integer Scounter)
{
        llSetText(Stext, <0.667, 0.667, 0.667>, 1.0);
        if (Stime != 5.0) llSetTimerEvent(Stime);
        counter = Scounter;
}

default
{
    state_entry()
    {
        if(owner)  ;
        else
        {
            llSetMemoryLimit(40000);
            owner = llGetOwner();
            set_time(10.0, "[- Starting -]", 0);
        }
    }
    
    on_rez(integer start_param)
    {
        llResetScript();
    }

    changed(integer change)
    {
        if(change & (CHANGED_REGION)) state teleport;
    }
    
    touch_start(integer total_number)
    {   
        if (llGetAttached())
        {  
            if (counter) 
            {  
                set_time(0.0, "[- Off -]", 0);
                RStat = FALSE;
            }
            else if (!RStat)
            {  
                set_time(10.0, "[- Starting -]", 0);
                RStat = TRUE;
            }
        }
    }
    
    timer()
    {
        list AvatarsDetect = llGetAgentList(AGENT_LIST_REGION, []);
        integer numOfAvatars = llGetListLength(AvatarsDetect);
        if (!llGetAttached())
        {
            if (llGetObjectPrimCount(llGetKey()))
            {
                set_time(0.0, "[- Off -]", 0);
                RStat = FALSE;
            }
        }
        else if (numOfAvatars < 2)
        {
            if (counter != 2) set_time(5.0, "[- Nobody -]", 2);
        }
        else if (numOfAvatars > 100) return;
        else 
        {
            integer index;
            list NewTab = [];
            vector currentPos = llGetPos();
            integer Zfix = numOfAvatars;
            for (index = 0; index < Zfix; ++index)
            {
                key AvKey = llList2Key(AvatarsDetect, index);
                list AvPos = llGetObjectDetails(AvKey, [OBJECT_POS]);
                if (AvPos) NewTab += [llVecDist(currentPos, llList2Vector(AvPos, 0)), AvKey];
                else --numOfAvatars;
            }
            
            if (numOfAvatars > 1) 
            {
                AvatarsDetect = [];
                NewTab = llListSort(NewTab, 2, TRUE);
                string mode = "[- Sim: " + (string)(numOfAvatars -1) + " -]";
                numOfAvatars *= 2;
                for(index = 0; index < numOfAvatars; index += 2)
                {
                    key id = llList2Key(NewTab, index + 1);
                    if (Zfix)
                    {
                        if (id == owner)
                        {
                            Zfix = FALSE;
                            jump Ignore;
                        }
                    }
                    string DName = llGetUsername(id);
                    string DLang = "?";
                    if (DName) 
                    {
                        DLang = llGetAgentLanguage(id);
                        integer Dlenght = llStringLength(DLang);
                        if (Dlenght == 2)  ;
                        else if (Dlenght == 5)
                        {
                            if (DLang == "en-us") DLang = "en";
                            else DLang = "xx";
                        }
                        else DLang = "xx";
                    }
                    else DName = "???";
                    DName += " (" + DLang + "-" + (string)llList2Integer(NewTab, index) + "m)";
                    if (index > 18)
                    {
                        DName = mode + "\n" + DName;
                        if (llStringLength(DName) > 254) jump affich;
                        else mode = DName;
                    }
                    else mode += "\n" + DName;
                    @Ignore;
                    
                }
                @affich;
                NewTab = [];
                set_time(5.0, mode, 1);
            }
        }
    }
}

state teleport
{
    state_entry()
    {
        if (counter) set_time(10.0, "[- Searching -]", 0);
        state default;
    }
    
    on_rez(integer start_param)
    {
        llResetScript();
    }

    timer()
    {
        return;
    }
}