Don't click here unless you want to be banned.

LSL Wiki : llGiveInventoryList

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawl338.us.archive.org
llGiveInventoryList(key destination, string category, list inventory)

Give the list of named inventory items to the keyed agent (anywhere in the world--see notes below) or object (in the same simulator as the giver) destination. If the recipient is an agent, the user follows the normal procedure of accepting or denying the offer. The offered inventory is then placed in a folder named category in the recipient's inventory. If the recipient is an object, the same permissions apply as if the user dragged inventory onto the object by hand, i.e., if llAllowInventoryDrop has been called with TRUE, any other object can pass items to its inventory. If the recipient is an object, the category parameter is ignored--an object cannot contain folders in its inventory.

Notes:

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.

        list        inventory;
        string      name;
        integer     num = llGetInventoryNumber(INVENTORY_ALL);
        string      text = llGetObjectName() + " is unpacking...\n";
        integer     i;
        key         user = llGetOwner();//Set to llDetectedKey(0); to allow anyone to use
        
        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()]);
        if(~i)//if this script isn't found then we shouldn't try and remove it
            inventory = llDeleteSubList(inventory, i, i);
        
        if (llGetListLength(inventory) < 1) llSay(0, "No items to offer."); else
        {
            llGiveInventoryList(user, text, inventory);
            llSetText("All done!\nYou can delete this now!",<1,1,1>,1);
            name = "Your new "+ text +" can be found in your inventory, in a folder called '"+ text +"'. Drag it onto your avatar to wear it!";
            if(user == llGetOwner())
                llOwnerSay(name);
            else
                llInstantMessage(user, name);
        }
    }
}

Q: Is there a way to give items into an existing folder or subfolder in a user's inventory?
A: No. The recipient will recieve the items in a new folder with the name specified in category within their inventory's root. There's no way to create a folder within their 'Clothing' folder, for example.

Q: So can I use llGiveInventoryList to give items that I can copy, but that have been set to prohibit other users from copying?
A: Yes. llGiveInventoryList will only prevent a script from giving an items if its owner does not have permissions copy permission. See llGetInventoryPermMask for more details on the difference between a "no-copy" item the creator can copy, and a no-copy item after it's been transferred to another user.

Q: What if the user I'm trying to give the objects to is offline?
A: If their offline buffer isn't full, and they don't have the object giving the items muted, they will be able to accept the transfer when they log on.

I seriously doubt if this is true. It gives me a "Cannot find destination" error -- FuRaz
This error seems to appear if the destination avatar was never on the sim where the object invoking llGiveInventoryList() is used, like described above. This is quite frustrating! -- GwynethLlewelyn

If the category argument of llGiveInventoryList is set to an empty string, it appears that the object(s) in the list are given individually into destination's inventory root. (02/04/09). -- GanymedeCeriaptrix


This article wasn't helpful for you? Maybe the related article at the LSL Portal is able to bring enlightenment.

Functions | Inventory | llGiveInventory
Comments [Hide comments/form]
This function cannot be used to give items that are no copy. Don't be fooled by testing a script using this function on yourself.
-- MeiyoSojourner (2004-09-16 15:42:02)
My original change to this page was to fix a syntax error, but now I've got a radical change for the example script:
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.

// Split into parts and variable name changes by Robot Mann
        list        inventory;
        string      invitem;
        string      scriptname = llGetScriptName();
        integer     num = llGetInventoryNumber( INVENTORY_ALL );
        string      objname = llGetObjectName();
        integer     i;
        integer     partnum = 1;
        
        for ( i = 0 ; i < num ; ++i )
        {
            invitem = llGetInventoryName( INVENTORY_ALL , i );
            if ( invitem != scriptname )
            {
                if( llGetInventoryPermMask( invitem , MASK_OWNER ) & PERM_COPY)
                {
                    inventory += invitem;
                    if( llGetListLength( inventory ) > 99 )
                    {
                        llGiveInventoryList( llGetOwner() , objname + " part " + (string)partnum , inventory );
                        partnum++;
                        inventory = [];
                    }
                }
                else
                {
                    llOwnerSay("Cannot give asset \""+invitem+"\", owner lacks copy permission");
                }
            }
            string percentdone = (string)((integer)(((i + 1.0) / num) * 100));
            string portiondone = (string)i+"/"+(string)num;
            llSetText(objname + " is unpacking...\n" + percentdone + "%\n("+portiondone+")\nPart("+(string)partnum+")", <1, 1, 1>, 1.0);
        }
        
        if ( llGetListLength( inventory ) > 0 )
        {
            string text = llGetObjectName();
            if ( partnum > 1 )
            {
                text += " part " + (string)partnum;
            }
            llGiveInventoryList( llGetOwner() , text , inventory );
            llSetText("All done!",<1,1,1>,1);
        }
    }
}

