Jump to content
MIVIMEX

Simplest Unpacker! ::: SCRIPT HELP :::

Recommended Posts

Hello! I'm trying to create a simple unpacker giving all content to the owner on rez and self-deleting. I have reviewed a bunch of scripts but they are all very difficult for a beginner. Please tell me how to start and where to go? that's what i have for now but it dont work... thanks for any help!

default
{
    on_rez(integer start_param)
    {     
       llGiveInventory(llGetOwner(), llGetInventoryName(INVENTORY_OBJECT));
       llDie;
    }
}

 

Edited by MIVIMEX

Share this post


Link to post
Share on other sites

The problem is that llGiveInventory takes a string as it's second parameter, not an integer. And that string is the name of the inventory item to give. What you'll need to do is using llGetInventoryNumber, and llGetInventoryName, compile a list of the inventory items and then best use llGiveInventoryList to give the items to the AV.

 

 

  • Thanks 1

Share this post


Link to post
Share on other sites

All you need is to loop through the object's inventory and store all the names into a list, then send them with llGiveInventoryList.

I guess the confusing part was you trying to use the function to send one item at a time.

Edited by Wulfie Reanimator
  • Thanks 1

Share this post


Link to post
Share on other sites
8 minutes ago, Wulfie Reanimator said:

All you need is to loop through the object's inventory and store all the names into a list, then send them with llGiveInventoryList.

What's the confusing part?

@Wandering Soulstar @Wulfie Reanimator

Thank you very much for the answers. the most confusing part is now how to get this list?

default
{
    on_rez(integer start_param)
    {     
       llGiveInventory(llGetOwner(), llGetInventoryName(INVENTORY_OBJECT));
       llGiveInventoryList(llGetOwner(), List);

    }
}

 

Share this post


Link to post
Share on other sites
Just now, MIVIMEX said:

@Wandering Soulstar @Wulfie Reanimator

Thank you very much for the answers. the most confusing part is now how to get this list?


default
{
    on_rez(integer start_param)
    {     
       llGiveInventory(llGetOwner(), llGetInventoryName(INVENTORY_OBJECT));
       llGiveInventoryList(llGetOwner(), List);

    }
}

 

If you read the wiki page, it's really as simple as:

list inventory;

integer i;
while(i < llGetInventoryNumber(INVENTORY_ALL))
{
  inventory += llGetInventoryName(INVENTORY_ALL, i);
  ++i;
}

Of course, if you (probably) don't want to send the unpacker script as well, you need to check if GetInventoryName matches GetScriptName.
Then, if you think someone might put no-transfer or no-copy items into the contents, you can check for that with GetInventoryPermMask.

  • Thanks 1

Share this post


Link to post
Share on other sites
17 minutes ago, Wulfie Reanimator said:

If you read the wiki page, it's really as simple as:


list inventory;

integer i;
while(i < llGetInventoryNumber(INVENTORY_ALL))
{
  inventory += llGetInventoryName(INVENTORY_ALL, i);
  ++i;
}

 

Oh thanks! where does this part go? and what does ++ mean?

default {
    on_rez(integer start_param) {
        list inventory;

        integer i;
        while (i < llGetInventoryNumber(INVENTORY_ALL)) {
            inventory += llGetInventoryName(INVENTORY_ALL, i);

            ++i;

            llGiveInventoryList(llGetOwner(), inventory);
        }
    }
}

 

Share this post


Link to post
Share on other sites
9 minutes ago, MIVIMEX said:

Oh thanks! where does this part go? and what does ++ mean?

Sorry, I'm making too many assumptions.

The bit of code I showed only fills that list, you can put it anywhere you want, where you need that list to be created. At the beginning of on_rez like you showed is fine.

"++" means "increment," it can only be used with integer variables and it increases the value by one. It has some small technical details involved but that's not very important here. You should rewrite the loop in a way you understand.

Lastly, you should not put llGiveInventoryList into the loop, otherwise you're sending a folder with one item, then a folder with two items, then a folder with three items... Put it outside of the loop, after it has finished, so that you only send one folder with all of the items found.

Edited by Wulfie Reanimator
  • Thanks 1

Share this post


Link to post
Share on other sites

@MIVIMEXHere's a fully commented example, which may help.

Note that in a production version,  I'd include some tests to make sure the objects are all copyable by the new owner.   If they aren't, then llGiveInventoryList won't give them to the owner, and you need to give them separately, one at a time, using llGiveInventory.    If you need help with that, please ask, but this, I hope, will help explain what we're talking about:

list lContents;
string strFolderName = "A folder of goodies";// change to the name you want for your folder

default {
    state_entry() {//some preliminary work to set things up
        //first, populate the lContents list
        string strThisScript = llGetScriptName();//note the name of this script, since you don't want to give that as part of the folder
        integer max = llGetInventoryNumber(INVENTORY_ALL);//note the number of items in the object's inventory
        integer counter = 0;
        do{
            string str = llGetInventoryName(INVENTORY_ALL, counter);//check the name of each item
            if(str!=strThisScript){//and if it's not this script
                lContents +=[str];//add the name to lContents
            }
        }
        while(++counter < max);//and keep on doing this, advancing the counter each time, until  all items have been checked.
        if(llStringLength(strFolderName)== 0){//sanity check -- if no folder name is provided
            strFolderName = llGetObjectName();//then use the name of this object for the folder
        }
    }

    changed(integer change) {
        if(change & CHANGED_INVENTORY){//if the contents of the object's inventory change
            llResetScript();//then reset the script in order to rebuild the list
        }
        else if(change & CHANGED_OWNER){//if the object's owner changes, give the folder to the new owner
            llGiveInventoryList(llGetOwner(), strFolderName,lContents);//give the folder to the new owner
        }
    }

    attach(key id) {
       if(id){//if someone attaches the object
            llGiveInventoryList(id, strFolderName,lContents);//give them the folder
       } 
    }


}

 

  • Thanks 1

Share this post


Link to post
Share on other sites

@Innula Zenovka

Thank you very much, I was already desperate, having decided that this is not the easiest script to start with, but with your comments everything will become clear! thank you!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...