Hi all.
Am I missing something really obvious?
When I give a certain item to another character I want the item to disappear from my inventory.
function cBarman_UseInv()
{
if (cEgo.ActiveInventory == iNewPretzels)
{
cEgo.Say("Dialogue");
cBarman.Say("Dialogue");
cEgo.LoseInventory(iNewPretzels);
}
}
Why then, Do I still have the iNewPretzels in my inventory after this exchange (and still the ActiveInventory)?
Is there any known reason why this could be the case?
The only thing I can think of is that you have multiple copies of the item. You have probably given your character the item twice in the code before.
Yep. That's exactly what's happened.
I can't even work out how he ends up with two tokens of the item, but running cEgo.LoseInventory(iNewPretzels); twice eliminates the problem.
Thanks man :)
You should probably find the source, though :) You haven't by any chance ticked the character-starts-with-this-item for testing purposes? In case you can't find it in the code.
I still can't exactly get my head around it, but in the function where you actually get the item in the first place I have changed it from if, if, else to if, else if, else, (which is what I probably meant to do in the first place) and that seems to have done the trick :)
Well, I guess you had two conditions that both were true and both awarded the item. With the additional "else" you have made sure only one is run. Glad to hear it's solved anyway :)