سؤال

I am trying to get the tags from some items but i cant find a function that give me these tags.. I am using GetPlayerItems from the steam web API to get the player items but it wont give me the item tags, what should i do?

is there a way to give me the tags?

and i have another question, is there a fast way to pull the image of the item? not by storing it on my server? i mean like an URL to the image through steam server or something..

i have tried GetSchema to find information for an item but i dont really get how it works.

thanks!

هل كانت مفيدة؟

المحلول

You need to combine two separate API calls to link the GetPlayerItems to what the data actually means.

Perform you GetPlayerItems call and return data. In the return data, you will iterate over result['items'] to get a listing of the player items.

One item in that array may look like this:

{
            "id": 493336261,
            "original_id": 493336261,
            "defindex": 5050,
            "level": 50,
            "quality": 6,
            "inventory": 2147483948,
            "quantity": 1,
            "origin": 2,
            "attributes": [
                {
                    "defindex": 195,
                    "value": 1065353216,
                    "float_value": 1.000000
                }
            ]

},

Using this data, you can use the defindex to look at the result['items'] array returned from your GetSchema call. You will have to iterate through each of those items comparing the GetPlayerItems defindex to the GetSchema defindex. When it matches you have know what the item is.

In the above case, 5050 is a Backpack Expander. You can pull the image for this item by looking at the image_url or image_url_large values on the GetSchema match.

For the "tags" that you mention, I am assuming you mean attributes. These can be matched by following a similar process, but instead matching against the GetSchema result['attributes'] array. Again, you'll have to loop through all and compare defindex values.

For the above example, the attribute with defindex = 195 matches this:

        {
            "name": "always tradable",
            "defindex": 195,
            "attribute_class": "always_tradable",
            "description_string": "#Attrib_Always_Tradable",
            "description_format": "value_is_additive",
            "effect_type": "negative",
            "hidden": true,
            "stored_as_integer": false
        },

The float_value of 1.0 in the GetPlayerItems attributes indicates that this object has that attribute. So, this backpack expander is always tradable.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top