JavaScript query

Is there any way to query a server and get back basic info such as online players, max players, and hostname, in JavaScript?

If not in JavaScript, what language?

Not sure if you are looking for this in particular but when you join a server, you could just type “status” in console.

if you’re trying to do this in gmod, check this out:

Yes, but I would like to put this on a webpage

You port/reverse engineer LuaServerBrowser to WebJS or NodeJS

[editline]14th July 2017[/editline]

Yeah, you’ll have to NodeJS it with

[editline]14th July 2017[/editline]

There’s even. NodeJS implementation in the first link PortalGod gave you.

You could write a php query script and then just use ajax ($.ajax) in jquery to get the returned info. The best way of doing the php backend would be by using a libary such as GitHub - xPaw/PHP-Source-Query: 🐘 PHP library to query servers that implement Steam query protocol (also known as Source Engine Query protocol)

Sorry for the late response, I had some stuff to do.

I tried using the link PortalGod sent me, but it is sending me an error when I try it:

Uncaught ReferenceError: require is not defined
    at gametest.html:2

Here is what I have in gametest.html:

	var gamequery = require('gamequery');
		type: 'garrysmod',
		host: '',
		port: '11119'
	}).then((state) => {
	}).catch((error) => {
		console.log("Server is offline");

Thats a JS error, Google it first… (1st google)

Thank you, I will try this.

don’t waste your time, gamequery is a node.js module, if your website isn’t hosted on node.js it isn’t going to work
if you’re able to use php, use php, if not, we’ll need more info on what you’re trying to do

I have installed game query on the host, is there another step I need to do?

I have not learned php.

This isn’t PHP. This is NodeJS. Server-Side JavaScript

There’s tons of options w/ javascript (idk why you want it in that mainly, unless ur doing some nodejs stuff) but if you don’t find what you’re looking for or are too lazy to use javascript; PHP Source Query is pretty great.

I am trying to display the amount of players on, and the max players from the server (I can put the max players in manually if necessary)