Giter Site home page Giter Site logo

joshuaferrara / node-csgo Goto Github PK

View Code? Open in Web Editor NEW
455.0 39.0 79.0 36.27 MB

A node-steam plugin for Counter-Strike: Global Offensive.

License: MIT License

JavaScript 100.00%
game-coordinator javascript csgo node-steam steam counter-strike nodejs npm

node-csgo's Introduction

node-csgo

Need help? Don't open an issue - ask in the Gitter room.

Join the chat at https://gitter.im/joshuaferrara/node-csgo

Build Status Code Climate

NPM


A node-steam plugin for Counter-Strike: Global Offensive.

Based on node-dota2 by RJacksonm1

Used by

  • PopFlash - Alternative CS:GO matchmaking & PUG service.
  • CS Stats - Detailed insights and statistics for competitive CS:GO

This list is getting too long. Wanna be on it? Message me on Gitter and we'll talk. - joshuaferrara

Requirements

  • node-steam
  • CS:GO must be purchased on the account you sign in with.

Initializing

Parameters:

  • steamUser - Pass a SteamUser instance to change your current status(In-game/not).
  • steamGC - Pass a SteamGameCoordinator instance to use to send & receive GC messages.
  • debug - A boolean noting whether to print information about operations to console.
var Steam = require('steam'),
    steamClient = new Steam.SteamClient(),
    steamUser = new Steam.SteamUser(steamClient),
    steamGC = new Steam.SteamGameCoordinator(steamClient, 730),
    csgo = require('csgo'),
    CSGO = new csgo.CSGOClient(steamUser, steamGC, false);

Methods

All methods require the SteamClient instance to be logged on.

CSGO

launch()

Reports to Steam that you're playing Counter-Strike: Global Offensive, and then initiates communication with the Game Coordinator.

exit()

Tells Steam that you are not playing CS:GO.

ToAccountID(steamId)

Converts a 64 bit steam ID to an account ID.

ToSteamID(accountId)

Converts an account ID to a 64 bit steam ID.

Rank.getString(int rank_id)

Converts an integer rank_id to a string. Ex: CSGO.Rank.getString(1) = "Silver I"

Level.getString(int player_level)

Converts an integer player_level to a string. Ex: CSGO.Level.getString(1) = "Recruit"

Matches

matchmakingStatsRequest()

Sends a message to the Game Coordinator requesting some matchmaking stats. Listen for the matchmakingStatsData event for the game coordinator's response. Requires the GC to be ready (listen for the ready event before calling).

requestRecentGames()

Requests a list of recent games for the currently logged in account. Listen for the matchList event for the game coordinator's response.

requestLiveGameForUser(accountId)

Requests current live game info for given user. Listen for the matchList event for the game coordinator's response.

requestGame(string matchid, string outcomeid, int token)

Requests info about game given a matchId, outcomeId, and token for a game (Tip: These can be found with the Sharecode decoder). Listen for the matchList event for the game coordinator's response.

requestWatchInfoFriends(arguments)

Requests watchable info for game. Arguments:

int request_id; //Not enough tests yet
account_ids[array_of_csgo_accounts];//Not enough tests yet
long serverid;//ServerID of match.
long matchid;//MatchID of match.

Example:

CSGO.requestWatchInfoFriends({
  serverid: new Long(-569600767, -2130640678, true).toString(),
  matchid: new Long(39, 719230023, true).toString()
});

Requirements: game should be live.

Listen for the watchList event for the game coordinator's response.

requestCurrentLiveGames()

Requests a list of current live games. Listen for the matchList event for the game coordinator's response.

Player Info

playerProfileRequest(accountId)

accountId is the player's account ID (A player's SteamID64 can be converted to an account ID with CSGO.ToAccountID(steamid)).

Requests a player's profile from the game coordinator. The player must be online and playing CS:GO. Listen for the playerProfile event for the game coordinator's response.

Rich Presence

Note: You cannot set your rich presence to arbitrary strings anymore. Rather, games now define a list of up to 20 rich presence values that can be displayed. See the SetRichPresence method in this documentation for more info.

richPresenceUpload(richPresenceObject)

Sets the rich presence object for the currently logged in user. Rich presence is Valve's solution to giving friends information on what you're doing in a game. For example, when you see information about another friends matchmaking game (as in, the map and score), this is set by using rich presence. An example of how to use this method can be found in example.js

Item Data

itemDataRequest(string s, string a, string d, string m)

