1.2.2 • Published 4 years ago
source-fake-query v1.2.2
source-fake-query
A, kind of, emulator of a Source Engine server query in node.js
Features
- Supports both A2S_INFO and A2S_PLAYER requests.
- Default time played in a player will be added 1 every second, and restarted when the socket closes or restarts.
- Easy configuration
- Change query details without restarting/closing the socket
Installation
npm install source-fake-query
.
Usage
Example script is index.js
It only has three functions:
var FakeQuery = require('source-fake-query');
var fq = new FakeQuery();
fq.create(options, function(error, address){...});
Creates a socket and binds it to the address and port in options array.
Options:
- address (required): string. IP address to bind the socket to.
- port (required): integer. Port to bind the socket to.
- hostname (required): string. Name the fake query will return to players.
- map (required): string. Map name.
- folder (required): string. Folder where the game's stored. (f.e. garrysmod)
- game (required): string. The game's name.
- appId (required): integer. Application ID in Steam for the game.
- players (optional): integer. Connected players. Default: 0
- maxplayers (optional): integer. Slots in the server. Default: 32
- bots (optional): integer. Number of bots connected to the server. Default: 0
- passworded (optional): integer between 0 and 1. Name says all. Default: 0
- vac (optional): integer between 0 and 1. 1 will display the server is VAC protected. Default: 1
- servertype (optional): string, possible matches: 'd', 'l', 'p'. Default: 'd'. See https://developer.valvesoftware.com/wiki/Server_queries
- environment (optional): string, possible matches: 'w', 'l', 'm'/'o'. Default: 'w'. See See https://developer.valvesoftware.com/wiki/Server_queries
- version (required): string. Server version of the game.
- playerlist (optional): array. Contains info about connected players. null if not passed. Format: name: string. Player's name. score: integer. Player's score. * played: integer/float. Player's played time IN SECONDS.
- logqueries (optional): boolean. true will log every IP address and which query it requests. Default: false.
Response:
- error: string if there's one, undefined if not.
- address: object, contains address and port where the socket has been opened. Use like
address.address
andaddress.port
fq.update(options, function(error){...});
Takes the same arguments as fq.create
but all are optional. At least one is required.
Address and port aren't valid arguments in the update function.
fq.close();
Closes the socket.
Credits
- Heix - Programming
- Vror - Idea (sort of)