Jump to content
Returning Members: Password Reset Required ×

How to remove multiple variety of items from inventory


ownedrpd

Recommended Posts

Im trying to remove multiple items from inventory for a quest but I cannot find a way to, this is what I got so far but its not working at all..

if (client.Inventory.Contain(711306, 1) && client.Inventory.Contain(711307, 1))

{

if (client.Inventory.HaveSpace(1))

{

client.Inventory.Remove(711306, 1, stream) && client.Inventory.Remove(711307, 1, stream);

Link to comment
Share on other sites

In C# && and || are used when attempting to boolean shortcircuit. I reckon in the code above the first item 711306 is removed but the second item 711307 is not removed. You want to perform the removals in sequence on two separate lines instead:


client.Inventory.Remove(711306, 1, stream);
client.Inventory.Remove(711307, 1, stream);

When you do it in the fashion you showed above, C# will stop executing at the first truthy evaluation, and if .Remove returns truthy on the first removal (which I imagine it does in your code since rarely will you sanity check a removal), it will not bother executing the second removal.

Try the above and let me know what happens.

Link to comment
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.   Restore formatting

  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...