Requests item data for the specified CSGO item inspect link parameters. The parameter s has a value when the inspect link is from an inventory; likewise, the parameter m has a value when the inspect link is from the market. If there is no value for a given parameter from the inspect link, set it to "0".

Listen for the itemData event for the game coordinator's response.

Example for an inventory inspect link for a CSGO item

// steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20S76561198084749846A6768147729D12557175561287951743
CSGO.itemDataRequest("76561198084749846", "6768147729", "12557175561287951743", "0");

Example for a market inspect link for a CSGO item

// steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20M563330426657599553A6710760926D9406593057029549017
CSGO.itemDataRequest("0", "6710760926", "9406593057029549017", "563330426657599553");

Sharecode Decoding/Encoding

new CSGO.SharecodeDecoder(string code);

Instantiates a SharecodeDecoder class to decode sharecodes.

Calling the decode() method of the SharecodeDecoder will return an object with the decoded information.

console.log(new CSGO.SharecodeDecoder("CSGO-U6MWi-hYFWJ-opPwD-JciHm-qOijD").decode())

{ matchId: '3106049990460440633',
  outcomeId: '3106056003414655216',
  tokenId: '11842' }

Events

ready

Emitted when the GC is ready to receive messages. Be careful not to declare anonymous functions as event handlers here, as you'll need to be able to invalidate event handlers on an unready event.

unready

Emitted when the connection status to the GC changes, and renders the library unavailable to interact. You should clear any event handlers set in the ready event here, otherwise you'll have multiple handlers for each message every time a new ready event is sent.

exited

Emitted when .exit() is called as a convenience for clearing handlers upon intentional exits.

itemData (itemDataResponse)

{ 
    "iteminfo":
   { 
        "accountid": null,
        "itemid": Long { "low": -1821786863, "high": 1, "unsigned": true },
        "defindex": 7,
        "paintindex": 474,
        "rarity": 6,
        "quality": 4,
        "paintwear": 1054492909,
        "paintseed": 183,
        "killeaterscoretype": null,
        "killeatervalue": null,
        "customname": null,
        "stickers": [],
        "inventory": 3221225475,
        "origin": 8,
        "questid": null,
        "dropreason": null,
        "floatvalue": 0.4263376295566559 
    }
}

Emitted when the game coordinator responds to the itemDataRequest method.

