DoctorMcKay / node-globaloffensive

A Node.js module to connect to and interact with the CS2 game coordinator. Mostly used to get item data.
https://www.npmjs.com/package/globaloffensive
MIT License
262 stars 61 forks source link

inspectItem doesn't return anything #54

Closed middoors closed 4 years ago

middoors commented 4 years ago

Hi, I have the following code, but the csgo.inspectItem doesn't respond at all. I would really appreciate it if you could help me out:

`import { NestFactory } from '@nestjs/core'; import { AppModule } from './app.module';

const SteamUser = require('steam-user'); const GlobalOffensive = require('globaloffensive');

async function bootstrap() { const app = await NestFactory.create(AppModule, { cors: true });

await app.listen(3000);

let user = new SteamUser(); let csgo = new GlobalOffensive(user);

user.logOn({ accountName: 'myusername', password: 'mypassword', });

user.on('loggedOn', function(details) {

user.gamesPlayed(730);

csgo.on('connectedToGC', () => {

  if (csgo.haveGCSession) {
    console.log('GC is true');

    // ****** up to here is fine and works ok, but the call to inspectItem returns nothing ***********

    csgo.inspectItem(
      76561198036030455,
      19490927092,
      7667532402530609553,
      item => {
        console.log(item);
      },
    );
  }

});

});

user.on('emailInfo', function(address, validated) {

// This works fine

console.log(
  'Our email address is ' +
    address +
    " and it's " +
    (validated ? 'validated' : 'not validated'),
);

});

user.on('wallet', function(hasWallet, currency, balance) {

// This works fine

 console.log(
  'Our wallet balance is ' + SteamUser.formatCurrency(balance, currency),
);

}); } bootstrap(); `

DoctorMcKay commented 4 years ago

SteamIDs and inspect keys (the "D" number) are too big to be represented as numbers in JavaScript. The maximum integer that can be represented with guaranteed precision is 2^53.

Wrap those numbers in quotes to turn them into strings.

middoors commented 4 years ago

It worked! Thanks for the prompt reply :)

middoors commented 4 years ago

1) How can I directly use the link and feed it into inspectItem() like the following:

let owner = 'steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20S%76561198036030455%A%19484048566%D16585286310613617655'

2) another question I have is whether I can inspect multiple items at the same time?

DoctorMcKay commented 4 years ago

That's not a valid link. There should not be % around the SteamID and assetID values.

No, you can't.

middoors commented 4 years ago

that did the job thanks 👍