Coder Social home page Coder Social logo

digz's Introduction

digz library

DayZ server query library, with DZSA Tools fallback request. It is built on top of node-gamedig, but focus on providing a simpler DayZ server output.

digz is available as a node.js module, as well as a command line executable.

Usage from Node.js

npm install digz
const digz = require('digz')

digz.query({
  host: '168.100.162.110',
  port: '2303'
}).then((response) => {
  console.log('Server data:', response)
}).catch((error) => {
  console.log('Server is offline')
})

Query parameters

Parameter Type Default
host string - Required. Hostname or IP of the server.
port number - Required. Connection port or query port for the server. Make sure it's the query port and not the game port.
pretty boolean false Hostname or IP of the server.
maxAttempts number 1 Number of attempts to query server in case of failure.
socketTimeout number 2000 Milliseconds to wait for a single packet. Beware that increasing this will cause many queries to take longer even if the server is online.
attemptTimeout number 10000 Milliseconds allowed for an entire query attempt. This timeout is not commonly hit, as the socketTimeout typically fires first.
givenPortOnly boolean false Only attempt to query server on given port.
debug boolean false Enables massive amounts of debug logging to stdout.
pingOnly boolean false Only gets ping in the response.

Response

The returned state object will contain the following keys:

Key Type
name string Server name.
map string Map name.
connect string IP:PORT to connect.
ping number Round trip time to the server in milliseconds.
password boolean If password is required.
numplayers number Number of players connected.
maxplayers number Maximum number of connected players.
queue number Number of players in queue.
official boolean If server is official or not.
version string Game version the server is running.
firstPerson boolean If server is first person only.
dlcEnabled boolean If server needs Livonia DLC.
dayAcceleration number In-game day time acceleration.
nightAcceleration number In-game night time acceleration.
time string Current server day time.
mods array Title and Steam Workshop ID.

Usage from Command Line

Install digz globally if you need to integrate server queries from a batch script or other programming language:

npm install digz -g
digz 168.100.162.110:2303 --pretty

The output of the command will be in JSON format. Additional optional parameters can be passed in as well. Ex: --pretty, --socketTimeout 5000, etc.

node-gamedig

This library is built on top of node-gamedig, a more broad game server library. This wouldn't be possible if it wasn't for all their hard work. I decided to put this togeter, because DayZ has it's own misteries and needs a little more love to have fallback options and a simpler query response.

License

Released under the MIT license.

digz's People

Contributors

podrivo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.