Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Give some one a pack of items

Jenn Yoshikawa
Registered User
Join date: 14 Nov 2007
Posts: 91
09-19-2008 02:02
Not sure if this can be done but if it can chould some one show me how lol. I have server I have made and I want to add some thing to it. In my server I would have items listed like

Jenn Yoshikawa item 1
Jenn Yoshikawa item 2
Jenn Yoshikawa item 3
Jenn Yoshikawa item 4
John Doe item 1
John Doe item 2
John Doe item 3
John Doe item 4
Jane Doe item 1
Jane Doe item 2
Jane Doe item 3
Jane Doe item 4
etc

So when I touch the server and or use my remote pc I want the items with my name to be sent. And no one elses. The idea would be Jenn Yoshikawa mail with a title but I only want it to pick up Jenn Yoshikawa mail and send all the note cards with Jenn Yoshikawa mail to me or said person.
Pedro McMillan
SLOODLE Developer
Join date: 28 Jul 2007
Posts: 231
09-19-2008 02:21
What you'd need to do is make the script go through each item in your inventory, and check its name against the name of the avatar -- if it finds the name of the avatar in it, then add the object name to a list. You'd then pass that list to the "llGiveInventoryList" function to do the sending.

Something along these lines I guess:

CODE

// Change this if you only want to send certain types
integer TYPE_TO_SEND = INVENTORY_ALL;

send_items( key avkey )
{
string avname = llKey2Name(avkey);
list itemstosend = [];
integer numitems = llGetInventoryNumber(TYPE_TO_SEND);
string itemname = "";
integer item = 0;

// Go through each item
for (item = 0; item < numitems; item++) {

// Check if the item matches the avatar name
itemname = llGetInventoryName(TYPE_TO_SEND, item);
if (llSubStringIndex(itemname, avname) == 0) itemstosend += [itemname];

}

// Send the items
llGiveInventoryList(avkey, avname + "'s items", itemstosend);
}


I hope that's valid. :-) It could do with a lot of improvement though... especially the way it checks for the avatar name in an item name (the method there is relatively slow).
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
09-19-2008 09:03
Though it shouldn't generally be an issue if the user needs to touch the object, llGiveInventoryList() doesn't work if the avatar is offline or in another sim. In that case you'd need to llGiveInventory() each item instead of doing the entire list in one go (and you lose the nice folder delivery and have a bit more script delay to wait out).
Jenn Yoshikawa
Registered User
Join date: 14 Nov 2007
Posts: 91
nods
09-19-2008 13:50
ok after cleaning the script up some and fixing the parts some. Is there a way to give a message you have no items. I have tried to work in one I know moded it some that would work on one item but I still get that script error.

integer found = FALSE;
for (i = 0; i < llGetInventoryNumber(inventoryType); i++)
{
if (llGetInventoryName(inventoryType, i) == note)
{
found = TRUE;
}
}
if (!found)
{
llInstantMessage(av, "No New Info At This Time";);
return;
}
else
{
llGiveInventory(av, note);
return;
}
}

but I'm not sure how to go about this part.
Pedro McMillan
SLOODLE Developer
Join date: 28 Jul 2007
Posts: 231
09-19-2008 15:17
Using the function I wrote earlier, all you'd need to do is check if the list of items you're about to give is empty or not (only attempt to give the items if the list is *not* empty). E.g. instead of the existing llGiveInventoryList line, do this:

CODE

if (llGetListLength(itemstosend) == 0) llInstantMessage(avkey, "No new items at this time");
else llGiveInventoryList(avkey, avname + "'s items", itemstosend);
Jenn Yoshikawa
Registered User
Join date: 14 Nov 2007
Posts: 91
:)
09-19-2008 15:35
Thank you so much