User:Zand Gundersen/Scripts

From Second Life Wiki
< User:Zand Gundersen
Revision as of 16:11, 7 April 2008 by Zand Gundersen (talk | contribs) (New page: ==Zand Gundersen's Mail Box Script== This is my mail box script i have been working on. I will try to keep it updated. ===Version 1.0 Code=== ===Version 1.1a Code=== <lsl> // Zand Gunde...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Zand Gundersen's Mail Box Script

This is my mail box script i have been working on. I will try to keep it updated.


Version 1.0 Code

Version 1.1a Code

<lsl> // Zand Gundersen's Mail Box Script

//This script turns an ordinary prim into a Mail Box. // string credits="

-=Credits=- Apr 7, 2008 - created by Zand Gundersen

This script is public domain and should be copyable! "; // THIS SCRIPT IS PUBLIC DOMAIN! Do not delete the credits at the top of this script! // Feel free to copy, modify, and use this script.

// Always give credit to Zand Gundersen and all people who modify it in a readme or in the object description.


//Config integer chan=11; //Dialog Chat Channel integer sendim=TRUE; //Im You if theres New Mail integer updatetime=5; //How often in seconds to update info //End of Config

//Variables that make the script work //Don't edit unless you know what your doing string version="1.1a"; //Version Number string endcmd="Close"; //End Dialog list usercmd=["About","Status","Admin"]; //User Menu string usertext="User"; list admincmd=["Back","Reset","Test"]; //Admin Menu string admintext="Admin"; string owner; //Owner Key string im=""; integer online=TRUE;

SetNew(integer new) {

   vector pos=llGetPos();
   if (new) //Yay New Mail
   im="You Got Mail 
   (http://slurl.com/secondlife/"+llGetRegionName()+"/"+(string)pos.x+"/"+(string)pos.y+"/"+(string)pos.z+")";
   llSetColor(<new,!new,new>, 6);

}

default {

   state_entry()
   {
       //Init
       llListen(chan, "", "", "");
       llSetTimerEvent(updatetime);
       SetNew(FALSE);
       
       //Set up the Prims Settings
       llSetTouchText("Menu");
       llSetClickAction(CLICK_ACTION_OPEN);
       llAllowInventoryDrop(TRUE);
       owner=llGetOwner();
       llSetText( llKey2Name(owner) + "'s Mail Box:\nClick to Open then Drag and Drop\n Item into Box. Right Click for Menu.\n---\nNote: This is still in the testing phase",<1,1,.5>,.75 );   
   }
   
   touch(integer num)
   {
       key id=llDetectedKey(0);
       llDialog(id, usertext, endcmd+usercmd, chan); //Show user menu
   }
   
   timer()
   {
       if (im!="")
       {
           llInstantMessage(owner, im);
           im="";
       }
       llRequestAgentData(owner, DATA_ONLINE);    
   }
   
   dataserver(key request, string data)
   {
       if (data == "1")
       online = TRUE;
       else
       online = FALSE;
   }
   
    changed(integer change)
   {
       if (change & CHANGED_ALLOWED_DROP) //Did we get a new item?
       {
           SetNew(TRUE);
       }
   }
      
   listen( integer channel, string name, key id, string msg )
   {
       msg=llToLower(msg);
       if (msg==llToLower(endcmd)) //End
       {
           //Do Nothing
       }
       else if (msg=="back") //Back
       {
           llDialog(id, usertext, endcmd+usercmd, chan); //Show user menu
       }
       else if (msg=="status") //Status
       {
           if (online) //Check Online
           {
               llDialog(id, llKey2Name(owner)+" is Online",endcmd+["Back"],chan);
           }
           else
           {
               llDialog(id, llKey2Name(owner)+" is Offline",endcmd+["Back"],chan);
           }
       }
       else if (msg=="about") //About
       {
           llDialog(id, "Zand Gundersen's Mail Box Script Version "+version+credits,endcmd+["Back"],chan);
       }
       else if (msg=="admin") //Admin
       {
           if (id==owner)
           {
               llDialog(id, admintext, endcmd+admincmd,chan); //Show admin menu
           }
           else
           {
               llDialog(id, "Only Owner Can Do That", endcmd+["Back"],chan);
           }
       }
       else if (msg=="reset") //Reset
       {
           if (id==owner)
           {
               llDialog(id, "Reseted",endcmd+["Back"],chan);
               llResetScript();
           }
           else
           {
               llDialog(id, "Only Owner Can Do That",endcmd+["Back"],chan);
           }
       }
       else if (msg=="test") //Test
       {
           if (id==owner)
           {
               llDialog(id, "Test Send",endcmd+["Back"],chan);
               SetNew(TRUE);
           }
           else
           {
               llDialog(id, "Only Owner Can Do That",endcmd+["Back"],chan);
           }
       }
       
   }

} </lsl>