Closed borewik closed 12 years ago
Confirmed. The method should not always simply pick the first item in the inventory with the given defindex to the trade and search for the next item with that defindex if the first one is already in the trade.
Currently this is impossible to fix unless the items in the trade are mirrored locally in the Trade class which is currently not the case, because otherwise a trade cannot access the items in a trade.
I also have other bug/problem... don't know if i should make another topic about it. Check how much CPU does that bot eat, run 2 in parallel and its 100% (for mine pc at last). I put in function Update() just under while(true) one line: Thread.Sleep (1); That made it barley use CPU.
Yeah, this is definitely something for a seperate issue.
The bug with AddItemByDefindex
is actually not yet fixed. Please reopen.
I said before that it is impossible to fix which is partially true, because I just discovered that we do keep a list of all items in the trade, but items are only added after the the next poll. This would allow us to do a partial fix by checking in the existing list. Or we could create a new list of items that are not yet confirmed to be added.
There is also the possibility of having the bot keep track of all the items it has put in the trade, and updating its local copy on the next poll; that way, you can validate it on the spot, as there's really no chance that the local copy differs, and if it does, then the local copy takes precedence over what steam tells us (as in, we should update Steam to match our local copy of items in the trade, instead of the other way around).
Is there a way to get all the items of a certain defindex in the backpack and then get their respective ids?
@mango52 Yup. There's a method called GetItemsByDefindex
in Inventory.cs
: Link
@Philipp15b And it works? If so, why not just implement that code as part of AddItemByDefindex? It seems too obvious... EDIT: I wrote this without checking. The broken code already does what I was thinking. I'm confused as to why it doesn't work. EDIT 2: I understand now and redjazz's solution seems like the best option to me.
Is there something wrong with this? https://gist.github.com/3966611
@mango52 Almost right :smirk: See my changes in my fork.
Just a stupid mistake. Not bad for my first day in C# though, I'd say. What would happen in the Trade parameter was removed from the function and replaced with 'this' in the code? Would that not work?
Yeah, you can remove the trade parameter, just as in Java you can access parameters in functions only by their name or with a this
.
Have we checked out trade.MyOfferedItems
?
Yes. @mango52 uses it in his fix. We just have to add the changes to the Poll()
method in Trade
.
Isn't that the same as mine? Or is the null
check in foreach
s important?
It was there in the code before, so I assumed an item could be null and I checked for it. And I added a RemoveItemByDefindex
method.
If so, this would be a bug.
Yeah, but this will not work if you use AddItemByDefindex
to add multiple items in one go (which will likely happen for metal). The new items have to be added to the list when AddItem
etc. is called. What you could do then in Poll()
is validating the local list against the list from Steam.
Derp, I knew that.
Is this now fixed?
I'm not sure, I'll check it later when I have direct access to steam.
I can confirm it is fixed.
When you input this:
To any event, it will move the same item from slot 0 to slot 1, instead of adding new item of same type to slot 1.