I want my character after performing a certain action to lose every inventory item that he posses. Is it possible to do?
Thanks.
int i;
while (i < Game.InventoryItemCount) {
player.inventory[i] = 0;
i++;
}
That should do it.
Edit: Yup, ignore this and look below for the correct way. I hope it served at least as a pointer in the right direction.
.inventory is not a public member of player/character.
The property is .InventoryQuantity and IIRC inventory items start from 1 not 0, so:
int i = 1;
while (i <= Game.InventoryItemCount) {
player.InventoryQuantity[i] = 0;
i++;
}
You may also want to call UpdateInventory() at the end of the loop.
Taking it one step further you could implement an extender method such as this:
function LoseAllInventory(this Character*) {
int i = 1;
while (i <= Game.InventoryItemCount) {
player.InventoryQuantity[i] = 0;
i++;
}
UpdateInventory();
}
And then:
player.LoseAllInventory();
(See Also: import keyword in the manual :P)
Thanks Monkey.
Oddly enough I was searching the forums for the answer to this for myself, for my own game, and was directed to this newly created post. Now that's luck. :P