Fires events when CSGO game state changes
npm install csgo-eventsSome code based on Shaunidiot's CSGOGSI implementation at https://github.com/shaunidiot/node-csgo-gsi
msgFormat, which controls how events are specified. default or simply left blank: Unique events are triggered per game state. updated: all csgo-related messages are a csgoEvent, and a data object is passed where data.type specifies which game state has been reached.Default behaviour:
``javascript
var CsgoEvents = require('csgo-events');
var csgo = new CsgoEvents();
csgo.on('roundFreezetime', function(data) {
console.log('Freezetime');
});
csgo.on('roundOver', function(winner) {
console.log('Round over, ' + winner + 'win');
});
`
New format:
`javascript
var CsgoEvents = require('csgo-events');
var csgo = new CsgoEvents('updated');
csgo.on('csgoEvent', function(msg) {
switch (msg.type) {
case 'roundFreezeTime':
console.log('Freezetime');
break;
case 'roundOver':
console.log('Round over, ' + msg.data +' win');
break;
}
});
`Methods
.$3
Forces roundStats message on next game state update (see below). This only applies to the new message format.Events (new format)
$3
Fires on a CSGO game state change. If msg.type is 'roundOver', msg.data contains the winning team, either 'T' or 'CT'. If msg.type is 'roundStats', msg.data contains the csgo data object as received.$3
Fires when an ext (external) socketIO message is received. Usage:
`javascript
csgo.on('extRequest', function(data) {
// log received message to console
console.log(data);
});
`
csgoEvent Message types (new format)
- roundFreezetime
- roundLive
- roundOver (msg.data contains string indicating winning team)
- bombPlanted
- bombDefused
- bombExploded
- roundStats (msg.data contains full data object)
- noGameEvents (default)
$3
Fires when the round goes live.$3
Fires when freezetime starts.$3
Fires on round end and returns the winning team, if the bomb wasn't planted
- T
- CT$3
Fires when the bomb is planted$3
Fires when the bomb is defused$3
Fires when the bomb explodes$3
Fires the first time data is recieved without a data.map` object, meaning no game is in progress.