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

LSL Wiki : llGiveInventory

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawl427.us.archive.org
llGiveInventory(key destination, string inventory)

Gives the named inventory item to the agent or object with the key destination. Objects have to be in the same sim but agents can receive inventory regardless of where they are. If the user isn't online, they will receive a dialog box when they next log in, asking them whether they would like to accept or decline the object's inventory offer. If offline IMs are enabled, they will also receive an email notification saying they have been offered inventory.

If the recipient is an agent, the user then follows the normal procedure of accepting or denying the offer. If the recipient is an object, the same permissions apply as if a user dragged an inventory item onto the object manually, i.e. if llAllowInventoryDrop has been called with TRUE, any other object can pass items to its inventory. No-copy objects can not be given from attachments.

If the recipient is an object, and the object already has something in its inventory with this name, then Second Life will check to see if the object being given differs from the object already existing in the recipient's inventory, or if it is another copy of the same object (ie, the object is being given multiple times). If it is the same object being given multiple times, nothing happens at all, and the recipient's inventory does not change. If the object is deemed to be a different object with the same name, it will create a new copy with an incremented number, as if a user manually placed an item with a duplicate name into an object's inventory. This differs from what happens if llRemoteLoadScriptPin places a script with a duplicate name into an object's inventory.

If you give a script the transfer will be done on the asset server but the script VM won't be loaded into the sim containing the object. This will cause the script to be unable to be started by normal means. To start the script you must either recompile it (forcing the sim to load the new VM) or pick the object up, rez it in world again, then the script may be set to running by normal means (check box in script window, set all scripts in selection to running via the tools menu, or by using llSetScriptState from another script. If you need to give a running script to an object, use llRemoteLoadScriptPin. A recipient that has recieved a non-running script from an llGiveInventory call cannot start that script running within itself, but it can still give that script to a further object using llRemoteLoadScriptPin, and the script will still be started on the recipient of the llRemoteLoadScriptPin if the parameters to that call specified that it should be.

A script may give itself.

If you attempt to give a large number of objects within a short period of time (such as using multiple scripts to increase speed) or you rez a self-replicating object that attempts to give objects, you may run into the Grey Goo Fence, which attempts to slow grid attacks.

Note: This function delays the script for 3 seconds if the target is an avatar. Object to object transfers seem to have no delay, and the delay text has been removed from the SL tooltip.

Q: How do I just make a script that just gives someone the only object/notecard/texture in inventory?
A: Simple, do this:
default {
    touch_start(integer total_number) {
        // to give a different inventory item type,
        // replace "INVENTORY_OBJECT" with "INVENTORY_NOTECARD", etc.
        llGiveInventory(llDetectedKey(0),llGetInventoryName(INVENTORY_OBJECT, 0));
    }
}

Q: Is there a way to have an object give itself?
A: No, but it's possible to put a copy of the object into itself that it can then give, which is sufficient for many uses. Also, here's a feature suggestion thread asking for it. This sort of thing is sometimes used in self-replicating objects.

Q: Can an object refuse an item based on a conditional statement?
A: No, but if you keep track of the inventory your object contains, you can remove unwanted items using llRemoveInventory when the changed event is called with CHANGED_INVENTORY in its integer parameter.

Q: How can I confirm the intended recipient actually recieved the item?
A: You can't, not automatically. If giving an item to an object, the recipient object could contain a script with a changed event, allowing it to llSay a "received item" message. When giving an item to an agent, you're probably out of luck.

Q: Can I choose which folder the inventory item goes into?
A: Not with llGiveInventory. Instead, use llGiveInventoryList, with the list containing the single item (to an agent in the same sim).

Q: When I try to give an inventory item, the item disappears from the original object's inventory. What's going on?
A: This is happening because you don't have copy permission on the item you're trying to give. Consequently, the script gives the only copy of the item in your object. To determine whether or not you have permission to give the objects specified, use llGetInventoryPermMask.

Q: Can my object give inventory to an object owned by another user?
A: Yes, but only if the receiving object has llAllowInventoryDrop set to TRUE. See CHANGED_ALLOWED_DROP under the changed event.

Q: Can prims in a linked object be given inventory items?
A: Yes. You must use llGetLinkKey to do it though.

Also see llGiveInventoryList to give several items at once, or to give items in a folder.


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

Functions | Inventory | llGiveInventoryList
Comments [Hide comments/form]
Ok, is it just me, or when you try to give an object that's in inventory to an agent, the object disappears from the original object's inventory?
-- DriftwoodNomad (2004-08-17 04:49:41)
Only when the current owner (you) doesn't have copy permission on the given object.
-- EzharFairlight (2004-08-17 14:36:57)
wrap your links in "[[" "]]"
http://forums.secondlife.com/showthread.php?t=67758
-- BlindWanderer (2005-10-27 15:59:34)
As of SL 1.7.1.3 llGiveInventory's functionality has been restored. See release notes: http://forums.secondlife.com/showthread.php?t=69156
-- StickMan (2005-11-06 14:40:45)


Fixing italics.
-- DolusNaumova (2005-11-07 15:55:31)
In attempting to use llGiveInventory to spread a script through the prims of a linkset... the script arrives fine, and not running of course. However no combination of "set scripts in selection to running" or "reset scripts in selection" would make them run. Only "recompile scripts in selection" would make them run.
-- SeifertSurface (2006-03-19 21:26:26)
You have to use llRemoteLoadScriptPin for that.
-- ReadyJack (2006-03-20 00:13:17)
Is this a new bug? Discovered Jan 4 2007, in 1.13.1(5)

Create two prims, link them, and place the following script in the root prim. The drop an object (with full permissions -- I used a snapshot) called "A" in the inventory of the root prim. Infinite loop.

default
{ state_entry()
{}

changed(integer change) {
if(change & CHANGED_INVENTORY) {
key k = llGetLinkKey(2);
llOwnerSay(llGetDate() + " Giving inventory");
llGiveInventory(k, "A");
}
}
}

The following script demonstrates that there is exactly one "changed" event for each llGiveInventory call.

integer count = 0;
default {
state_entry(){count = 0;}

timer() {
llSetTimerEvent(0.0);
llOwnerSay(llGetTimestamp() + " Giving " + ((string)count));
key k = llGetLinkKey(2);
llGiveInventory(k, "A");
}

changed(integer change) {
llOwnerSay(llGetTimestamp() + " Waiting to give " + ((string)count));
count++;
llSetTimerEvent(2.0);
}
}
-- OneBigRiverStork (2007-01-04 18:21:32)
The last comment is a bit misleading. The only time I have ever seen this happen is if you set the permissions on an object while it is in your inventory and put it directly into the object using this function. You should NEVER do this ( this is an old "bug" ). Always change permissions on an object that is rezzed and then take a copy and put that into the object doing the giving.
-- EvoCommons (2007-07-06 02:18:56)
Attach a comment to this page: