Don't click here unless you want to be banned.

LSL Wiki : ExampleProximityDoor

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawl338.us.archive.org
This is a script I use to control access to an area.
I'm sure there are a hundred better scripts out there like this one.
Feel free to use it, and please let me know how I can make it better...

- Jordan Cotton

// This script was authored by (in game) Jordan Cotton.
// and has been placed in the public domain.
// Feel free to use and abuse it as you feel fit.
// When not in game, the author can be contacted through the private message 
// feature of the on the secondlife forums:     
//               http://forums.secondlife.com/private.php?s=&action=newmessage
//
// Enjoy!


// -----------------------------------
// CONSTANT DEFINITIONS
// -----------------------------------

list     DEFAULT_USERS = [ "Jordan Cotton"];  // Put you name here so you don't get locked out...


// -----------------------------------
// GLOBAL VARIABLES
// -----------------------------------

integer  g_listen_control;
integer  g_isScanning     = FALSE;
integer  g_isOpen         = FALSE;
integer  g_debug          = FALSE;
list     g_protectionList = DEFAULT_USERS; 
integer  g_OLD_STATE;

dumpList( )
{
    integer i;
    string entry;
    
    for( i = 0; i< llGetListLength( g_protectionList ); i++ )
    {
        entry = llList2String( g_protectionList, i);
        llSay( 0, (string) i + ") " + entry);
    }        
}

integer isInList( string who )
{
    integer i;
    string entry;
    
    for( i = 0; i< llGetListLength( g_protectionList ); i++ )
    {
        entry = llList2String( g_protectionList, i);
        if ( llSubStringIndex(entry, who ) != -1) return TRUE;
    }    
    
    return FALSE;
}


addToList( string who )
{    
    if ( ! isInList( who ) )
    {
        g_protectionList = who + g_protectionList;           
    }
}

removeFromList( string who)
{
    integer i;
    string entry;
    
    for( i = 0; i< llGetListLength( g_protectionList ); i++ )
    {
        entry = llList2String( g_protectionList, i);
        //llSay( 0, (string) i + ") " + entry);
        //llSay( 0, "Does [" + entry + "] = [" + who + "]" );
        if ( llSubStringIndex(entry, who ) != -1){
            llSay( 0, "deleting ->" +  entry); 
             g_protectionList = llDeleteSubList( g_protectionList, i, i);
        }
    }       
}

default
{
    on_rez(integer param)
    {
        llResetScript();
    }
    
    state_entry()
    {      
        if( g_debug) llSay(0, "Scanner Online.");        
        
        g_listen_control = llListen(0, "", NULL_KEY, "");
    }

    
    state_exit()
    {
        llListenRemove(g_listen_control);     
        llSetTimerEvent(0.0);   
    }
    
    listen(integer number, string name, key id, string message)
    {   
        string who;
        
        if ( isInList( name ) ||
             ( llSubStringIndex( llKey2Name( llGetOwner()) , name ) != -1 ) )
        {
            if( message=="door:help" ) {
                llWhisper( 0, "Door Commands ");
                llWhisper( 0, "door:open Toggles the door's open status.");
                llWhisper( 0, "door:scan start/stop looking for people who I will open for.");
                llWhisper( 0, "door:whoisonlist Dislay who is on the access list.");
                llWhisper( 0, "door:reset reset the access control list");
                llWhisper( 0, "door:remove remove someone from the list.");
                llWhisper( 0, "door:add add someone to the list.");
            
            } else if( message=="door:open" ) {
                g_isOpen = !g_isOpen;
                llSetStatus( STATUS_PHANTOM, g_isOpen );
                if ( g_isOpen ) {
                    llSetAlpha( 0.3, ALL_SIDES );
                } else {
                    llSetAlpha(1.0, ALL_SIDES );
                }
            } else if( message=="door:scan" ) {
                g_isScanning = !g_isScanning;
                if ( g_isScanning ){
                    llWhisper( 0, "door is scanning.");
                    llSensorRepeat("", "", AGENT, 5, 2*PI, .1);
                } else {
                    llWhisper( 0, "door stopped scanning.");
                    llSensorRemove();    
                }           
            }else if( llSubStringIndex(message, "door:whoisonlist") != -1 ) {
                dumpList();
            }else if( llSubStringIndex(message, "door:reset") != -1 ) {
                g_protectionList = DEFAULT_USERS;
            }else if( llSubStringIndex(message, "door:remove") != -1 ) {
                who = llGetSubString( message, 12, llStringLength(message));
                llSay( 0, "removing: " + who );
                removeFromList( who );
            }else if( llSubStringIndex(message, "door:add") != -1 ) {
                who = llGetSubString( message, 9, llStringLength(message));
                llSay( 0, "adding: " + who );    
                addToList( who );            
            }
        }
    }
    
    sensor(integer detected)
    {
        integer i;
        for(i=0; i<detected; i++)
        {           
            if  (  isInList( llDetectedName(i) ) ) 
            {          
                if (g_debug) llWhisper( 0 , "opening");      
                llSetStatus( STATUS_PHANTOM, TRUE );   
                llSetAlpha( 0.3, ALL_SIDES );
                llSetTimerEvent(2.0);
            }
        }
    }
    
    timer()
    {
        if (g_debug) llWhisper( 0 , "closing");
        llSetStatus( STATUS_PHANTOM, FALSE );            
        llSetAlpha(1.0, ALL_SIDES );
    } 
}


Examples Jasa SEO Jasa SEO Murah Sepatu Online Toko Sepatu Online Sepatu Sepatu Murah Sepatu Safety Sepatu Futsal Cheapes Hostgator Coupon Link Booking Televisori offerte Notebook Offerte Berita Terkini Internet Marketer Muda Internet Marketer Indonesia Portatile Apple RDAnet Lorks Karikatur Bisnis Modal Kecil Bisnis UKM Berita Terbaru Iklan Baris Jasa SEO Jasa SEO Murah SEO Indonesia Konsultan SEO SEO Belajar SEO Kursus SEO Kursus SEO Murah Jam Tangan Casio Jam Tangan Casio Jam Tangan Murah Jam Tangan Grosir Baju Terbaru Grosir Baju Baju Terbaru Grosir Baju Murah Bisnis Online Belajar SEO Kerupuk Kerupuk kulit Social Bookmark Dofollow Social Bookmark Kumpulan Puisi Kirim Puisi bola hantu Penumbuh Rambut Penumbuh Rambut timbangan WBC Wonogiri Jasa SEO Murah Jasa SEO Jam Tangan Murah
There is no comment on this page. [Display comments/form]