ownedrpd Posted April 20, 2023 Posted April 20, 2023 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); Quote
Rezlind Posted April 20, 2023 Posted April 20, 2023 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.