Create a LSL script for give an object to the inventory

2.1k Views Asked by At

i need a script that when someone touch the object will receive the items that are inside the object, but the items inside have no copy,no modify,transfer permissions, i couldn t find nothing....please help

1

There are 1 best solutions below

0
Cassius On

If you don't have copy permissions in the contents to be delivered, you would have to deliver each one at a time, like this:

DeliverContents(key receiver)
{
    integer item = llGetInventoryNumber(INVENTORY_ALL);
    while (item--)
    {
        string inv_name = llGetInventoryName(INVENTORY_ALL, item);
        if (llGetInventoryType(inv_name)!=INVENTORY_SCRIPT)
        {
            llGiveInventory(receiver, inv_name);

        }
    }
}

default
{
    touch_start(integer num_detected)
    {
        key toucher = llDetectedKey(0);
        DeliverContents(toucher);
    }
}

However, if they are no-copy for the next owner, but you do have copy permissions, you are able to deliver them as a folder, like this:

DeliverContentsFolder(key receiver)
{
    integer item = llGetInventoryNumber(INVENTORY_ALL);
    list folder;
    while (item--)
    {
        string inv_name = llGetInventoryName(INVENTORY_ALL, item);
        if (llGetInventoryType(inv_name)!=INVENTORY_SCRIPT)
        {
            folder+=inv_name;
        }
    }

    if (llGetListLength(folder))
    {
        string folder_name = llGetObjectName();
        llGiveInventoryList(receiver, folder_name, folder);
    }
}

default
{
    touch_start(integer num_detected)
    {
        key toucher = llDetectedKey(0);
        DeliverContentsFolder(toucher);
    }
}