Perfect MailBox

Thread Started By steadymobbin

2337
0
  • 46 Vote(s) - 3.15 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rate Thread
#1
PHP Code:
list lMail = [];
// column 1 = notecard name, column 2 = read by user
integer     MAIL_UNREADED 0;
integer     MAIL_READED 1;
integer     DIALOG_CHANNEL 49383;
list        
DIALOG_CHOICE =
                [
"Unread",
                 
"Read",
                 
"Delete"];
integer nLastCardCount 0;
integer nLastItemCount 0;
key owner1;
string ownerName;

TxtRefresh()
{
    
// show the unreadable notecard
    
integer nTotalCard 0;
    
integer nNotReaded 0;
    
integer nCount 0;
    for (
nCount 0nCount llGetListLength(lMail); nCount += 2)
    {
        if (
llList2Integer(lMailnCount 1) == MAIL_UNREADED)
            
nNotReaded += 1;
        
nTotalCard += 1;
    }

    
// total string
    
string cPost = (string)nTotalCard " card";
    if (
nTotalCard 1cPost += "s";
    
cPost += " Recu";

       
// unreaded string
    
    
string cUnreaded = (string)nNotReaded " Non Lu";
    
llSetText("MailBox of : " + (string)ownerName "\n"+"Drag your notecard has the inside\n" cPost "\n" cUnreaded, <.95.750>, 1);
}

default
{
    
on_rez(integer n)
    {
        
llSetText(" ",<0,0,0>,0.0);
        
llResetScript();
    }
    
state_entry()
    {
       
owner1 llGetOwner();
        
ownerName llKey2Name(owner1);
       
// Allowing dropping of object
       
llAllowInventoryDrop(TRUE);
       
llListen(DIALOG_CHANNEL""NULL_KEY"");
       
nLastCardCount llGetInventoryNumber(INVENTORY_ALL);
       
nLastItemCount llGetInventoryNumber(INVENTORY_NOTECARD);

       
// Auto complete list
       
integer nCardCount llGetInventoryNumber(INVENTORY_NOTECARD);
       
integer n_CurObj 0;
       
string c_Name "NotEmpty";
       while (
c_Name != "")
       {
            
c_Name llGetInventoryName(INVENTORY_NOTECARDn_CurObj);
            
n_CurObj += 1;
            if (
c_Name != "")
            {
                
lMail += [c_Name];
                
lMail += MAIL_UNREADED;
            }
        }
        
TxtRefresh();
    }

    
touch_start(integer total_number)
    {
        
llSay(0"Drag a note card to leave a message");
//---- Change MY OWNER above to suit your likes and needs.   //
        // if owner
        
key id llDetectedKey(0);
        if (
id == llGetOwner())
        {
            
// Show a dialog
            
llDialog(id"What do you want to do ?"DIALOG_CHOICE,
              
DIALOG_CHANNEL);
        }
    }

    
listen(integer channelstring namekey idstring message)
    {
        if (
llGetOwner() == id && llListFindList(DIALOG_CHOICE,
           [
message]) != -1)
        {
            
integer i;
            
string cName;
            list 
lRemove;
            
integer nStatus;
            for (
0llGetListLength(lMail); += 2)
            {
                
cName llList2String(lMaili);
                
nStatus llList2Integer(lMail1);
                if (
message == llList2String(DIALOG_CHOICE0)
                   && 
nStatus == MAIL_UNREADED)
                {
                    
// open un-readed
                    
llGiveInventory(idcName);
                    
// mark for readed
                    
lMail llListReplaceList(lMail, [MAIL_READED],
                        
11);
                }
                if (
message == llList2String(DIALOG_CHOICE1)
                   && 
nStatus == MAIL_READED)
                {
                    
// open readed
                    
llGiveInventory(idcName);
                }
                if (
message == llList2String(DIALOG_CHOICE2)
                   && 
nStatus == MAIL_READED)
                {
                    
// delete readed
                    
llSay(0cName);
                    
llRemoveInventory(cName);
                    
lRemove += i;
                }
            }
            
// remove from the list
            
if (llGetListLength(lRemove) > 0)
            {
                
integer k;
                for (
0llGetListLength(lRemove); k++)
                {
                    
llList2Integer(lRemovek);
                    
lMail llDeleteSubList(lMailii+1);
                }
            }
            
TxtRefresh();
        }
    }

    
changed(integer change)
    {
        
// dont accept other than a notecard
        
integer nItemCount llGetInventoryNumber(INVENTORY_ALL);
        if (
nItemCount 2)
        {
            
// clear the list
            
lMail = [];
        }

        if (
nItemCount != nLastItemCount)
        {
            
// delete other item type than notecard
            
string cName "NotEmpty";
            
integer nCurObj 0;
            
integer nObjType INVENTORY_NONE;
            list 
lRemove = [];
            while (
cName != "")
            {
                
cName llGetInventoryName(INVENTORY_ALLnCurObj);
                
nCurObj += 1;
                
nObjType llGetInventoryType(cName);
                if (
nObjType != INVENTORY_NOTECARD)
                {
                    
// add for deletion, its not a notecard
                    
lRemove += cName;
                }
            }

            
// delete other object than notecard
            
integer nD 0;
            for (
nD 0nD llGetListLength(lRemove); nD += 1)
            {
                
// dont remove this script !
                
cName llList2String(lRemovenD);
                if (
cName != llGetScriptName() && cName != "")
                {
                    
llSay(0"Sorry " cName "is not a notecard");
                    
llRemoveInventory(cName);
                }
            }

            
// search for a new notecard
            
integer n_CurObj 0;
            
string c_Name "NotEmpty";
            while (
c_Name != "")
            {
                
c_Name llGetInventoryName(INVENTORY_NOTECARDn_CurObj);
                
llSay(0c_Name);
                
n_CurObj += 1;
                
// search for this card
                
if (llListFindList(lMail, [c_Name]) == -&& c_Name != "")
                {
                    
// ok its a new card
                    
lMail += [c_Name];
                    
lMail += MAIL_UNREADED;
                    
llSay(0c_Name " ajouter a la MailBox");
                }
            }
        }
        
nLastItemCount llGetInventoryNumber(INVENTORY_ALL);
        
nLastCardCount llGetInventoryNumber(INVENTORY_NOTECARD);
        
// refresh the text
        
TxtRefresh();
    }

[Image: guns-bullet-shirt_recreated.jpg]
Reply




Possibly Related Threads…
Thread Author Replies Views Last Post
  ZenMondo's Mailbox [UPDATED] Famenig 2 3,632 03-03-2018, 09:55 PM
Last Post: Flash0r
  Perfect Resize 1 script steadymobbin 0 2,477 02-18-2013, 02:18 AM
Last Post: steadymobbin

Forum Jump:

1 Guest(s)
Share this:

About Second Life Copybot

Second Life CopyBot Forum is a place where you can get items for Second Life and other vitual worlds for free. With our CopyBot viewers you can export and import any content from these virtual worlds and modify them in 3D software such as Blender, 3D studio Macx etc...