gamedig / node-gamedig

Query game servers and not only! Node.JS/Deno/Bun or Bash (via the CLI).
https://www.npmjs.com/package/gamedig
MIT License
599 stars 147 forks source link

View Dedicated Gportal server #510

Closed saki-xhan closed 7 months ago

saki-xhan commented 7 months ago

Hi, I tried to get the number of players connected on a Conan Exiles and Palworld server but without success because they are dedicated Gportal servers. This gives me server not found. But the servers are online and full of players.

podrivo commented 7 months ago

Hello @saki-xhan!

Do you mind providing examples of dedicated Gportal servers, for Conan Exiles and Palworld? Thank you!

saki-xhan commented 7 months ago

https://www.battlemetrics.com/servers/palworld/25156030

176.57.140.222:30800

guilhermewerner commented 7 months ago

https://www.battlemetrics.com/servers/palworld/25156030

176.57.140.222:30800

Palworld is bugged, not even my server outside of gportal works, Conan should work, would there also be a Conan IP for us to test?

saki-xhan commented 7 months ago

Conan exiles: 185.239.211.117:32200

guilhermewerner commented 7 months ago

The one from palworld has now responded:

{
    "name": "[FR] V├®t├®rans - https://discord.gg/6CqKeXp9HD",
    "map": "MainWorld5",
    "raw": {
        "deployment": "0a18471f93d448e2a1f60e47e03d3413",
        "id": "eebdf08281c6455e9f99f27700c67c04",
        "bucket": "Pal_1",
        "settings": {
            "maxPublicPlayers": 20,
            "allowInvites": false,
            "shouldAdvertise": true,
            "allowReadById": true,
            "allowJoinViaPresence": true,
            "allowJoinInProgress": true,
            "allowConferenceRoom": false,
            "checkSanctions": false,
            "allowMigration": false,
            "rejoinAfterKick": "",
            "platforms": null
        },
        "totalPlayers": 0,
        "openPublicPlayers": 20,
        "publicPlayers": [],
        "started": true,
        "lastUpdated": null,
        "attributes": {
            "OWNINGUSERNAME_s": "DedicatedServer - sid5965708",
            "BUSESSTATS_b": false,
            "GAMESERVER_PORT_l": 30800,
            "DAYS_l": 6,
            "WORLDGUID_s": "64BA63524910E72543D40D85ADD20969",
            "NUMPRIVATECONNECTIONS_l": 0,
            "TYPE_s": "Community",
            "NAME_s": "[FR] V├®t├®rans - https://discord.gg/6CqKeXp9HD",
            "CREATE_TIME_l": 1706102776,
            "SERVERTIME_l": 80,
            "DEDICATEDONLY_b": true,
            "ADDRESS_s": "176.57.140.222",
            "PRESENCESEARCH_b": true,
            "NUMPUBLICCONNECTIONS_l": 20,
            "BUILDUNIQUEID_l": 0,
            "ISPASSWORD_b": false,
            "VERSION_s": "v0.1.2.0",
            "GAMESERVER_ADDRESS_s": "176.57.140.222",
            "NAMESPACE_s": "production",
            "BANTICHEATPROTECTED_b": false,
            "BISDEDICATED_b": true,
            "PLAYERS_l": 5,
            "MAPNAME_s": "MainWorld5"
        },
        "owner": "Client_xyza78918C8ZyYGcxMcpvTQjPFdjtykx",
        "ownerPlatformId": null
    },
    "maxplayers": 20,
    "numplayers": 5,
    "players": [],
    "bots": [],
    "queryPort": 30800,
    "connect": "176.57.140.222:30800",
    "ping": 0
}
saki-xhan commented 7 months ago

What I need to do is get the number of players online on the server and display it in bot status.

guilhermewerner commented 7 months ago

What I need to do is get the number of players online on the server and display it in bot status.

This information is in the query response:

    "maxplayers": 20,
    "numplayers": 5,
import { GameDig } from '../lib/index.js'
// Instead of '../lib/index.js' you would have here 'gamedig'.

async function main() {
  const query = await GameDig.query({
    type: 'palworld',
    host: '176.57.140.222',
    port: 30800
  });

  console.log(query.numplayers)
}

main();
saki-xhan commented 7 months ago

This tells me undefined online.

podrivo commented 7 months ago

There's a fix (https://github.com/gamedig/node-gamedig/pull/508) that was merged yesterday, but it hasn't been published yet.

Currently, you can grab players from state.raw.attributes.PLAYERS_l:

{
  "name": "[FR] Vétérans - https://discord.gg/6CqKeXp9HD",
  "raw": {
    "attributes": {
      "PLAYERS_l": 5,
}
podrivo commented 7 months ago

Conan exiles: 185.239.211.117:32200

This server seems to be offline: https://gamemonitoring.net/conan-exiles/servers/1565452 I've tried this from g-portal and it worked: https://gamemonitoring.net/conan-exiles/servers/616457

gamedig --type conanexiles 176.57.140.217:28015 --pretty

{
  "name": "Official server #1111 PvP - g-portal.com",
  "map": "The Exiled Lands",
  "password": false,
  "raw": {
    "protocol": 2,
    "folder": "",
    "game": "Conan Exiles",
    "appId": 440900,
    "numbots": 0,
    "listentype": "d",
    "environment": "w",
    "secure": 1,
    "version": "",
    "players": [
      {
        "name": "MSV#34557",
        "score": 0,
        "time": 35059
      },
    ]
  },
  "maxplayers": 40,
  "numplayers": 16,
  "players": [
    {
      "name": "dxylbo#54516",
      "raw": {
        "score": 0,
        "time": 41143
      }
    }
  ],
  "bots": [],
  "queryPort": 28015,
  "connect": "176.57.140.217:28000",
  "ping": 222
}