Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/fabricio-191/valve-server-query

An implementation of valve protocols (server, master servers and RCON)
https://github.com/fabricio-191/valve-server-query

game-server-query master-server-query ping protocol query steam valve

Last synced: about 1 month ago
JSON representation

An implementation of valve protocols (server, master servers and RCON)

Awesome Lists containing this project

README

        






Buy Me A Coffee


Discord


PayPal



This module allows you to:

* Easily make queries to servers running valve games
* Make queries to valve master servers
* Use a remote console to control your server remotely

## Links

* [Full Docs](https://fabricio-191.github.io/docs/valve-server-query/)
* [GitHub](https://github.com/Fabricio-191/valve-server-query)
* [Discord](https://discord.gg/zrESMn6)

## An implementation of valve protocols

```js
const { Server, RCON, MasterServer } = require('@fabricio-191/valve-server-query');
```

**Some** of the games where it works with are:

* Counter-Strike
* Counter-Strike: Global Offensive
* Garry's Mod
* Half-Life
* Team Fortress 2
* Day of Defeat
* The ship

## Examples

#### Server

```js
const server = new Server({
ip: '0.0.0.0',
port: 27015,
timeout: 3000,
});

const info = await server.getInfo();
console.log(info);

const players = await server.getPlayers();
console.log(players);

const rules = await server.getRules();
console.log(rules);

console.log(server.lastPing);
```

#### Master Server

```js
const servers = await MasterServer({
quantity: 1000,
region: 'US_EAST',
timeout: 3000,
});

//servers is an array if 'ip:port' strings, see the docs
console.log(servers);
```

#### RCON

```js
const rcon = await RCON({
ip: '0.0.0.0',
port: 27015, //RCON port
password: 'your RCON password'
});

rcon.on('disconnect', async (reason) => {
console.log('disconnected', reason);
try{
await rcon.reconnect();
}catch(e){
console.log('reconnect failed', e.message);
}
});

rcon.on('passwordChanged', async () => {
const password = await getNewPasswordSomehow();
try{
await rcon.authenticate(password);
}catch(e){
console.error('Failed to authenticate with new password', e.message);
}
});

const response = await rcon.exec('sv_gravity 1000');
```

#### [Full docs](https://fabricio-191.github.io/docs/valve-server-query/)