Jump to content


Photo

[node-globaloffensive] Successive calls to GlobalOffensive.InspectItem not seeming to work

globaloffensive node node-globaloffensive inspectitem

  • Please log in to reply
3 replies to this topic

#1 TkrZ

TkrZ

    Newbie

  • Member
  • Pip
  • 3 posts

Posted 24 October 2018 - 07:47 PM

Hey there, I've currently spent today investigating and playing around with node-steam-user, and node-globaloffensive. I've have an array of inspect item links and I would like to check each of them using the InspectItem method, however my implementation seems to only send a protobuf message once, with successive calls not doing anything. It fires an 'inspectItemInfo' event once as it successfully displays the item details with.

csgo.on('inspectItemInfo', function (item) {
    console.log(`got item: paint index is ${item.paintindex} and paintwear is ${item.paintwear}`);
});

I am iterating over an items array containing the correct id, assetID and d value from the inspect link, I have validated each of these values work by manually inputting the values when calling InspectItem as they correctly give me the paint index and the wear float, however as previously mentioned it only seems to do this once, and then hangs.

 

Here is my implementation:

csgo.on('connectedToGC', function () {
    marketItemsObject.forEach(function (listing, index) {
            console.log(listing);
            
            setTimeout(() => {
                console.log(`${listing.id}`);
                csgo.inspectItem(listing.id, listing.assetID, listing.d);
            }, index * 3000);
        });
});

Many thanks for any help you may be able to give as i've been stumped on this for a few hours now.



#2 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 1,817 posts

Posted 24 October 2018 - 09:32 PM

That code looks right. You're probably being rate-limited by the GC. Valve is big on making it only possible to get data one way, then rate-limiting that one way to hell. What happens if you delay 10 seconds between items?



#3 TkrZ

TkrZ

    Newbie

  • Member
  • Pip
  • 3 posts

Posted 24 October 2018 - 11:27 PM

I've changed the structure slightly as I don't think the requests were chaining properly, i.e all being sent after the setTimeout delay, so it now uses an async promise chaining structure to repeat the request n amount of times (I plan to iterate over the size of marketItemsObject.length, but testing with just 3 requests for now).

 

I've also changed the timeout delay to between 10 and 20 seconds, however it still seems only to be only returning the first item, and either failing or not attempting the rest. As you may say this probably might be rate limiting however so i'm going to leave it until tomorrow to see if there is any sort of reset on the limit, with a much larger interval.

 

Here's the re-done code for reference

getMarketFunctionIsHere().then(function (marketItemsObject) {
        async function asyncRepeat(f, n) {
            var i = 0;
            while (n-- > 0)
                i += await f(i);
        }

        function itemFunction(i) {
            return new Promise(function (resolve, reject) {
                setTimeout(() => {
                    console.log('i is currently: %d', i);
                    console.log(marketItemsObject[i].price_gbp);
                    csgo.inspectItem(marketItemsObject[i].id, marketItemsObject[i].assetID, marketItemsObject[i].d, () => {
                        console.log("Sent an inspect item request");
                    });
                    resolve(1); // resolve 1 to be added to index
                }, 50000);
            });
        }

        asyncRepeat(itemFunction, 3).then(() => {
            console.log("Completed Inspections");
        });
    });


#4 TkrZ

TkrZ

    Newbie

  • Member
  • Pip
  • 3 posts

Posted 25 October 2018 - 05:05 PM

Update after leaving it for a day - you were correct with the rate limiting - i'm now waiting 30 seconds between each request just to be safe but it now iterates through my array and checks each item correctly, returning the pattern index and wear float :) Many thanks for your work on the node modules, it's greatly appreciated


Edited by TkrZ, 25 October 2018 - 05:06 PM.

  • Dr. McKay likes this





Also tagged with one or more of these keywords: globaloffensive, node, node-globaloffensive, inspectitem

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users