I was getting an error copying items out of an object with 300 items in it. This script creates partial folders with 100 items each in them (if less than 100 items, it doesn't add the "part x" to the folder name.)
-- RobotMann (2005-10-03 14:06:57)
I wrote this little function just to be safe. If you want to use llGiveInventoryList but you don't know if the person is in the same sim, all you have to do is use the llKey2Name() function to detect if the person is. Here's the example. I wrote this thingie here on the wiki, so it could contain errors :P

Just add it to your script before "default" and use llSafeGiveInventoryList instead of llGiveInventoryList.

llSafeGiveInventoryList(key destination, string category, list inventory)
{
      if (llKey2Name(destination) != "") // if the user is in the same sim as the object
      {
            llGiveInventoryList(destination, category, inventory); // then just use the normal function
      } else // if the user is not in the same sim, or the person is offline
      {
            integer i;
            for (i = 0; i < llGetListLength(inventory); i++) // send each item in the list seperately
            {
                  llGiveInventory(destination, llList2String(inventory, i));
            }
      }
}
-- FuRaz (2006-06-17 07:49:26)
Psst, test the script in SL BEFORE posting it to the wiki.
-- EepQuirk (2006-06-18 00:52:16)
Psst, The function works fine Eep. Does exactly what it is supposed to do.

I know... maybe you should test the script before blindly being the Wiki Cop and telling someone else to test it.
-- ThraxisEpsilon (2006-06-18 05:27:40)
Hello every one can you please help with this doubt !!!!
i wanted to know what will be the result if the folder with same exists already before then will it over rite it or make another folder or will extract the contents in the folderhaving same folder name!!!!
can any one plz please help me!!!!
-- triband-mum-59.182.233.90.mtnl.net.in (2007-11-05 06:43:41)
It creates a new folder with the same name - not overwriting anything :)
-- 0x55532465.adsl.cybercity.dk (2007-12-05 11:18:51)
(that was me btw :P - forgot to log in :P)
-- HerbsBest (2007-12-05 11:21:57)
I've managed to speed the example a bit (by about 30%) by avoiding llGetListLength call in every iteration of the loop...

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.

// Split into parts and variable name changes by Robot Mann

// Optimized by Domchi Underwood (in SL)
        list        inventory;
        string      invitem;
        string      scriptname = llGetScriptName();
        integer     num = llGetInventoryNumber( INVENTORY_ALL );
        string      objname = llGetObjectName();
        integer     i;
        integer     partnum = 1;
        integer     invsize = 0;
        
        for ( i = 0 ; i < num ; ++i )
        {
            invitem = llGetInventoryName( INVENTORY_ALL , i );
            if ( invitem != scriptname )
            {
                if( llGetInventoryPermMask( invitem , MASK_OWNER ) & PERM_COPY)
                {
                    inventory += invitem;
                    ++invsize;
                    if( invsize > 99 )
                    {
                        llGiveInventoryList( llGetOwner() , objname + " part " + (string)partnum , inventory );
                        partnum++;
                        inventory = [];
                        invsize = 0;
                    }
                }
                else
                {
                    llOwnerSay("Cannot give asset \""+invitem+"\", owner lacks copy permission");
                }
            }
            string percentdone = (string)((integer)(((i + 1.0) / num) * 100));
            string portiondone = (string)i+"/"+(string)num;
            llSetText(objname + " is unpacking...\n" + percentdone + "%\n("+portiondone+")\nPart("+(string)partnum+")", <1, 1, 1>, 1.0);
        }
        
        if ( llGetListLength( inventory ) > 0 )
        {
            string text = llGetObjectName();
            if ( partnum > 1 )
            {
                text += " part " + (string)partnum;
            }
            llGiveInventoryList( llGetOwner() , text , inventory );
            llSetText("All done!",<1,1,1>,1);
        }
    }
}
-- DomchiUnderwood (2007-12-25 19:14:37)
Attach a comment to this page: