The GSI object takes raw request from CS:GO GSI’s system, parses this to more comfortable form and calls listeners on certain events. You need to configure GSI file and receiving end yourself.
Installing
For Node and React
npm install csgogsi
Example #1
importexpressfrom'express';import{CSGOGSI}from'csgogsi';const app =express();constGSI=newCSGOGSI();
app.use(express.urlencoded({extended:true}));
app.use(express.raw({limit:'10Mb',type:'application/json'}));
app.post('/',(req, res)=>{const text = req.body.toString().replace(/"(player|owner)":([ ]*)([0-9]+)/gm,'"$1": "$3"').replace(/(player|owner):([ ]*)([0-9]+)/gm,'"$1": "$3"');const data =JSON.parse(text);GSI.digest(data);
res.sendStatus(200);});GSI.on('roundEnd',team=>{console.log(`Team ${team.name} win!`);});GSI.on('bombPlant',player=>{console.log(`${player.name} planted the bomb`);});
app.listen(3000);
Methods
Method
Description
Example
Returned objects
digest(GSIData)
Gets raw GSI data from CSGO and does magic
GSI.digest(req.body)
CSGO Parsed
digestMIRV(RawKill)
Gets raw kill data from mirv pgl and does magic
GSI.digestMIRV(mirv)
KillEvent
on('event', callback)
Sets listener for given event (check them below)
GSI.on('roundEnd', team => console.log(team.name));
static findSite(mapName, position)
Tries to guess the bombsite of the position
A, B, null
Beside that, CSGOGSI implements standard Event Emitter interfaces.
Events
Event
Name
Callback
Data incoming
data
(data: CSGO Parsed) => {}
End of the round
roundEnd
(score: Score) => {}
End of the map
matchEnd
(score: Score) => {}
Kill
kill
(kill: KillEvent) => {}
Timeout start
timeoutStart
(team: Team) => {}
Timeout end
timeoutEnd
() => {}
MVP of the round
mvp
(player: Player) => {}
Freezetime start
freezetimeStart
() => {}
Freezetime end
freezetimeEnd
() => {}
Intermission start
intermissionStart
() => {}
Intermission end
intermissionEnd
() => {}
Defuse started
defuseStart
(player: Player) => {}
Defuse stopped (but not defused and not exploded)
defuseStop
(player: Player) => {}
Bomb plant started
bombPlantStart
(player: Player) => {}
Bomb planted
bombPlant
(player: Player) => {}
Bomb exploded
bombExplode
() => {}
Bomb defused
bombDefuse
(player: Player) => {}
Objects
CSGO Parsed
Property
Type
provider
Provider Object
map
Map Object
round
Round Object or null
player
Player Object or null
players
Array of Player's Object
observer
Observer Object
bomb
Bomb Object
phase_countdowns
The same as in raw GSI
Observer
Property
Type
activity
'playing', 'textinput' or 'menu'
spectarget
'free' or SteamID64
position
number[]
forward
number[]
Team Extension
Property
Type
id
string
name
string
country
string or null
logo
string or null
map_score
number
Player Extension
Property
Type
id
string
name
string
steramid
string
realName
string or null
country
string or null
avatar
string or null
Provider
Property
Type
name
'Counter-Strike: Global Offensive'
appid
730
version
number
steamid
number
timestamp
number
Map
Property
Type
mode
string
name
string
phase
"warmup" or "live" or "intermission" or "gameover"