DoctorMcKay / node-steam-tradeoffer-manager

Simple and sane Steam trade offer management
https://dev.doctormckay.com/forum/9-node-steam-tradeoffer-manager/
MIT License
517 stars 134 forks source link

Detect items already in offers (inOffer property) #186

Open demipixel opened 7 years ago

demipixel commented 7 years ago

I'd like to know which items are already in offers when loading my inventory. It's possible to do manually (either by loading all offers when attempting to load your inventory or loading once at the beginning and keeping track via events which items are in offers and which are no longer in any offers).

So the suggestion is:

1) Load all offers on startup, save each item from the user in a dictionary 2) Offer changed events detects if an offer was changed (remove items from dictionary whether accepted or declined—not in an offer anymore) 3) When loading the user's inventory, modify the EconItem to include an inOffer boolean

Yes, it's possible to do yourself by watching newOffer, sentOfferChanged, and receivedOfferChanged, but I would imagine almost any bot (except receive-only bots) want to ensure users get different instances of the same item so trade offers for the same type of item don't clash.

andrewda commented 7 years ago

Good idea, but might be very inefficient to load all offers on startup. This should probably be an optional feature.

vankxr commented 7 years ago

How does steam handle this? Like when you open your inventory you have the in trade flag. How does steam flag this to the user ?

demipixel commented 7 years ago

@Vankxr Is there an in-trade flag? Is that new? I think (thought) Steam doesn't support this, it's just especially useful for bots.

andrewda commented 7 years ago

Nope, no official Steam in-trade flag AFAIK, though I think 3rd party extensions such as Steam Inventory Helper provide one.

DoctorMcKay commented 7 years ago

Steam doesn't do anything special to prevent you from putting the same item in multiple trades.

vankxr commented 7 years ago

Oh, stupid me. I forgot i was using steam inventory helper :(

Anyways I still agree majority of users of this module will need it.

ciwox commented 7 years ago

Just make yourself an array, and push the assetid whenever you put an item up for trade. If you get an error while the trade is being sent, just remove the assetid from the array. That's how I did it. Works pretty well.