Jump to content
McKay Development

node-globaloffensive and fetching paintwear and paintindex


punkt

Recommended Posts

Hello,

 

Firstly, thank you kindly for your sustained work!

 

I'm in a situation where I periodically need to update an account's inventory in a table, and currently I'm doing this by refreshing the inventory items in the database (delete rows + insert). 

 

Now, I need to add 'paintwear' and 'paintindex' values to all the skins in the DB and I thought it would be great to use the `inventory` property, which, according to the documentation is "An array containing the items in your inventory".

 

Adding to that, the docs also say that, using `inspectItem` for "an item your account owns is useless as all the data is already available in `inventory`."

 

However, looking at the inventory array structure, it's different from the inspectItem() results one, and I don't quite know where to go on from here. Here's the 'inventory' structure: http://pastebin.com/nHHNne35

 

Can I get paintwear & paint index from inventory alone? without the need to inspect every skin in there?

 

Are 'paintwear' and 'paintindex' attributes? If they're found in the 'valueBytes' properties inside 'attribute', I'm not sure how to handle that...

 


 

Is there any other way to get paint wear & paintindex for an account's inventory or am I stuck to inspect each skin?

 

Thank you for your help!

 

 

Link to comment
Share on other sites

It's indeed inside valueBytes. Wear is attribute 8, and I believe paintindex is attribute 7 (it might be 6 so check that one if 7 doesn't give you the expected result). Loop the attributes array till you find the attribute with the expected defindex, then call valueBytes.readFloat() to get the value as a float.

Link to comment
Share on other sites

Thanks, that did it :)

 

For anyone else looking to use node-globaloffensive.inventorry

var csgo = new GlobalOffensive(steamUser);

// assume already connected to GameCoordinator and that inventory is populated

_.forEach(csgo.inventory, (inventoryItem) => {
    _.forEach(inventoryItem.attribute, (attr) => {

        if(attr.defIndex === 7)
            inventoryItem.paintindex = attr.valueBytes.clone().readFloat();
        else if(attr.defIndex === 8)
            inventoryItem.paintwear = attr.valueBytes.clone().readFloat();

    }); 
});

also:

 

defIndex 7 is 'paint index' or 'pattern index'

defIndex 8 is 'paint wear'

Edited by punkt
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...