matchmakingStatsData (matchmakingStatsResponse)

  • matchmakingStatsResponse - Raw response object. Example response below.
{
    "account_id": 137013074,
    "ongoingmatch": {                                       // Only populated when logged in user is in a match
        "serverid": 90112014586923017,
        "direct_udp_ip": 2734604850,
        "direct_udp_port": 27035,
        "reservationid": 18374688715512210549,
        "reservation": {
            "game_type": 520,
            "match_id": 3245263802660290728,
            "tournament_event": null,
            "pre_match_data": null
        },
        "map": "de_dust2",
        "server_address": "=[A:1:153428969:9318]:0"
    },
    "global_stats": {
        "players_online": 423480,
        "servers_online": 132472,
        "players_searching": 4212,
        "servers_available": 65497,
        "ongoing_matches": 17016,
        "search_time_avg": 46530,
        "search_statistics": [
            {
                "game_type": 264,
                "search_time_avg": 128555,
                "players_searching": 148
            },
            {
                "game_type": 520,
                "search_time_avg": 31962,
                "players_searching": 1768
            },
            {
                "game_type": 1032,
                "search_time_avg": 122353,
                "players_searching": 426
            },
            {
                "game_type": 2056,
                "search_time_avg": 136133,
                "players_searching": 160
            },
            {
                "game_type": 4104,
                "search_time_avg": 62643,
                "players_searching": 1069
            },
            {
                "game_type": 8200,
                "search_time_avg": 70380,
                "players_searching": 563
            },
            {
                "game_type": 16392,
                "search_time_avg": 115923,
                "players_searching": 132
            },
            {
                "game_type": 32776,
                "search_time_avg": 54906,
                "players_searching": 1248
            },
            {
                "game_type": 65544,
                "search_time_avg": 116871,
                "players_searching": 183
            },
            {
                "game_type": 131080,
                "search_time_avg": 82308,
                "players_searching": 145
            },
            {
                "game_type": 262152,
                "search_time_avg": 209331,
                "players_searching": 105
            },
            {
                "game_type": 524296,
                "search_time_avg": 270376,
                "players_searching": 110
            },
            {
                "game_type": 1048584,
                "search_time_avg": 64499,
                "players_searching": 1020
            },
            {
                "game_type": 268435464,
                "search_time_avg": 84615,
                "players_searching": 642
            },
            {
                "game_type": 536870920,
                "search_time_avg": 104965,
                "players_searching": 478
            },
            {
                "game_type": 2097160,
                "search_time_avg": 198734,
                "players_searching": 228
            },
            {
                "game_type": 134217736,
                "search_time_avg": 147703,
                "players_searching": 203
            },
            {
                "game_type": 8388616,
                "search_time_avg": 538828,
                "players_searching": 138
            },
            {
                "game_type": 16777224,
                "search_time_avg": 232350,
                "players_searching": 192
            },
            {
                "game_type": 4194312,
                "search_time_avg": 237269,
                "players_searching": 151
            },
            {
                "game_type": 33554440,
                "search_time_avg": 203183,
                "players_searching": 181
            }
        ],
        "main_post_url": "",
        "required_appid_version": 13494,
        "pricesheet_version": 1438240620,
        "twitch_streams_version": 2,
        "active_tournament_eventid": 6,
        "active_survey_id": 0
    },
    "penalty_seconds": null,                                // Contains amount of time logged in account has an MM cooldown
    "penalty_reason": null,                                 // Integer representing reason for MM cooldown
    "vac_banned": 0,
    "ranking": {
        "account_id": 137013074,
        "rank_id": 11,
        "wins": 192,
        "rank_change": null
    },
    "commendation": {
        "cmd_friendly": 3,
        "cmd_teaching": 3,
        "cmd_leader": 3
    },
    "medals": {
        "medal_team": 0,
        "medal_combat": 0,
        "medal_weapon": 0,
        "medal_global": 0,
        "medal_arms": 0,
        "display_items_defidx": [],
        "featured_display_item_defidx": null
    },
    "my_current_event": null,
    "my_current_event_teams": [],
    "my_current_team": null,
    "my_current_event_stages": [],
    "survey_vote": null,
    "activity": null,
    "player_level": 3,
    "player_cur_xp": 327684342,
    "player_xp_bonus_flags": null
}

Emitted when the game coordinator responds to the matchmakingStatsRequest method.

playerProfile (Response to playerProfileRequest)

{
  "request_id": null,
  "account_profiles": [
    {
      "account_id": 137013074,
      "ongoingmatch": null,
      "global_stats": null,
      "penalty_seconds": null,
      "penalty_reason": null,
      "vac_banned": null,
      "ranking": {
        "account_id": 137013074,
        "rank_id": 11,
        "wins": 192,
        "rank_change": null
      },
      "commendation": {
        "cmd_friendly": 3,
        "cmd_teaching": 3,
        "cmd_leader": 3
      },
      "medals": {
        "medal_team": 0,
        "medal_combat": 0,
        "medal_weapon": 0,
        "medal_global": 0,
        "medal_arms": 0,
        "display_items_defidx": [],
        "featured_display_item_defidx": null
      },
      "my_current_event": null,
      "my_current_event_teams": [],
      "my_current_team": null,
      "my_current_event_stages": [],
      "survey_vote": null,
      "activity": null,
      "player_level": 3,
      "player_cur_xp": 327684342,
      "player_xp_bonus_flags": null
    }
  ]
}

Emitted when the game coordinator responds to the playerProfileRequest method.

matchList (Response to requestRecentGames)

