Due to a lack of resources, this project has been mostly abandoned. Please see gigobyte/HLTV for a popular and more up-to-date HLTV API. If anyone would like to take over maintenance for this project, please contact me.
A simple Node.js library to interface with HLTV's live scorebot.
This module is based on @Nols1000's original version, created back in May of 2015. It is packed full of features, but was never updated to the newest version of HLTV's scorebot. The purpose of this version is to be more of a wrapper for HLTV, and to incorporate all of the features available with the new scorebot.
Install with npm:
$ npm install hltv-livescore
Usage:
var Livescore = require('hltv-livescore');
var live = new Livescore({
listid: 2299033
});
live.on('kill', function(data) {
console.log(data.killer.name, 'killed', data.victim.name, 'with', data.weapon, data.headshot ? '(headshot)' : '');
});
options
- An optional object containing some of the following optionslistid
- The game's listidurl
- The URL to listen on. Defaults tohttp://scorebot2.hltv.org
port
- The port to listen on. Defaults to10022
Constructs a new Livescore
. You will be automatically connected to the HLTV scorebot server. The game with the specified listid
will be automatically started if provided. If not provided, you must specify them using them using the start()
method.
options
- An optional object containing some of the following optionslistid
- The game's listid
callback
- An optional callback.
Start the game with the specified listid
. If provided in the Constructor, the listid
is not required. An error will be thrown if you are not connected to the HLTV scorebot server before calling this method.
callback
- Required. Called with an object of playersplayers
- An object containing all the players connected to the server, with their name as the key
Retrieve all players connected to the server.
callback
- Required. Called with an object of playersteams
- An object containing both teams connected to the server
Retrieve both teams connected to the server.
time
- Required. The time to set the scoreboard to (in seconds)
Set the scoreboard to a new time.
callback
- Required. Called with the remaining timetime
- The time remaining in seconds as displayed on the scoreboard
Retrieve the time remaining.
Events emit an object containing the parameters listed under each event.
Emitted when we successfully connect to the HLTV Socket.io server.
Emitted immediately before the first scoreboard
event is emitted.
log
- The log given to us by HLTV since the last log was emitted
Emitted whenever HLTV feels like giving us logs (after kills, round events, etc).
seconds
- The time displayed on the timer in seconds
Emitted every time the timer on the scoreboard is updated.
teams
- An object containing the two teams' objectsmap
- The current mapbombPlanted
-true
if the bomb is plantedcurrentRound
- The current round number
Emitted whenever HLTV sends us a scoreboard update. The scoreboard may not be any different from the last update.
killer
- The player object of the killervictim
- The player object of the victimweapon
- The weapon usedheadshot
-true
if the kill was a headshot
Emitted after every kill.
player
- The player object of the suicider
Emitted after a player commits suicide.
player
- The player object of the bomb planter
Emitted when the bomb is planted.
player
- The player object of the bomb defuser
Emitted when the bomb is defused.
round
- The round number.
Emitted at the start of every round.
teams
- The list of teamswinner
- The team that wonwinType
- How the team wonknifeRound
- If we think the round was a knife round (>=5 knife kills)
Emitted at the end of every round.
playerName
- The player's name
Emitted when a player joins the server.
player
- The player object of the player who quit
Emitted when a player leaves the server.
map
- The new map
Emitted when the map is changed.
Emitted when the score is restarted
steamid
- A SteamID objecthltvid
- The player's HLTV idname
- The player's usernamealive
-true
if the player is alivemoney
- The player's in-game moneyrating
- The player's HLTV rating for this gamekills
- The player's total killsassists
- The player's total assistsdeaths
- The player's total deathsteam
- The player's Team class
Example:
Player {
steamid: [Object],
hltvid: 11654,
name: 'almazer1',
alive: true,
money: 12300,
rating: 1.16,
kills: 19,
assists: 4,
deaths: 17,
team: [Object]
}
id
- The team's HLTV idname
- The team's namescore
- The team's scoreside
- The team's side (ESide)players
- An array of the team's Player classeshistory
- The team's round history
Example:
Team {
id: 6921,
name: 'Vesuvius',
score: 16,
side: 1,
players: [Array],
history: [Object]
}
type
- How the round ended for this team (ERoundType)round
- The round number
Example:
Round {
type: 6
round: 12
}
There are numerous enums available for your use. All enums are located in the /resources/
directory.
Primarily for internal use. Specifies options about the module.
Specifies how a team ended the round.
Specifies team constants.