lartaxx-package

1.0.4 • Public • Published

Game Server Query

Game server querying tools for Node.JS. Used to receive information about a game such as players, map and server name.

Example usage

npm install game-server-query
var query = require('game-server-query');
query(
    {
        type: 'minecraft',
        host: 'mc.example.com'
    },
    function(state) {
        if(state.error){
      console.log("Server is offline");
    }
        else {
      console.log(state);
    }
    }
);

Input Parameters

  • type: One of the game IDs listed in the game list below
  • host
  • port: (optional) Uses the protocol default if not set
  • notes: (optional) Passed through to output

Callback

The callback function is "guaranteed" to be called exactly once.

If an error occurs, the returned object will contain an "error" key, indicating the issue. If the error key exists, it should be assumed that the game server is offline or unreachable.

Otherwise, the returned object is guaranteed to contain the following keys:

Stable, always present:

  • name
  • map
  • password: Boolean
  • maxplayers
  • players: (array of objects) Each object may contain name, ping, score, team, address
  • bots: Same schema as players
  • notes: Passed through from the input

Unstable, not guaranteed:

  • raw: Contains all information received from the server
  • query: Details about the query performed

It can usually be assumed that the number of players online is equal to the length of the players array. Some servers may return an additional player count number, which may be present in the unstable raw object.

Games List

Supported

Don't see your game listed here?

First, let us know so we can fix it. Then, you can try using some common query protocols directly by using one of these server types:

  • protocol-ase
  • protocol-battlefield
  • protocol-doom3
  • protocol-gamespy1
  • protocol-gamespy2
  • protocol-gamespy3
  • protocol-nadeo
  • protocol-quake2
  • protocol-quake3
  • protocol-unreal2
  • protocol-valve

Games with Additional Notes

Counter-Strike: Global Offensive

To receive a full player list response from CS:GO servers, the server must have set the cvar: host_players_show 2

DayZ

DayZ uses a query port that is separate from its main game port. The query port is usually the game port PLUS 24714 or 24715. You may need to pass this port in as the 'port_query' request option.

Minecraft

Some minecraft servers may not respond to a typical status query. If this is the case, try using the 'minecraftping' server type instead, which uses a less accurate but more reliable solution.

Mumble

For full query results from Mumble, you must be running the GTmurmur plugin. If you do not wish to run the plugin, or do not require details such as channel and user lists, you can use the 'mumbleping' server type instead, which uses a less accurate but more reliable solution

Nadeo (ShootMania / TrackMania / etc)

The server must have xmlrpc enabled, and you must pass the xmlrpc port to the module, not the connection port. You must have a user account on the server with access level User or higher. Pass the login into to the module with the additional options: login, password

TeamSpeak 3

For teamspeak 3 queries to work correctly, the following permissions must be available for the guest server group:

  • Virtual Server
  • b_virtualserver_info_view
  • b_virtualserver_channel_list
  • b_virtualserver_client_list
  • Group
  • b_virtualserver_servergroup_list
  • b_virtualserver_channelgroup_list

Terraria

Requires tshock server mod, and a REST user token, which can be passed to the module with the additional option: token

Separate Query Port

Games with this note use a query port which is usually not the same as the game's connection port. Usually, no action will be required from you. The 'port' option you pass the module should be the game's connection port. the module will attempt to calculate the query port automatically. If the query still fails, you may need to pass the 'port_query' option to the module as well, indicating the separate query port.

Package Sidebar

Install

npm i lartaxx-package

Weekly Downloads

4

Version

1.0.4

License

ISC

Unpacked Size

141 kB

Total Files

42

Last publish

Collaborators

  • lartaxx