seishun / node-steam

Interface directly with Steam servers from Node.js
MIT License
1k stars 180 forks source link

gamesPlayed format #381

Closed ghost closed 8 years ago

ghost commented 8 years ago

I can guess that gamesPlayed is an array, but it is not described anywhere what is the format of that array, if I want to use it for CS:GO for example, if I use:

   steamUser.gamesPlayed({
      "game_id": "730"
    });

It doesn't work. It gives error:

.CMsgClientGamesPlayed#game_id is not a field: undefined
Efreak commented 8 years ago

So far as I know, I'm using:

steamUser.gamesPlayed({
        'games_played':[
                {'game_id':214610}
        ]
});

Unfortunately, I somehow have a confusing way of parsing what I'm doing (currently I'm passing an array of ints to this...). Somehow, one of those is working with bot.setGames(parseInt([214610,282800].toString()));.

I should probably be figuring out/fixing my own code before advising someone else...

jwigley commented 8 years ago

It's an array of game_id key/value pair objects:

steamUser.gamesPlayed([{
      "game_id": "730"
 }]);
steamUser.gamesPlayed([{
      "game_id": "730"
 },{
      "game_id": "731"
 }]);
seishun commented 8 years ago

gamesPlayed takes a CMsgClientGamesPlayed object.

The structure of protobuf objects as passed and received by node-steam is described here.

So you could call gamesPlayed like this:

user.gamesPlayed({
  games_played: [{
    game_id: '731',
    game_flags: 1234134 // god knows what this is
  }, {
    // other games
  }],
  client_os_type: 123123 // god knows what this is
});

Of course you can skip fields that are optional.

Suggestions on how the docs could be made clearer are welcome.