The whole response ended up being too big for the readme and caused browsers to crash. Due to this, I've only included an excerpt as to what's returned.

        {
          "reservationid": {
            "low": 65,
            "high": 715485165,
            "unsigned": true
          },
          "reservation": {
            "account_ids": [
              2879081,
              182261908,
              225695551,
              30039512,
              90132590,
              94815387,
              37671978,
              31906737,
              137013074,
              61347894
            ],
            "game_type": 1032,
            "match_id": null,
            "server_version": null,
            "rankings": [],
            "encryption_key": null,
            "encryption_key_pub": null,
            "party_ids": [],
            "whitelist": [],
            "tv_master_steamid": null,
            "tournament_event": null,
            "tournament_teams": [],
            "tournament_casters_account_ids": [],
            "tv_relay_steamid": null,
            "pre_match_data": null
          },
          "map": "http://replay124.valve.net/730/003072985384448163905_0699089210.dem.bz2",
          "round": null,
          "kills": [
            21,
            22,
            15,
            15,
            12,
            37,
            20,
            23,
            17,
            15
          ],
          "assists": [
            5,
            5,
            1,
            3,
            4,
            2,
            3,
            2,
            6,
            7
          ],
          "deaths": [
            22,
            22,
            24,
            23,
            21,
            13,
            13,
            19,
            20,
            20
          ],
          "scores": [
            55,
            54,
            40,
            39,
            37,
            79,
            65,
            59,
            41,
            37
          ],
          "pings": [],
          "round_result": null,
          "match_result": 2,
          "team_scores": [
            11,
            16
          ],
          "confirm": null,
          "reservation_stage": null,
          "match_duration": 2332,
          "enemy_kills": [
            21,
            22,
            15,
            15,
            12,
            37,
            20,
            23,
            17,
            15
          ],
          "enemy_headshots": [
            12,
            11,
            4,
            2,
            3,
            9,
            6,
            9,
            3,
            12
          ],
          "enemy_3ks": [],
          "enemy_4ks": [],
          "enemy_5ks": [],
          "mvps": [
            4,
            3,
            1,
            1,
            2,
            4,
            5,
            2,
            3,
            2
          ],
          "spectators_count": null,
          "spectators_count_tv": null,
          "spectators_count_lnk": null,
          "enemy_kills_agg": []
        }

Emitted when requestRecentGames, requestGame, requestLiveGameForUser, requestCurrentLiveGames is replied to.

watchList (Response to requestWatchInfoFriends)

Example:

{
  "request_id": 0,
  "account_ids": [],
  "watchable_match_infos": [
    {
      "server_ip": 2453839835,
      "tv_port": 28056,
      "tv_spectators": 1,
      "tv_time": 417,
      "tv_watch_password": {
        "buffer": {
          "type": "Buffer",
          "data": [ ]
        },
        "offset": 21,
        "markedOffset": -1,
        "limit": 53,
        "littleEndian": true,
        "noAssert": false
      },
      "cl_decryptdata_key": null,
      "cl_decryptdata_key_pub": {
        "low": -249571153,
        "high": 1941167002,
        "unsigned": true
      },
      "game_type": 32776,
      "game_mapgroup": "mg_de_mirage",
      "game_map": "de_mirage",
      "server_id": {
        "low": 2054631424,
        "high": 20977258,
        "unsigned": true
      },
      "match_id": {
        "low": 32,
        "high": 719254593,
        "unsigned": true
      },
      "reservation_id": null
    }
  ],
  "extended_timeout": null
}

node-csgo's People

Contributors

ammaraskar avatar cryptodescriptor avatar devsaider avatar hacktoberfest-acc avatar joshuaferrara avatar mshi avatar muratsu avatar ovr avatar rchh avatar step7750 avatar thecatontheflat avatar thesupremecommander avatar truecarry avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-csgo's Issues

How to get sharecode for a given match?

I think I've figured out how to extract the matchId and the reservationId of the last round which I assume to be the outcomeId, but I have no clue how to get the token. I dumped the entire match into a file and tried to search for token or even the token I manually extracted from one sharecode but neither found anything.

I also failed to find the sharecode encoder if such a thing exists.

Get match details from requestCurrentLiveGames

Through requestCurrentLiveGames I only can gather match_id, I would like to wait for them to wait and download its replay. Is there a way to get outcomeId and tokenId from those matches? Its easy to wait for them to end, but I don't know how to get the token or the outcome

Unable to request player profiles multiple times

I'm currently unable to request profiles for multiple players as the 'playerProfile' event only gets fired once.
This happens both when quickly requesting player profiles (in a loop) and waiting to request the next one until the previous one has been received.

EDIT: It suddenly worked.

Unable to turn json back into proto objects

I'm having a problem with turning the json response back into protos.

This worked earlier with the bundled protos in v1.5.7.

What im trying to do is to be able to create the dem.info files so that i keep the same format that downloading manually from csgo does.

So what im doing is to take the matchList response, taking out the match in that list trying to create a proto object with it.

if you check out this repo i've created a demo that showcases the error, https://github.com/ajohnsen/node-csgo-proto-encode-error

if you download that and run 'STEAM_USERNAME= STEAM_PASSWORD= npm start' it will run the demo and request a game from a sharecode. And then when the matchList response comes in it tries to create the dem.info file, but fails when trying to make the proto file.

If you take a look at works.js (run with 'npm works') this will read match.dem.info and decode it into a json object, before it turns it back into a protobuf object and writes it to a new file (new.dem.info).

You can check that these files are the same with md5

The only difference i see in the json is that the one that is not working is missing the tv_control and flags attribute from roundstatall[].reservation, and that the last roundstatall[].map is null on the working one and has the download link on the non working one.

Edit: even if i add the missing flags and make the json completely different (using JSON.strigify and comparing with jsondiff.com) i still only get the problem with one of them. Even if i do it in the same file.

The error message im getting is:
Error: Illegal value for [object Object] of type uint64: object (not convertible to Long) at line 1769 in Protobuf.js

Edit 2: From my digging around in protobuf.js it looks like its trying to read the Long value for matchId by parsing the entire json object as the long value and failing.

demo download

Hey man this looks like a sweet project. I really want some api that will let me automatically download my recent demos from matchmaking. Have you thought about adding the demo list to this?

Prime status?

Hi, would it be possible to find the prime status of a given user?

requestRecentGames is working ?

Hello !

I can't manage to make requestRecentGames working. I made this code. Is it wrong ? Or maybe Valve disable it (like the other one) ?

Thanks.

(Code)

async function getMatchesFor(steamid) {
    console.log("* sending request");
    var res_cs = csgo.requestRecentGames(steamid);
    console.log("* request method returned "+res_cs);
    while(received_matchs_infos == null) {
        console.log("* waiting because no response");
        await sleep(1000);
    }
    console.log("* got return value");
    val = received_matchs_infos;
    received_matchs_infos = null;
    return val;
}
// I use this function after receiving loggedOn event (and after connectedToGC event)

Version 1.5.13 is broken because of steam-resources

steam-resources has a prepare script in their package.json that uses svn to clone stuff on installation.

When I try to do a fresh installation without node_modules it fails to install. Not every server has svn installed on their machines...

Request game info

Do you think there's a way when we can use

message CMsgGCCStrike15_v2_MatchListRequestFullGameInfo {
    optional uint64 matchid = 1;
    optional uint64 outcomeid = 2;
    optional uint32 token = 3;
}

?
I'm trying to make it work, but I have no matches in reponse. I think outcomeid is id of last round, but I have no clue what token value should be.

node-csgo unready

I keep get this message ,
GC Connection went missing, exiting node-csgo unready

requestRecentGames game_map is always null

This is probably not an issue with node-csgo itself, but I figured this would still be the best place to post to get an answer.

The matchList response from requestRecentGames never seems to populate game_type, game_mapgroup and game_map. Is that just how it is?

It seems a bit strange considering the map names are displayed in game on the "Your Matches" page.

Thanks,


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

examples question and getting started

Hi , so I want to get started with this repo to make a website for csgo that pulls certain information from the game/player.

I'm having a hard time getting started. While the documentation on the readme is superb, there's isn't enough for someone new to get started.

I saw there was an example.js, but none of it is commented, and its using a lot of stuff not mentioned in the readme. Even when I run the example.js, after setting my username and password, it asks for an auth code, and no where in there does it specify how to get an auth code.

Basically, if I'm a web developer and all I want to do is pull off some user data what's the best way to do that, Can someone provide me with a full code snippet on something that works, so I can get started? I couldn't find any tutorials online for this specific repo.

Please don't get mad if this seems like a dumb post, I'm just trying to get started :)

gamesPlayed

Hi ! Don't know if the project is supposed to be up to date but it seems the launch of CS GO is broken :

.CMsgClientGamesPlayed.GamePlayed#games_played is not a Field

I fixed the issue changing

this._user.gamesPlayed({
    games_played: [{game_id: '730'}]
});

to

this._user.gamesPlayed([{game_id: '730'}]);

in index.js

After few hours of running bot died on connection status

I'm not sure why GCConnectionStatus is undefined, but it doesn't appearing in CSGO scope.

/home/csgo/node_modules/csgo/index.js:121
    case CSGO.GCConnectionStatus.GCConnectionStatus_HAVE_SESSION:
                                ^
TypeError: Cannot read property 'GCConnectionStatus_HAVE_SESSION' of undefined
    at CSGOClient.gcClientConnectionStatus (/home/csgo/node_modules/csgo/index.js:121:33)
    at SteamClient.fromGC (/home/csgo/node_modules/csgo/index.js:32:30)
    at SteamClient.emit (events.js:118:17)
    at SteamClient.handlers.(anonymous function) (/home/csgo/node_modules/steam/lib/handlers/game_coordinator.js:59:13)
    at SteamClient._netMsgReceived (/home/csgo/node_modules/steam/lib/steam_client.js:106:26)
    at SteamClient.handlers.(anonymous function) (/home/csgo/node_modules/steam/lib/steam_client.js:192:10)
    at SteamClient._netMsgReceived (/home/csgo/node_modules/steam/lib/steam_client.js:106:26)
    at Connection.emit (events.js:107:17)
    at Connection._readPacket (/home/csgo/node_modules/steam/lib/connection.js:50:8)

playerProfileRequest mainly returns null and readCString error

Since the start of using the 'package', I've been trying to recieve player profile information; however, all requests no matter what valid accoundID provided returns null for the majority of the fields:

{
  "request_id": null,
  "account_profiles": [
    {
      "account_id": 396346719,
      "ongoingmatch": null,
      "global_stats": null,
      "penalty_seconds": null,
      "penalty_reason": null,
      "vac_banned": null,
      "ranking": null,
      "commendation": {
        "cmd_friendly": 19,
        "cmd_teaching": 16,
        "cmd_leader": 18
      },
      "medals": {
        "medal_team": null,
        "medal_combat": null,
        "medal_weapon": null,
        "medal_global": null,
        "medal_arms": null,
        "display_items_defidx": [
          4674,
          970,
          1367
        ],
        "featured_display_item_defidx": 4674
      },
      "my_current_event": null,
      "my_current_event_teams": [],
      "my_current_team": null,
      "my_current_event_stages": [],
      "survey_vote": null,
      "activity": null,
      "player_level": 14,
      "player_cur_xp": 327681231,
      "player_xp_bonus_flags": null
    }
  ]
}

The logs return:

13 Dec 23:37:01 - Launching CS:GO
13 Dec 23:37:03 - Sending ClientHello
13 Dec 23:37:03 - CS:GO fromGC: 4004
13 Dec 23:37:03 - Received client welcome.
13 Dec 23:37:03 - Sending player profile request
13 Dec 23:37:04 - CS:GO fromGC: 9173
13 Dec 23:37:04 - CS:GO fromGC: 9128
13 Dec 23:37:04 - Received player profile

Can confirm CS GO is running, as it established a successful connection and:
ur5U


In addition, I've had the client crash to a random error:

/root/**********/node_modules/csgo/helpers/VDF.js:28
            var name = buffer.readCString();
                              ^

TypeError: buffer.readCString is not a function
    at Object.exports.decode (/root/**********/node_modules/csgo/helpers/VDF.js:28:31)
    at CSGOClient.handlers.<computed> (/root/**********/node_modules/csgo/handlers/rich_presence.js:44:20)
    at SteamClient.<anonymous> (/root/**********/node_modules/csgo/index.js:50:30)
    at SteamClient.emit (events.js:326:22)
    at SteamClient._netMsgReceived (/root/**********/node_modules/steam/lib/steam_client.js:175:10)
    at SteamClient.handlers.<computed> (/root/**********/node_modules/steam/lib/steam_client.js:262:10)
    at SteamClient._netMsgReceived (/root/**********/node_modules/steam/lib/steam_client.js:160:26)
    at Connection.emit (events.js:314:20)
    at Connection._readPacket (/root/**********/node_modules/steam/lib/connection.js:50:8)
    at Connection.emit (events.js:314:20)
    at emitReadable_ (_stream_readable.js:557:12)
    at processTicksAndRejections (internal/process/task_queues.js:83:21)

Can provide more information if needed!

playerProfile keeps the same data for every user.

Hello. Me and my friend are trying to do a simple app that would take all the steam64ids from mysql and then use the id in playerProfileRequest.

`var j = schedule.scheduleJob('*/5 * * * * *', function(){
var array = [];

con.query("SELECT * FROM counterStrikeGlobalOffensive", function (err, rows) {
	for (var i = 0; i < rows.length; i++) {
		console.log(rows[i].steam64ID);
		CSGOCli.playerProfileRequest(CSGOCli.ToAccountID(rows[i].steam64ID));
		CSGOCli.on("playerProfile", function(profile) {
			console.log(profile.account_profiles[0].ranking.rank_id);
			return;
		});
	}
});

return;
});`

This is where my problem begins. When I do console.log(rows[i].steam64ID, it returns all of the ids that are in the mysql. Then I put the id in playerProfileRequest and then when I do console.log(profile), it keeps repeating the same data for each steamid.

requestGame() returns null

var Steam = require('steam'),
    steamClient = new Steam.SteamClient(),
    steamUser = new Steam.SteamUser(steamClient),
    steamGC = new Steam.SteamGameCoordinator(steamClient, 730),
    csgo = require('csgo'),
    CSGO = new csgo.CSGOClient(steamUser, steamGC, false);

var decoded = new csgo.SharecodeDecoder("CSGO-7UvAK-FD3Ac-8DeTA-74ZUK-9Sm6J").decode();
console.log(decoded);
var requestinfo = CSGO.requestGame(decoded.matchId, decoded.outcomeId, decoded.tokenId);
console.log(requestinfo);

requestGame() returns null :(
screenshot_3

Problem with friend and playerProfileRequest

Hello

I have a problem with event friend and getting player.

My friend event:

steamFriends.on('friend', function(userId, relationship) { 
    if (relationship == 2 && !_.contains(secrets.blacklist, userId)) {
        steamFriends.addFriend(userId);

        setTimeout(function() {
            steamFriends.sendMessage(userId, 'Hello');
            setTimeout(function() {
                CSGO.playerProfileRequest(CSGO.ToAccountID(userId));
                CSGO.on("playerProfile", function(profile) {
                   steamFriends.sendMessage(userId, 'test');
                });
            }, 2000);
        }, 3000);
    }
});

and when I first time add bot he send me: Hello and test, but when I remove him and add again he send me Hello, test, test.
If I again remove and add him he send me Hello, test, test, test

Why? How can I get fix it?

Error when starting

When I do node example.js, I get the following error:

error, { eresult: 5,
eresult_extended: 5,
client_supplied_steamid: 'xxxxxxxxxxx',
count_loginfailures_to_migrate: 0,
count_disconnects_to_migrate: 0 }

playerProfile event never triggered

this is my code:

csgo.launch();
csgo.playerProfileRequest(AccountID);
csgo.on('playerProfile',function(profiles) {
	console.log("playerProfile received");
});

console never log the "playerProfile received".

About the number on richPresenceUpload

According to the console command "version", that value is the Protocol version, which (at least at the current update) is the same as the EXE version but without points.

So maybe it's required to make sure that the client is on the latest version?

Here's what the current "version" looks like:

Protocol version 13504
Exe version 1.35.0.4 (csgo)
Exe build: 17:12:46 Sep 30 2015 (6171) (730)

This is not really an issue (apart from the fact that the example is now outdated (13503 instead of 13504), just some info on the number.

Sometimes PlayerProfileRequest return ranking: null

Sometimes, i don't know why it returns this

{ request_id: null,
  account_profiles:
   [ { account_id: 152304352,
       ongoingmatch: null,
       global_stats: null,
       penalty_seconds: null,
       penalty_reason: null,
       vac_banned: null,
       ranking: null,
       commendation: [Object],
       medals: [Object],
       my_current_event: null,
       my_current_event_teams: [],
       my_current_team: null,
       my_current_event_stages: [],
       survey_vote: null,
       activity: null,
       player_level: 20,
       player_cur_xp: 327680966,
       player_xp_bonus_flags: null } ] }

Any idea why i can't get the rank ?
Ty


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

node-steam connect socket timeout

Unable to connect SteamClient to steam servers

Debug:
connecting to 162.254.196.41:27017
socket timed out
socket closed
connecting to 162.254.196.40:27020
socket timed out
socket closed

Matches array is always empty when using requestGame()

I am using this snippet for testing:

steamFriends.setPersonaState(steam.EPersonaState.Busy);

const counterstrike = new csgo.CSGOClient(steamUser, steamCoordinator, false);

counterstrike.launch();

const decode = new csgo.SharecodeDecoder(sharecode);

counterstrike.on('ready', () => {
    counterstrike.requestGame(decode.matchId, decode.outcomeId, decode.tokenId);
});

counterstrike.on('matchList', (matchResponse) => {
    console.log(JSON.stringify(matchResponse));
});

which always returns

{
  "msgrequestid": 0000,
  "accountid": 000000000,
  "servertime": 0000000000,
  "matches": [],
  "streams": [],
  "tournamentinfo": null
}

Am I doing something wrong? The matches are always very recent (A few hours ago) - so they should definitely be returned? Or am I missing something?

Cannot connect, stuck at "Sending ClientHello"

SInce the gitter chat appears to be dead, I decided to open an issue on matter.

The node steam module successfully connects and logs in, however, after CSGOClient.launch(), it is stuck in a loop constantly trying to send ClientHello, and doesn't move from there.

TypeError: Cannot read property 'send' of undefined

var Steam = require('steam'),
    steamClient = new Steam.SteamClient(),
    steamUser = new Steam.SteamUser(steamClient),
    steamGC = new Steam.SteamGameCoordinator(steamClient, 730),
    csgo = require('csgo'),
    CSGO = new csgo.CSGOClient(steamUser, steamGC, true);

module.exports.login = async (user, password) => {
    CSGO.launch();
}

29 Apr 22:18:03 - Launching CS:GO (node:4528) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'send' of undefined at SteamClient._send (C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Cyberpunk 2077\Desktop\VertBob\node_modules\steam\lib\steam_client.js:117:20) at SteamClient.send (C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Cyberpunk 2077\Desktop\VertBob\node_modules\steam\lib\steam_client.js:126:8)

Tried node V12 and V14

Stuck at Sending ClientHello

I have basically same issue as discussed in recently closed #80
When I try to launch node-csgo it gets stuck at Sending ClientHello, never firing ready event.

My code: https://pastebin.com/H9fCSubE
It's more or less just the example script.

Output:

Username: ******************
Password: ********************
31 Jan 23:59:37 - Logged in!
31 Jan 23:59:37 - Logged on.
31 Jan 23:59:37 - Launching CS:GO
31 Jan 23:59:37 - Received servers.
31 Jan 23:59:40 - Sending ClientHello
31 Jan 23:59:42 - Sending ClientHello
31 Jan 23:59:45 - Sending ClientHello
31 Jan 23:59:47 - Sending ClientHello
31 Jan 23:59:50 - Sending ClientHello
31 Jan 23:59:52 - Sending ClientHello
31 Jan 23:59:55 - Sending ClientHello
31 Jan 23:59:57 - Sending ClientHello
1 Feb 00:00:00 - Sending ClientHello
1 Feb 00:00:02 - Sending ClientHello
1 Feb 00:00:05 - Sending ClientHello
1 Feb 00:00:07 - Sending ClientHello

However node-dota2 works fine.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

How can I get infos from matches?

Hey guys,
Basicaly I want to get infos from the matches that my own cs:go servers will do... Infos like: kills, deaths, assists, etc...

I heard about that Valve let we do a request each 60 seconds to pull those infos to my website?

Thank soo much guys!

Event playerProfile problem

Hello

Im on event "friend" from node-steam call:
CSGO.playerProfileRequest(CSGO.ToAccountID(sid));
CSGO.on("playerProfile", function(profile) {
//get player profil info
}

I have a problem when check first friend is ok, but when I add second friend "playerProfile" is calling two times for first and second friend.

How can I fix it?

Cannot get watchablematchinfo from matchList

hi, when I use CSGO.requestGame(), providing all the parameter that I get from SharecodeDecoder, in the matchList response I can find the match with all the information for every round but I cannot get the watchablematchinfo like game_type, game_mapgroup, game_map because they are assigned to null.
screenshot


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

SharecodeDecoder not working

The sharecode decover is not working for me:

`

var Steam = require('steam');
var csgo = require('csgo')

var steamClient = new Steam.SteamClient();
var steamUser = new Steam.SteamUser(steamClient);
steamClient.connect();
steamClient.on('connected', function() {
steamUser.logOn({
account_name: 'redacted',
password: 'redacted'
});
});

steamClient.on('logOnResponse', function() {
steamGC = new Steam.SteamGameCoordinator(steamClient, 730);
CSGO = new csgo.CSGOClient(steamUser, steamGC, false);

console.log(CSGO.SharecodeDecoder("CSGO-U6MWi-hYFWJ-opPwD-JciHm-qOijD").decode());
});

`

this results in
image

setGameName

What's the correctly way to make a Non Steam Game visible?
I've tried:

bot.gamesPlayed(["test name", 730]);

And

bot.setGameName(["teste"]);

Still shows CS:GO as currently game running.

Implement an 'exited' event

The 'unready' event on CSGO only triggers on unexpected interruptions to the GC connection. Currently, there is no specific event that triggers on CSGO.exit().

The README may lead one to believe that it is recommended practice to remove any event listeners on the unready event -- yet, that doesn't account for intentional exits. An exited event would be ideal here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.