How come inventory items still appear as a cursor and in the active inventory item window, even if the quantity of said item is 0 and I've used UpdateInventory()?
Like, cEgo picks up a bunch of carrots. so inventoryquantity is 5. He then eats 4. no problem, theres one left, its still visible in inventory and in acitive inventory. then he eats one more, and the item disappears from the inventory. but it's still there as a cursor item! and if I try to "eat" the zero quantity carrot, then the game crashes. I can work around it by using a display related to there being 0 carrots, but it's unwieldy and buggy.
what can I do?
Try using something like:
if (!player.HasInventory(player.ActiveInventory))
player.ActiveInventory = null;
Also, are you sure not trying to access player.InventoryQuantity[] with an an index below zero?
Are you using player.LoseInventory() to remove the carrots?
If you do, and removing the last one doesn't set player.ActiveInventory to null, you simply have to do it yourself.
Quote from: Khris on Wed 15/05/2013 11:07:49
Are you using player.LoseInventory() to remove the carrots?
If you do, and removing the last one doesn't set player.ActiveInventory to null, you simply have to do it yourself.
That's the baby. I'd blinded myself to using only InventoryQuantity(). Thanks.