Delete All Items In Inventory

Started by SilverSpook, Tue 19/01/2016 09:02:48

Previous topic - Next topic

SilverSpook

Is it possible to delete all of the items in a players inventory, no matter what the item is? 

I am thinking of just using the "LoseInventory" function for each item, but the thing is I can't be certain what all items will be in the inventory at a certain time.

What is the best way to do this?  Thanks

AnasAbdin

Code: ags
 int j = 0;
    while (j < (Game.InventoryItemCount ))
    {
      cEgo.LoseInventory(inventory[ j ]);
      j++;
    }

Khris

InventoryItem numbering starts at 1, not 0.
Plus, if the player is able to pick up more than one of one or more items, you need to remove every single one.
You can add an inner loop, or do this:
Code: ags
  int j = 1;
  while (j <= Game.InventoryItemCount)
  {
    player.InventoryQuantity[j] = 0;
    j++;
  }
  UpdateInventory();  // changing .InventoryQuantity requires manually updating the inventory GUI

selmiak

Quote from: Khris on Tue 19/01/2016 13:52:59
InventoryItem numbering starts at 1, not 0.
Wouldn't it be easy to just delete the complete inventory with
Code: ags
cEgo.LoseInventory(0);

Should I add this to the feature requests or are there possible complications?

Crimson Wizard

#4
Quote from: selmiak on Tue 19/01/2016 18:34:35
Wouldn't it be easy to just delete the complete inventory with
Code: ags
cEgo.LoseInventory(0);

Should I add this to the feature requests or are there possible complications?
LoseInventory takes pointer, not index number.
As for deleting all there should better be a separate function. Using nullpointer to delete everything is a bit counter-intuitive.


SMF spam blocked by CleanTalk