Jump to content

Multi user Mailbox script


Taliena Leistone
 Share

You are about to reply to a thread that has been inactive for 2658 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hello.. I have a basic mailbox script I am using, and it works great.. But the mailbox is for 2 people, and only I (the owner) can access the menu to read/delete the mail. So any mail for the other person, has to be given thru me. I need one that will allow myself and one other person to access the menu to read/delete the mail. If someone could please help me, would be greatly appreciated.

Link to comment
Share on other sites

It's hard to give a specific response without knowing how you wrote the script, but the generic answer is that you put an if test at the start of the touch_start event (or wherever you trigger your user menus) that says something like

if( ( llDetectedKey(0) == Talienas_UUID ) || (llDetectedKey(0) == Talienas_friends_UUID)){   // Show the menu}

 

 

Link to comment
Share on other sites

This is a script I got as a generic mail system.. this is what I am trying to alter, to allow 1 other person to access the the menu/notecards

 

// :CATEGORY:Suggestion Box
// :NAME:Suggestion_Box
// :AUTHOR:dakar Muliaina
// :CREATED:2010-01-10 05:20:56.000
// :EDITED:2013-09-18 15:39:05
// :ID:843
// :NUM:1171
// :REV:1.0
// :WORLD:Second Life
// :DESCRIPTION:
// To use this script, simply copy/paste the contents below into a New Script in the game. Then place the script into a ‘prim’ (in the shape of a mailbox or suggestion box?). That’s all there is to it.
// :CODE:
// --------------------------------------//

// This script transform a prim to a Mail Box.

// Folks can drop notecard to the box.

// Read/unread information is displayed as hovering text.

// You can copy/modify this script, it's totally free.

// --------------------------------------//

// Modified by dakar Muliaina, converted to The king's English

// and a few other enhancements.

//-------------------------------------------//

 

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;

 

TxtRefresh()

{

// show the unreadable notecard

integer nTotalCard = 0;

integer nNotReaded = 0;

integer nCount = 0;

for (nCount = 0; nCount < llGetListLength(lMail); nCount += 2)

{

if (llList2Integer(lMail, nCount + 1) == MAIL_UNREADED)

nNotReaded += 1;

nTotalCard += 1;

}

 

// total string

string cPost = (string)nTotalCard + " card";

if (nTotalCard > 1) cPost += "s";

cPost += " posted";

 

// unreaded string

string cUnreaded = (string)nNotReaded + " unread";

llSetText("\n" + cPost + "\n" + cUnreaded, <1.95, .75, 0>, 1);

}

 

default

{

state_entry()

{

// 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_NOTECARD, n_CurObj);

n_CurObj += 1;

if (c_Name != "")

{

lMail += [c_Name];

lMail += MAIL_UNREADED;

}

}

TxtRefresh();

}

 

touch_start(integer total_number)

{

//---- 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 channel, string name, key id, string message)

{

if (llGetOwner() == id && llListFindList(DIALOG_CHOICE,

[message]) != -1)

{

integer i;

string cName;

list lRemove;

integer nStatus;

for (i = 0; i < llGetListLength(lMail); i += 2)

{

cName = llList2String(lMail, i);

nStatus = llList2Integer(lMail, i + 1);

if (message == llList2String(DIALOG_CHOICE, 0)

&& nStatus == MAIL_UNREADED)

{

// open un-readed

llGiveInventory(id, cName);

// mark for readed

lMail = llListReplaceList(lMail, [MAIL_READED],

i + 1, i + 1);

}

if (message == llList2String(DIALOG_CHOICE, 1)

&& nStatus == MAIL_READED)

{

// open readed

llGiveInventory(id, cName);

}

if (message == llList2String(DIALOG_CHOICE, 2)

&& nStatus == MAIL_READED)

{

// delete readed

llSay(0, cName);

llRemoveInventory(cName);

lRemove += i;

}

}

// remove from the list

if (llGetListLength(lRemove) > 0)

{

integer k;

for (k = 0; k < llGetListLength(lRemove); k++)

{

i = llList2Integer(lRemove, k);

lMail = llDeleteSubList(lMail, i, i+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_ALL, nCurObj);

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 = 0; nD < llGetListLength(lRemove); nD += 1)

{

// dont remove this script !

cName = llList2String(lRemove, nD);

if (cName != llGetScriptName() && cName != "")

{

llSay(0, "Sorry but " + 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_NOTECARD, n_CurObj);

llSay(0, c_Name);

n_CurObj += 1;

// search for this card

if (llListFindList(lMail, [c_Name]) == -1 && c_Name != "")

{

// ok its a new card

lMail += [c_Name];

lMail += MAIL_UNREADED;

llSay(0, c_Name + " added to the mailbox.");

}

}

}

nLastItemCount = llGetInventoryNumber(INVENTORY_ALL);

nLastCardCount = llGetInventoryNumber(INVENTORY_NOTECARD);

// refresh the text

TxtRefresh();

}

}

Link to comment
Share on other sites

Yup, basically what I guessed.  See right at the top of the touch_start event?  Where it's asking whether id == llGetOwner()?   Just test to see whether id is your UUID or your friend's UUID instead of just looking for yours.  You'll need to do a similar thing at the top of the listen event, although it's not clear to me why the script even cares at that point.  You could reduce that to just

if (llListFindList(DIALOG_CHOICE,[message]) != -1)

 

Link to comment
Share on other sites

  • 2 years later...

You didn't specify what "doesn't work", so it's hard to give you any constructive advice.  At this point, the best thing for you to do is to add diagnostic llOwnerSay messages at critical places in the script to find out where it's failing and what the values of key variables are.  If you identify the trouble spot and you're still stuck, post the problem area here again (not the entire script), and tell us exactly what you need help with.

FWIW, this is one of the problems with trying to modify a script that someone else wrote.  It's often more trouble to fiogure out the other scripter's logic than to simply write your own.

Link to comment
Share on other sites

How did you interpret Rolig's suggestion about changing the scrpt?

 I think she's suggesting that you change the test in the touch_start event from

		key id = llDetectedKey(0);		if (id == llGetOwner()) //if the toucher is my owner		{			//show the menu		}

to something like

		key id = llDetectedKey(0);		if(id == llGetOwner() || id == my_friends_uuid)		{			//show the menu		}

and EITHER making a similar change to the test in the listen event, from  

		if (llGetOwner() == id && llListFindList(DIALOG_CHOICE,[message]) != -1)		{			//if the uuid of the speaker is that of my owner and the message is an item in the list DIALOG_CHOICE		}

to something like

		if( llListFindList([my_uuid, my_friends_uuid],[id] != -1 ) && (llListFindList(DIALOG_CHOICE,[message]) != -1))		{			//if the uuid is either mine or that of my friend AND the message is an item in the list DIALOG_CHOICE 		}

or  removing the first half of that test altogether, and simply checking on whether the message is a list item.

If you want to have multiple users, then probably the easiest way to test things is have a list of approved users that read from a notecard in the dataserver event, and then do a similar test -- something on the these lines (obviously this is just a fragment of code that won't work on its own):

list lApprovedUsers;string strAccessCard = "Access List";default {	state_entry() {		 lApprovedUsers+=[llGetOwner()]; // add the owner to the list automatically		 if(llGetInventoryType(strAccessCard) == INVENTORY_NOTECARD)		 {		 	//if there is a notecard in my inventory called "Access List", then do stuff to read it and further populate lApprovedUsers		 }	}	//and so on	touch_start(integer num_detected) {		key id = llDetectedKey(0);		if(llListFindList(lApprovedUsers, [id]) != -1)		{			//if the toucher is on the list of approved users		}	}

You can find a good generic example of how to do that (by Rolig, as it happens) in the Forum Script Library,

However, I would strongly advise you to get this example working first, since the basic logic ("is the toucher on a list of approved people?") is identical, and this example is a lot simpler.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2658 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...