Closed Zexuz closed 7 years ago
I'd rather you replace the old GenericInventory class instead, but use it as a base-line for implementation/code-style.
So replace the old inventory class with my new one and tighty up the code?
This will mean that all FetchInventory
(http://api.steampowered.com/IEconItems_<appid>/GetPlayerItems/
) will get removed and that
Inventory GetInventory
will be the only way to fetch inventories?
Facepalm... I don't know what I was doing last night. I now see that you have a class named GenericInventory and that I was looking at the wrong Inventory.
I will fix this PR ASAP.
I now see that you have a class named GenericInventory and that I was looking at the wrong Inventory.
That's correct. I meant you should update this class to use the new endpoint for your pull request.
The GenericInventory.cs now uses the new api for fetching players inventories.
Most of the things is the same. Some of the changes are
Item GetItem(ItemDescription itemDescription)
and ItemDescription GetItemDescription(Item item)
bool onlyTradeableItems
. Set this to true and we only fetch items that has the flag trade-able set to truevar bot = StartAndConfigBot();
var inventory = new GenericInventory(new SteamID(steamid), bot.SteamWeb, new Dictionary<int, int>
{
{730, 2},
{(int) GenericInventory.AppId.PUBG, (int) GenericInventory.ContextId.PUBG},
}, true);
inventory.InventoriesLoaded += (sender, args1) =>
{
var inv = sender as GenericInventory;
Console.WriteLine($"success : {inv.Success}");
Console.WriteLine($"Inventories loaded: {string.Join(",",inv.Inventories.Keys)}"); // prints: Inventories loaded: 578080,730
};
var csInv = inventory.Inventories[730][2];
I also believe that AddForeignInventory
and FetchForeignInventory
should be removed and if you want to fetch another persons inventory, create a new GenericInventory instance.
Pull request looks great. Left some code review comments if you wanna take a look.
How/where can I see these "comments"? Never used this feature before.
You'll probably have to visit the desktop version of GitHub website. It's in-line with all these comments here on this pull request.
In your inventory. (look at this link http://steamcommunity.com/inventory/76561198045552709/570/2?l=english&count=5000 in browser)
you have two items with "classid":"848466467","instanceid":"1507031039", diffrent AssetId but same classId and instanceid. Is this a bug on steams end? I was told that instaceid + classid was unique.
this code breaks beacuse of it
public ItemDescription GetItemDescription(Item item)
{
if (item == null) return null;
return Descriptions.SingleOrDefault(itemDesc =>
itemDesc.AppId.ToString() == item.Appid &&
itemDesc.ClassId.ToString() == item.ClassId &&
itemDesc.InstanceId.ToString() == item.InstanceId
);
}
since they refer to the same ItemDescription
i will change the SingelOrDefault
to FirstOrDefault
.
That said, this seams like a bug to me.
Only assetid is unique.
Okej, well. The new code will fix that also. Since both Assets are referring to the same ItemDescription.
If there is no more problems, this should be good to be merged in.
@Zexuz there is one way you can implement tradableOnly
- the items descriptions have a tradable
property. You could perhaps filter out anything with tradable: 0
if tradableOnly
is set to true
?
Yes, but then we already have made the HTTP call. My plan was to save time and space in the HTTP call.
Now the end user can filter those out by them self.
Kinda how then need to pair Item with ItemDescription. All they have to do is inv.Item.where(item => item.tradeableOnly == true)
. Just my 2 cents
Yeah I mean it's not really a big deal, just a "nice-to-have" kind of thing.
Okey, I hear you. I might do it in the feature, but then I will create a new PR and implement some other nice things.
Thanks, merged.
Since the API for fetching CSGO items has been removed, I removed it and updated the other API (I was told that that was also an old one) with the new one.
This is a draft of what I came up with tonight. ATM there are missing some "descriptions" attributes and I don't know how to fetch the float value.
Don't know if this is something that you might be interesting in. But here it is.
Usage: