Git Product home page Git Product logo

node-globaloffensive's Introduction

Counter-Strike Global Offensive for Node.js

npm version npm downloads license

This module provides a very flexible interface for interacting with the CS2 Game Coordinator. It's designed to work with a node-steam-user SteamUser instance.

This is based off of node-tf2.

You will need steam-user v4.2.0 or later and Node.js v14 or later to use globaloffensive v3.
You will need steam-user v4.2.0 or later and Node.js v8 or later to use globaloffensive v2.

Setup

First, install it from npm:

$ npm install globaloffensive

Require the module and call its constructor with your SteamUser instance:

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

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

To initialize your GC connection, just launch CS:GO via SteamUser normally:

client.gamesPlayed([730]);

node-globaloffensive will emit a connectedToGC event when the game coordinator connection has been successfully established. You shouldn't try to do anything before you receive that event.

Enums

There are some enums that are used by various methods and events. You can find them in enums.js.

Properties

There are a few useful read-only properties available to you.

haveGCSession

true if we're currently connected to the GC, false otherwise. You should only call methods when we have an active GC session.

accountData

A big object containing account data and some statistics including players in-game. Undefined until accountData is emitted.

inventory

An array containing the items in your inventory. Undefined until connectedToGC is emitted.

As of v2.2.0, some special properties are populated on items in this array (and also item objects in itemAcquired and related events), where applicable:

  • position - This item's position in your inventory. If the item is new and unacknowledged, this is 0
  • custom_name - This item's custom name, applied via name tag
  • paint_index - The item's paint index
  • paint_seed - The item's paint seed
  • paint_wear - The item's paint wear, as a float (often ignorantly referred to as "float value")
  • kill_eater_value - Tracked stat value for StatTrak weapons
  • kill_eater_score_type - What type of stat is tracked for StatTrak weapons. Currently only 0 (Kills) is available.
  • quest_id
  • tradable_after - A Date object representing when this item will become tradable. May be a date in the past, as this is not removed when the date is reached.
  • stickers - An array of objects:
    • slot - The sticker slot number, 0-5
    • sticker_id
    • wear - The sticker's wear (how scratched it is), as a float. null if not scratched at all.
    • scale - Float, null if not applicable
    • rotation - Float, null if not applicable
    • tint_id
    • offset_x - Float, null if not applicable
    • offset_y - Float, null if not applicable
  • casket_id - If this item is contained in a casket (storage unit), this is a string containing that casket's item ID
  • casket_contained_item_count - If this item is a casket (storage unit), this is a count of how many items it contains

Note that if any of the above attributes are not applicable, then they will not exist in the item object.

It appears that under some circumstances, the GC might load items from storage units into your inventory without calling getCasketContents, so if you are using this property to see what items are in your inventory, you will need to check casket_id to filter out items stored in storage units.

Methods

Constructor(steamClient)

When instantiating your node-globaloffensive instance, you need to pass your active Steam.SteamClient instance as the sole parameter, as shown here:

var csgo = new GlobalOffensive(steamClient);

requestGame(shareCodeOrDetails)

  • shareCodeOrDetails - Either a share code as a string, or an object containing properties matchId, outcomeId, token

v2.2.0 or later is required to use this method

Requests stats for a historical game. Listen for the matchList event to get your response.

requestLiveGames()

Request a list of current live tournament games. This is the list you see in the client under Watch -> Live. Listen for the matchList event to get your response.

requestRecentGames(steamid)

Request a list of recent games (max. 8). This is the list you see in the client under Watch -> Your Matches. Listen for the matchList event to get your response.

requestLiveGameForUser(steamid)

Request live game info for a specific user. Listen for the matchList event to get your response.

inspectItem(owner[, assetid][, d][, callback])

  • owner - The numeric SteamID or market listing ID of the owning Steam account or market listing, as a string; or an entire inspect link.
  • assetid - If owner is not an entire inspect link, this is the numeric asset ID of this item, as a string
  • d - If owner is not an entire inspect link, this is the "D" number from the inspect link (the last number following the "D" character)
  • callback - Optional. Called if all parameters are valid when Steam responds to us.
    • item - An object containing the item's data
      • accountid - Seems to always be null
      • itemid - The item's asset ID, as a string
      • defindex - The item's definition index
      • paintindex - The item's paint index
      • rarity - The item's numeric rarity
      • quality - The item's numeric quality
      • paintwear - The item's paint wear percentage, as a float between 0 and 1 (frequently and incorrectly called "float value")
      • paintseed - The item's paint seed
      • killeaterscoretype - What kind of statistic the StatTrak version of this item tracks (may be null if not StatTrak)
      • killeatervalue - The item's tracked statistic value (kills)
      • customname - The item's custom name via a name tag, or null if none
      • stickers - An array of objects describing the stickers applied to this item
        • slot - What slot this sticker is applied to
        • sticker_id - The ID of this type of sticker
        • wear - Either null (not scratched) or a float between 0 and 1 describing how much this sticker has been scratched
        • scale - This property is only not null on the early dreamhack 2013 stickers. It is no longer used.
        • rotation - This property is only not null on the early dreamhack 2013 stickers. It is no longer used.
        • tint_id
        • offset_x - Float, null if not applicable
        • offset_y - Float, null if not applicable
      • inventory - An integer which has no use to you
      • origin - The numeric origin of this item
      • questid - You can ignore this
      • dropreason
      • musicindex
      • entindex

v1.1.0 or later is required to use this method

Sends the same request to the GC that the official client sends when you inspect an item. If all parameters are correct and the GC is in a good mood, returns the item's data. Using this for an item your account owns is useless as all the data is already available in inventory.

The response will arrive in the callback and in the inspectItemInfo event.

As of v2.1.0, the request will time out if no response is received in 10 seconds. If this happens, inspectItemTimedOut will be emitted.

requestPlayersProfile(steamid[, callback])

  • steamid - The numeric SteamID of the Steam account to pull profile data for. Needs to be playing CSGO and be on the friend list of the requesting account.
  • callback - Optional. Called if all parameters are valid when Steam responds to us.
    • profile - An object containing the profiledata
      • account_id - Steam account id
      • ongoingmatch
      • global_stats - Seems to always be null
      • penalty_seconds
      • penalty_reason
      • vac_banned
      • ranking
        • account_id
        • rank_id - Rank (0-18), starting at 0 for unranked
        • wins - Number of wins
        • rank_change - Seems to always be null
        • rank_type_id - Rank type (6: Matchmaking, 7: Wingman, 10: Danger Zone)
      • commendation
        • cmd_friendly - The number of "friendly" commendations the account has received
        • cmd_teaching - The number of "teaching" commendations the account has received
        • cmd_leader - The number of "leader" commendations the account has received
      • medals - Achievement medals, their ranks and coins
        • medal_team
        • medal_combat
        • medal_weapon
        • medal_global
        • medal_arms
        • display_items_defidx - Array of coins
        • featured_display_item_defidx
      • my_current_event
      • my_current_event_teams
      • my_current_team
      • my_current_event_stages
      • survey_vote
      • activity
      • player_level - Private rank level
      • player_cur_xp - Current XP, starting at 327680000 (level % = (player_cur_xp - 327680000) / 5000)
      • player_xp_bonus_flags - Seems to always be null
      • rankings - Array of ranking infos
        • account_id
        • rank_id - Rank (0-18), starting at 0 for unranked
        • wins - Number of wins
        • rank_change - Seems to always be null
        • rank_type_id - Rank type (6: Matchmaking, 7: Wingman, 10: Danger Zone)

v1.2.0 or later is required to use this method

Sends the same request to the GC that viewing the CSGO player profile from the in-game friendlist sends. Returns the same information that you would get in-game. This returns the same protobuf that is used when you request your own profile data, so most of it stays empty.

nameItem(nameTagId, itemId, name)

  • nameTagId - The ID of the name tag you want to consume to do this
  • itemId - The ID of the item you want to rename
  • name - A string containing the item's new name

v2.1.0 or later is required to use this method

Renames a particular item in your inventory, using a given name tag. You can rename storage units for free by passing 0 as the nameTagId.

craft(items, recipe)

  • items - An array of item IDs to craft
  • recipe - An integer indicating which crafting recipe to use

v2.3.0 or later is required to use this method

Craft items together into a new item using a specific recipe. items should be an array of item IDs to craft. You will receive a craftingComplete event in response. If crafting succeeded, you will also get itemRemoved events for each item you spent, and itemAcquired events for each item you received.

Recipes are defined in items_game.txt. Available recipes as of late 2022 are:

  • 0 = Trade-Up: 10x Consumer Grade → 1x Industrial Grade
  • 1 = Trade-Up: 10x Industrial Grade → 1x Mil-Spec Grade
  • 2 = Trade-Up: 10x Mil-Spec Grade → 1x Restricted
  • 3 = Trade-Up: 10x Restricted → 1x Classified
  • 4 = Trade-Up: 10x Classified → 1x Covert
  • 10 = Trade-Up: 10x StatTrak Consumer Grade → 1x StatTrak Industrial Grade
  • 11 = Trade-Up: 10x StatTrak Industrial Grade → 1x StatTrak Mil-Spec Grade
  • 12 = Trade-Up: 10x StatTrak Mil-Spec Grade → 1x StatTrak Restricted
  • 13 = Trade-Up: 10x StatTrak Restricted → 1x StatTrak Classified
  • 14 = Trade-Up: 10x StatTrak Classified → 1x StatTrak Covert

deleteItem(itemId)

  • itemId - The ID of the item you want to delete

1.3.0 or later is required to use this method

Deletes a particular item from your inventory. This is a destructive operation, which cannot be undone.

addToCasket(casketId, itemId)

  • casketId - The ID of the casket (storage unit) you want to put an item into
  • itemId - The ID of the item you want to put into the casket

v2.1.0 or later is required to use this method

Put an item in your inventory into a casket (storage unit) you own. Assuming the request succeeds, itemRemoved will be emitted for the item that was put into the casket, and itemCustomizationNotification will be emitted with notification type CasketAdded for the casket.

removeFromCasket(casketId, itemId)

  • casketId - The ID of the casket (storage unit) you want to remove an item from
  • itemId - The ID of the item you want to remove from the casket

v2.1.0 or later is required to use this method

Remove an item from a casket (storage unit) you own and put it into your inventory. Assuming the request succeeds, itemAcquired will be emitted for the item that was removed from the casket, and itemCustomizationNotification will be emitted with notification type CasketRemoved for the casket.

getCasketContents(casketId, callback)

  • casketId - The ID of the casket (storage unit) you want to get the contents of
  • callback - A function to be called once the contents are loaded
    • err - An Error object on failure, or null on success
    • items - An array of item objects, the same structure as objects in inventory

v2.1.0 or later is required to use this method

Loads the contents of a storage unit. Note that calling this will have the GC load the contents of the storage unit using the same mechanism as your actual inventory, so items in the storage unit will appear in the inventory property, and itemAcquired will be emitted for each item. Each item in your inventory that is contained inside of a storage unit has a property casket_id, the value of which is a string containing the ID of the storage unit that contains that item.

It appears that under some circumstances, the GC might load these items into your inventory without calling this method, so if you are using inventory to see what items are in your inventory, you will need to check casket_id to filter out items stored in storage units.

Events

connectedToGC

Emitted when a GC connection is established. You shouldn't use any methods before you receive this. Note that this may be received (after it's first emitted) without any disconnectedFromGC event being emitted. In this case, the GC simply restarted.

disconnectedFromGC

  • reason - A value from the GCConnectionStatus enum

Emitted when we're disconnected from the GC for any reason. node-globaloffensive will automatically try to reconnect and will emit connectedToGC when reconnected.

Example usage:

const GlobalOffensive = require('globaloffensive');
let csgo = new GlobalOffensive(steamUser);

csgo.on('disconnectedFromGC', (reason) => {
    if (reason == GlobalOffensive.GCConnectionStatus.GC_GOING_DOWN) {
        console.log('GC going down');    
    }
});

error

  • err - An Error object

Emitted when we encounter a fatal error attempting to connect to the GC. If this event is not handled, the app will crash.

connectionStatus

  • status - A value from the GCConnectionStatus enum
  • data - The raw data that was received

Emitted when we receive the status of our connection to the GC. Exactly when this is emitted is currently unknown. This may be removed in the future.

matchList

  • matches - An array of matches
  • data - The raw data that was received

Emitted when we receive a match list, especially after a requestLiveGames() call. This may be emitted at other times. Presently, the exact behavior is unknown.

inspectItemInfo

  • item - An object containing the item's data
    • accountid - Seems to always be null
    • itemid - The item's asset ID, as a string
    • defindex - The item's definition index
    • paintindex - The item's paint index
    • rarity - The item's numeric rarity
    • quality - The item's numeric quality
    • paintwear - The item's paint wear percentage, as a float between 0 and 1 (frequently and incorrectly called "float value")
    • paintseed - The item's paint seed
    • killeaterscoretype - What kind of statistic the StatTrak version of this item tracks (may be null if not StatTrak)
    • killeatervalue - The item's tracked statistic value (kills)
    • customname - The item's custom name via a name tag, or null if none
    • stickers - An array of objects describing the stickers applied to this item
      • slot - What slot this sticker is applied to
      • sticker_id - The ID of this type of sticker
      • wear - Either null (not scratched) or a float between 0 and 1 describing how much this sticker has been scratched
      • scale - Always null?
      • rotation - Always null?
      • tint_id
      • offset_x - Float, null if not applicable
      • offset_y - Float, null if not applicable
    • inventory - An integer which has no use to you
    • origin - The numeric origin of this item
    • questid - You can ignore this
    • dropreason
    • musicindex
    • entindex

v1.1.0 or later is required to use this method

Emitted in response to an inspectItem() call.

inspectItemTimedOut

  • assetid - The asset ID of the item we attempted to inspect

v2.1.0 or later is required to use this method

Emitted if inspectItem() is called but we don't receive a timely reply to the request.

itemAcquired

  • item - The item that you received

Emitted when you receive a new item.

itemChanged

  • oldItem - The item's previous state
  • item - The item's new state

Emitted when an item in your inventory changes in some way.

itemRemoved

  • item - The item that you lost

Emitted when an item is removed from your inventory.

itemCustomizationNotification

  • itemIds - An array of item IDs (as strings) to which something happened
  • notificationType - A value from the ItemCustomizationNotification enum

v2.1.0 or later is required to use this event

Emitted when the GC informs us that an item is customized somehow. Example:

const GlobalOffensive = require('globaloffensive');
let csgo = new GlobalOffensive(steamUser);

csgo.on('itemCustomizationNotification', (itemIds, notificationType) => {
    if (notificationType == GlobalOffensive.ItemCustomizationNotification.CasketInvFull) {
        console.log('Storage unit ' + itemIds[0] + ' is full');
    }
});

craftingComplete

  • recipe - The ID of the recipe that was used to perform this craft, or -1 on failure
  • itemsGained - An array of IDs of items that were gained as a result of this craft

v2.3.0 or later is required to use this event

Emitted when a craft initiated by the craft method finishes.

playersProfile

  • profile - An object containing the profile data
    • account_id - Steam account id
    • ongoingmatch
    • global_stats - Seems to always be null
    • penalty_seconds
    • penalty_reason
    • vac_banned
    • ranking
      • account_id
      • rank_id - Rank (0-18), starting at 0 for unranked
      • wins - Number of wins
      • rank_change - Seems to always be null
      • rank_type_id - Rank type (6: Matchmaking, 7: Wingman, 10: Danger Zone)
    • commendation
      • cmd_friendly - The number of "friendly" commendations the account has received
      • cmd_teaching - The number of "teaching" commendations the account has received
      • cmd_leader - The number of "leader" commendations the account has received
    • medals - Achievement medals, their ranks and coins
      • medal_team
      • medal_combat
      • medal_weapon
      • medal_global
      • medal_arms
      • display_items_defidx - Array of coins
      • featured_display_item_defidx
    • my_current_event
    • my_current_event_teams
    • my_current_team
    • my_current_event_stages
    • survey_vote
    • activity
    • player_level - Private rank level
    • player_cur_xp - Current XP, starting at 327680000 (level % = (player_cur_xp - 327680000) / 5000)
    • player_xp_bonus_flags - Seems to always be null
    • rankings - Array of ranking infos
      • account_id
      • rank_id - Rank (0-18), starting at 0 for unranked
      • wins - Number of wins
      • rank_change - Seems to always be null
      • rank_type_id - Rank type (6: Matchmaking, 7: Wingman, 10: Danger Zone)

Emitted in response to an requestPlayersProfile() call.

node-globaloffensive's People

Contributors

blackcetha avatar doctormckay avatar iceq1337 avatar rob-- avatar sapphyrus avatar thewilhelmscream avatar wavpro avatar yaroslav-95 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

node-globaloffensive's Issues

GOTV

Is the ability to watch gotv through this script; d?

What for an ID do I need?

Hey...

I'm just trying out a bit. What for an steamID do I need? Tried it with the normal one STEAM_0:0:xxxxx and the steamID64

If I remove the STEAM_0:0: I get an TypeError:

/root/node_modules/globaloffensive/index.js:161
if (!steamid.isValid() || steamid.universe != SteamID.Universe.PUBLIC || steamid.type != SteamID.Type.INDIVIDUAL || steamid.instance != SteamID.Instance.DESKTOP) {
^

TypeError: steamid.isValid is not a function
at GlobalOffensive.requestRecentGames (/root/node_modules/globaloffensive/index.js:161:15)
at GlobalOffensive.csgo.on (/root/node_modules/csgobot/index.js:29:22)
at GlobalOffensive.emit (events.js:198:13)
at GlobalOffensive.handlers.(anonymous function) (/root/node_modules/globaloffensive/handlers.js:50:7)
at SteamUser.GlobalOffensive._steam.on (/root/node_modules/globaloffensive/index.js:51:12)
at SteamUser.emit (events.js:198:13)
at SteamUser. (/root/node_modules/steam-user/components/gamecoordinator.js:82:8)
at handlers.forEach (/root/node_modules/steam-user/components/classes/HandlerManager.js:37:12)
at Array.forEach ()
at HandlerManager.emit (/root/node_modules/steam-user/components/classes/HandlerManager.js:36:12)

Avoid event listeners leak

Bug Description

If somehow the server won't respond to an in-game item query (via inspectItem), there will be a inspectItem#<item-id> event listener leak.

If you send the inspect requests too frequently or send invalid requests, the server will ignore some of the requests, i.e. the server may never respond to some specific requests. This will cause a event listener leak until the same item is finally "inspected" again successfully.

requestLiveGameForUser

Hi, while requesting game info while in a competetive game by doing

csgo.requestLiveGameForUser('76561198400109811')

and listening on

csgo.on('matchList', (data) => {
    console.log(data)
})

I don't get any data in the listener. Am I requesting it wrong or did something break recently?

How can I reconnect to the gc?

After ~10 hours the Bot lost the connection to the GC.

How can I reconnect?

I tried it like this:

if ( csgo.haveGCSession ) {
    some code...
} else {
      log("Connection lost, trying to reconnect.");
      csgo.on("connectedToGC", function() {
    some code...
});
 };

But I wasn't succesful with that, am I doing something wrong?

How to get "D" numbers automatically?

This is my code:

csgo.inspectItem(steamID, assetID, d, (item) => {
    console.log(item.paintwear);
  })

My question is, can I somehow get the "d" numbers automatically instead of manually finding the inspect link and copy the "d" numbers from the link?

requestRecentGames

Is it possible to request recent games of other players than yourself? If so how?

Code used to test:

this.csgo.requestRecentGames(accountID)
let recentGames = await new Promise(resolve => {
    this.csgo
        .on('matchList', (matches, data) => {
            if (data.accountid !== accountID.accountid) return
            return resolve(matches)
        })
})

TypeError: this._send is not a function

Hey, I'm using promisify and get the TypeError: this._send is not a function
The Error only happens with const ranking = await requestPlayersProfile(account_id);

Does anyone have any ideas why it is not working?

Snippet:

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

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

const { promisify } = require('util');
const requestPlayersProfile= promisify(csgo.requestPlayersProfile);
const getConnection = promisify(pool.getConnection);

const query = (connection, sql, args) => new Promise((resolve, reject) => {
    connection.query(sql, args, err => {
        connection.release();
        if (err) {
            reject(err);
        } else {
            resolve();
        }
    });
});
if ( csgo.haveGCSession ) {
    pool.getConnection(function(err, connection) {
        if (err) throw err;
        connection.query("SELECT * FROM Users", function (err, rows, fields) {
        connection.release();
        if (err) throw err;
                async function doit() {
                for (let row of rows) {
                    var account_id = new SteamID(`${row.SteamID64}`);

                    csgo.setMaxListeners(50);
                    const ranking = await requestPlayersProfile(account_id);
                    var rankid = ranking.ranking.rank_id;

                        //Convert MM rankid
                        if (rankid == 0) {
                            var rank = "Unranked";
                        } else if (rankid == 1) {
                            var rank = "Silver 1";
                        }  else if (rankid == 2) {
                            var rank = "Silver 2";
                        } else if (rankid == 3) {
                            var rank = "Silver 3";
                        } else if (..) {
                            ..
                        } else if (rankid == 18) {
                        var rank = "Global Elite";
                        } 
                    const connection = await getConnection();
                    await query(connection, "UPDATE Users SET CSGOMM=? WHERE SteamID64=?", [rank, `${row.SteamID64}`]);
                }
                }
                doit().catch(err => console.error(err));
        });
    });
};

Competitive Cooldown Expiration

Greetings to all who know how to get "Competitive Cooldown Expiration", I looked at the protobufs but did not find anything like it.

How to get the floats of another user's inventory?

So right now im using steamcommunity to get another user's inventory. From there im using a map of the array to get the inspect link as shown below,

inventory.map(function(item)
    var inspectURL = JSON.stringify(item['actions'][0]['link'])
    var d = inspectURL.split("D").pop().slice(0, -1);
    var assetID = item['assetid'];
    var itemID = item['id'];
    var apiURL = ('steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20S' + steamID64 + 'A' + assetID + 'D' + d)
})

However im stumped when it comes to having it loop through the array. I get maybe 2 at most with a for item in inventory loop but that the best i get... Any help would be appreciated.

Crash when ranking.ranking.rank_id = NULL

My bot is crashing when it wants to check a profile, who didn't got a csgo rank.

How can I prevent that?

Some of my code:

csgo.setMaxListeners(50);
csgo.requestPlayersProfile(account_id, function(ranking) {

var rankid = ranking.ranking.rank_id;
var wins = ranking.ranking.wins;
var private = ranking.player_level;

if (rankid == 0) {
      var rank = "Unranked";
} else if (rankid == 1) {
      var rank = "Silver 1";
}  else if (rankid == 2) {
      ...
} else {
      var rank = "";
}

"Crash":

Got handled GC message PlayersProfile
/root/node_modules/csgobot/standalone.js:144
                var rankid = ranking.ranking.rank_id;
                                             ^

TypeError: Cannot read property 'rank_id' of null
    at GlobalOffensive.<anonymous> (/root/node_modules/csgobot/standalone.js:144:46)
    at Object.onceWrapper (events.js:286:20)
    at GlobalOffensive.emit (events.js:198:13)
    at GlobalOffensive.handlers.(anonymous function) (/root/node_modules/globaloffensive/handlers.js:98:7)
    at SteamUser.GlobalOffensive._steam.on (/root/node_modules/globaloffensive/index.js:51:12)
    at SteamUser.emit (events.js:198:13)
    at SteamUser.<anonymous> (/root/node_modules/steam-user/components/gamecoordinator.js:82:8)
    at handlers.forEach (/root/node_modules/steam-user/components/classes/HandlerManager.js:37:12)
    at Array.forEach (<anonymous>)
    at HandlerManager.emit (/root/node_modules/steam-user/components/classes/HandlerManager.js:36:12)

Bug

this.emit('disconnectedFromGC', TeamFortress2.GCGoodbyeReason.NO_SESSION); <- ReferenceError: TeamFortress2 is not defined
globaloffensive/index.js:75:36

Get item's name in inventory

The items don't have any attribute for name or anything that indicates which item it is. Is it possible to get that somehow?

connect to GC while locally running CSGO?

Can you connect to the CSGO GC using this and do some storage unit stuff while still actually running CSGO locally, and have the storage unit changes be present in both the local CSGO and the NodeJS CSGO?

Make a purchase key

Is it possible to use this library to make in-game purchases, such as the keys cases?

Bug ?

If i login account, and this account logout and disconnectedFromGC with reason 2 (NO_SESSION), steam-user login again this account, but i not get connectedToGC :/

No GC response

CSGO was launched on the account ; it is level 2 in-game.

Logging in to Steam...
Logged in to Steam as [some SteamID]
Connecting because we're playing CS:GO
Sending GC message ClientHello
Sending hello, setting timer for next attempt to 2000 ms
Sending GC message ClientHello
Sending hello, setting timer for next attempt to 4000 ms
# etc.

Here's the entire source code :
https://gist.github.com/kiwec/48dc3a12bd1b31064ad7037ca982cc37

Any ideas as to why it doesn't work ?

How can I get the LiveGame?

I want to get the live game of a specific steam user.
With csgo.requestLiveGameForUser(account_id) I get:

Sending GC message MatchListRequestLiveGameForUser
Got unhandled GC message 9173
Got handled GC message MatchmakingGC2ClientHello
Got unhandled GC message 9194
Got unhandled GC message 9173
Got handled GC message MatchList

But how can I see the data, that I received from the GC?

Get the image url of a stickerid on an item.

In the inspectItem() output I get an array with the stickers.

  stickers: 
   [ { slot: 0,
       stickerId: 358,
       wear: null,
       scale: null,
       rotation: null,
       tintId: null },
     { slot: 2,
       stickerId: 965,
       wear: null,
       scale: null,
       rotation: null,
       tintId: null },
     { slot: 3,
       stickerId: 356,
       wear: null,
       scale: null,
       rotation: null,
       tintId: null } ],

How can i turn the stickerid to an image of the sticker? Or is there any other way to get the image urls of the stickers?

server_id

What exactly is server_id in matchList (requestLiveGameForUser)? Should it be server's steamid? If so, it has wrong value or it's some kind of conversion problem:

FULLY CONNECTED!!
[
{
roundstatsall: [],
matchid: '3386139258250068207',
matchtime: null,
watchablematchinfo: {
server_ip: null,
tv_port: null,
tv_spectators: 0,
tv_time: 1998,
tv_watch_password: null,
cl_decryptdata_key: null,
cl_decryptdata_key_pub: null,
game_type: 32776,
game_mapgroup: 'mg_de_mirage',
game_map: 'de_mirage',
server_id: '9295711545907311873',
match_id: '3386139258250068207',
reservation_id: null
},
roundstats_legacy: {
kills: [Array],
assists: [Array],
deaths: [Array],
scores: [Array],
pings: [],
team_scores: [Array],
enemy_kills: [],
enemy_headshots: [],
enemy_3ks: [],
enemy_4ks: [],
enemy_5ks: [],
mvps: [Array],
enemy_kills_agg: [],
reservationid: null,
reservation: [Object],
map: null,
round: null,
round_result: null,
match_result: null,
confirm: null,
reservation_stage: null,
match_duration: 1909,
spectators_count: null,
spectators_count_tv: null,
spectators_count_lnk: null,
drop_info: null
}
}
]

example server's SteamID:

[A:1:1117543424:13807]
90131294278409216

I'm just a begginer, I will be grateful if you could explain it to me.
Thanks!

Can't load full inventory of floats

Hello,
I've been having a weird problem. I tried looping through the user inventory (not my own) and getting the floats but it only returns one item.
Also I tried to queue the requests like this:

Init.prototype.getDetails = function(inventory,index,callback)
{
	var _self = this;
	for(var i = index; i < inventory.length; i++)
	{
		if(inventory[i].inspect === "none") continue;
		else
		{
			var index = i;
	_self.instances.globalOffensive.inspectItem(inventory[index].inspect,undefined,undefined,function(item){
				console.log(item);
				_self.getDetails(inventory,index+1,callback);
			});
			break;
		}

	}
}

But that loads 3 items and stops. The callback is not getting called anymore. How do I correctly fetch all floats,paint seeds etc from an inventory?

Removal of stickers from weapons by means of API

Hello, dear DoctorMcKay and all readers.
Is there a way to remove stickers from the skin by API, if not, will it be implemented?
This feature would greatly facilitate the life of me and not only.

Thank you for your attention and your work. :-*

Unable to initialize GC connection

const Steam = require('steam-client'),
        cmclient = new Steam.CMClient()

  const steamuser = require('steam-user'),
        steamcommunity = require('steamcommunity'),
        globaloffensive = require('globaloffensive')

  const community = new steamcommunity(),
        client = new steamuser(cmclient),
        csgo = new globaloffensive(client)

I am unable to initialize GC connection this way.

Sending multiple 'requestPlayersProfile'

My current script looks like this:

const SteamUser = require('steam-user');
const SteamTotp = require('steam-totp');
const GlobalOffensive = require('globaloffensive');
const config = require('./config');
const db = require('./database');

var SteamID = require('steamid');
var mysql = require('mysql');

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

csgo.on('debug', console.log);
user.on('error', console.error);

var pool  = mysql.createPool({
  supportBigNumbers: true,
  bigNumberStrings: true,
  connectionLimit: 10,
  host: db.host,
  user: db.user,
  password: db.password,
  database: db.dbname
});

const logInOptions = {
  accountName: config.accountName,
  password: config.password
}

user.logOn(logInOptions);

user.on('loggedOn', res => {
  console.log("Logged into Steam as " + user.steamID.getSteam3RenderedID());

  user.setPersona(SteamUser.EPersonaState.Online);
  user.gamesPlayed(730);

});

csgo.on("connectedToGC", function() {
    console.log("connectedToGC");
    const checkData = setInterval(()=>{

    //Check connection to game coordinator
    if ( csgo.haveGCSession ) {

      //Check Database
      pool.getConnection(function(err, connection) {
        if (err) throw err;
        connection.query("SELECT * FROM Users WHERE (MainSteamGroup = '1' || CommunitySteamGroup = '1' || vip = '1') && BotInFriendlist = '1'", function (err, rows, fields) {
          connection.release();
          if (err) throw err;
          rows.forEach( (row) => {
            var account_id = new SteamID(`${row.SteamID64}`);

            //Request Data from CS:GO
            csgo.requestPlayersProfile(account_id, function(data) {
                console.log(data);
                console.log("before");
                setTimeout(function(){
                    //do what you need here
                }, 2000);
                console.log("after");
            });

            //I have no idea
            csgo.on("playersProfile", function(data) {
                console.log("Profile gotten");
            });
          });
        });
      });
    };
  }, 10000);
});

The script is sending multiple "GC message ClientRequestPlayersProfile" but only one is returning(?).
After the loop it starts again with only the first SteamID.

What do I have to change to send multiple requests in a row with this setup?

New function

You can add: sendCommend

this._send(Language.ClientCommendPlayer, Protos.CMsgGCCStrike15_v2_ClientCommendPlayer, {
accountId: steamid.accountid,
matchId: 8,
tokens: 10,
commendation: {
cmdFriendly: 1,
cmdTeaching: 2,
cmdLeader: 4
}
});

AND sendReport

this._send(Language.ClientReportPlayer, Protos.CMsgGCCStrike15_v2_ClientReportPlayer, {
accountId: steamid.accountid,
matchId: matchID ? matchID : 8,
rptAimbot: 2,
rptWallhack: 3,
rptSpeedhack: 4,
rptTeamharm: 5,
rptTextabuse: 6,
rptVoiceabuse: 7
});

Inconsistent availability state

Problem description

The documentation requires users try to do nothing before receiving the connectedToGC event. At the same time it requires users to call methods only when the haveGCSession is true.

However, I noticed that I can actually send item inspect queries and receive responses from the server when haveGCSession is false.

Now I have to explain why my haveGCSession property is false and that's actually another issue:

I called user.gamesPlayed(730) for the first time, and received connectedToGC event as expected. I checked the haveGCSession property, it was also true as expected. Later, I called user.gamesPlayed([]), the disconnectedFromGC event did not fired but haveGCSession became false. I also called inspectItem after that, no response received (that is what I expected). Finally, I called user.gamesPlayed(730) again and:

  1. No connectedToGC event fired
  2. haveGCSession was still false

I was confused, so I called inspectItem to see what would happen, and I received responses to the inspect query.

Also, there could be a connection leak caused by the aforementioned operation sequence as mentioned here.

Cannot read property 'on' of undefined

i have problem with event 'inspectItemInfo'

csgo.on('inspectItemInfo',function(item){
^

TypeError: Cannot read property 'on' of undefined
at Object. (D:\SteamGuard\Bot\test.js:149:5)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:393:7)
at startup (bootstrap_node.js:150:9)
at bootstrap_node.js:508:3

How to check the float?

I created js file in which I registered this:

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

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

user.logOn({
"accountName": "...",
"password": "..."
});
user.on('loggedOn', function(details) {
console.log("Logged into Steam as " + user.steamID.getSteam3RenderedID());
user.setPersona(SteamUser.EPersonaState.Online);
user.gamesPlayed(730);
csgo.inspectItem('steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20S76561198334769752A16578240883D14421726855138953619')
user.logOff();
});

Why can't I get float?

[Question] Entering Steam Code before fetching data

I'm currently using Express to run the node-globaloffensive module for my app. Every time I sign in, it'll ask me for my steam code and once I entered it, it'll take a long time to load and my web app will timeout. How do I efficiently enter steam code without causing my web app to crash?

user.on("loggedOn", function(details) {
  console.log("Logged into Steam as " + user.steamID.getSteam3RenderedID());
  user.setPersona(SteamUser.EPersonaState.Online);
  user.gamesPlayed([730]);
  console.log("Done setting Games Played");
});

user.on("steamGuard", function(domain, callback) {
  console.log("Steam Guard code needed from email ending in " + domain);
  router.post("/", function(req, res) {
    console.log(`SteamGuard: ${req.body.steam_guard}`);
    callback(req.body.steam_guard);
  });
});

get item names from storage unit?

hello,
i use node steamcommunity to fetch inventory but is there a way i can get items in storage units with their names?

would appreciate any help

inspectItem only works for some steam accounts

Hi there,

Is there any reason that csgo.inspectItem method would only work for some steam accounts but not for others? I can successfully get item data returned from one steam account, but not when I try it from another. Are there settings that need to be configured that I may be forgetting about?

inspectItem doesn't return anything

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();
`

npm install globaloffensive npm ERR!

npm install globaloffensive
npm ERR! code ENOSELF
npm ERR! Refusing to install package with name "globaloffensive" under a package
npm ERR! also called "globaloffensive". Did you name your project the same
npm ERR! as the dependency you're installing?
npm ERR!
npm ERR! For more information, see:
npm ERR! https://docs.npmjs.com/cli/install#limitations-of-npms-install-algorithm

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\RANGERSTUDIO\AppData\Roaming\npm-cache_logs\2020-02-09T08_33_32_267Z-debug.log

Error: Cannot find module 'protobufjs/minimal'

its was work fine before I restart code,then I got this error

ps: I only put this on my code : const GlobalOffensive = require('globaloffensive'); nothing else

Error: Cannot find module 'protobufjs/minimal'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at E:\new\commend\node_modules\globaloffensive\protobufs\generated\base_gcmessages.js:8:34
at Object. (E:\new\new\node_modules\globaloffensive\protobufs\generated\base_gcmessages.js:10:3)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)

How to parse prime status

Hello, I need to parse prime status of account, how i can do it with this library? I am nothing found in readme, so i decided to ask it

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.