Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Problem with "GiveAllContents"-Script

Funaria Moose
Registered User
Join date: 4 Sep 2005
Posts: 26
10-17-2005 03:52
Hi!

I'm quite new here and right now playing around with the Script "GiveAllContents".
If I add more than 3 items to the content I get this error:

Unable to give inventory: No item named ''

I can't find the mistake ...

Here's the script:

CODE

// Copyright 2004, Trimming Hedges. Released to the public domain.

// This is a simple script that gives everything in a box to the person who clicked.
// By default, it will only give items to the owner of the box.

// I wrote this because of all the texture bundles that are given out. It's really a PAIN
// to move a lot of textures or other contents out of a box. This speeds that up.

// This is NOT a vending script. You can use this script to give everything in a box to someone, by changing 'owneronly' to be 0. BUT:
//
// I suggest not using this script in an area where several people are going to touch it at once, because giving inventory is slow.
// Version 2.0 of this script now detects multiple simultaneous touches: it is still slow, but it should work better at classes or events.

// THIS IS NOT A VENDING SCRIPT. It gives items away, it does NOT SELL THEM. (You don't need a script for most vending anyway.)
// This script doesn't give itself away. If you want it to, put it in the box, and set it to not running.
// Then rename a copy and put that in the box too. The renamed copy should be the running one.
// Rename it FIRST, I had weird issues with renaming it when it was already in
// the box. (version 1.2.12 of SL.)

integer owneronly = 0;
key owner;

default
{
state_entry()
{
owner = llGetOwner();
}

touch_start(integer total_number)
{
integer i;
for (i=0;i<total_number;i++)
{
key target = llDetectedKey(i);

if ( (target != owner) && (owneronly == 1) ) // person clicking isn't owner and owneronly is set;
{
llInstantMessage(target,"Sorry, only the owner is allowed to get my contents.");
return;
}
list inventory_types = [INVENTORY_BODYPART,INVENTORY_CLOTHING,INVENTORY_LANDMARK,INVENTORY_NOTECARD,INVENTORY_OBJECT,INVENTORY_SCRIPT,INVENTORY_SOUND,INVENTORY_TEXTURE];
integer inventory_count = llGetListLength(inventory_types);
integer j;
integer k;
integer type;
integer typecount;
string myname = llGetScriptName();
string objectname;

for (j=0; j<inventory_count;j++)
{
type = llList2Integer(inventory_types,j); // get the next inventory type from the list
typecount = llGetInventoryNumber(type); // how many of that kind of inventory is in the box?
if (typecount > 0)
{
for (k=0; k<typecount;k++)
{
objectname = llGetInventoryName(type,k);
if (objectname != myname) // don't give self out so the user doesn't get fifty thousand copies.
{
llGiveInventory(target,objectname);
}
}
}
}
}
}
}
_____________________
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
10-17-2005 04:17
What are the permissions on those objects?

Personaly i would use
CODE


Example:
default
{
on_rez(integer nevermind)
{
llSetText("Touch me to unpack\nyour new "+llGetObjectName()+".",<1,1,1>,1.0);
}
touch_start(integer total_number)
{
// give all items in a prim to the owner, as folder (with the name of the prim)
// Ezhar Fairlight <efairlight@gmail.com>

// user-friendly additions by Mechanique Thirty (egypt@urnash.com)
// Script adjusted to run faster by Strife Onizuka.

if(llDetectedKey(0) != llGetOwner()) return;
list inventory;
string name;
integer num = llGetInventoryNumber(INVENTORY_ALL);
string text = llGetObjectName() + " is unpacking...\n";
integer i;

for (i = 0; i < num; ++i) {
name = llGetInventoryName(INVENTORY_ALL, i);
if(llGetInventoryPermMask(name, MASK_OWNER) & PERM_COPY)
inventory += name;
else
llOwnerSay("Cannot give asset \""+name+"\", owner lacks copy permission");
llSetText(text + (string)((integer)(((i + 1.0) / num) * 100))+ "%", <1, 1, 1>, 1.0);
}

//chew off the end off the text message.
text = llGetObjectName();

//we don't want to give them this script
i = llListFindList(inventory, [llGetScriptName()]);
inventory = llDeleteSubList(inventory, i, i);

if (llGetListLength(inventory) < 1) llOwnerSay("No items to offer."); else
{
llGiveInventoryList(llGetOwner(), text, inventory);
llSetText("All done!\nYou can delete this now!",<1,1,1>,1);
llOwnerSay("Your new "+ text +" can be found in your inventory, in a folder called '"+ text +"'. Drag it onto your avatar to wear it!");
}
}
}
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey