gamedig / node-gamedig

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

feat: Add status object player's online time #536

Closed Mululu closed 4 months ago

Mululu commented 4 months ago

What is this feature about? A status object with a player's online time would be desirable. The RAW output does include the time, but this designation varies depending on the game (time, uptime, ...) so this data can only be queried to a limited extent.

Additional context/references Example:

RAW output: Conan Exiles = time RAW output: Farming Simulator 22 = uptime

CosminPerRam commented 4 months ago

In order to stabilize a field (meaning to add one), the majority of the protocols would have to provide it and unfortunately I don't think many do that (cannot check know, will do later).

podrivo commented 4 months ago

@Mululu Hello! Can you give us examples of games that provide the data you mentioned? Thank you!

CosminPerRam commented 4 months ago

@podrivo he mentioned under "examples" Conan Exiles, which do provides time for players. FS22 could also but I can't remember its raw output to know.

Vito0912 commented 4 months ago

@CosminPerRam FS22/19 does contain uptime as response in it's raw. I am not sure if I included it. I will have to take a look.

But nevertheless imho I would not add a dedicated field for only very few games (if this is the case), if you can get it via the raw field.

But that said, shouldn't the valve protocol contain the uptime (at least many games show them with the steam client). But I am not into the valve Protocol at all.

CosminPerRam commented 4 months ago

But that said, shouldn't the valve protocol contain the uptime

It does, but many games (that uses the valve protocol) do not provide that data.

Mululu commented 4 months ago

Can this work?

$('Player').each(function () { if ($(this).attr('isUsed') === 'true') { state.players.push({ name: $(this).text(), time: parseInt($(this).attr('uptime'), 10), raw: { isAdmin: $(this).attr('isAdmin') === 'true' } }) } })

Vito0912 commented 4 months ago

Ofc this can work (Just formatted below)

    $('Player').each(function () {
      if ($(this).attr('isUsed') === 'true') {
        state.players.push({
          name: $(this).text(),
          raw: {
            isAdmin: $(this).attr('isAdmin') === 'true',
            uptime: parseInt($(this).attr('uptime'), 10)
          }
        })
      }
    })

To

    $('Player').each(function () {
      if ($(this).attr('isUsed') === 'true') {
        state.players.push({
          name: $(this).text(),
          time: parseInt($(this).attr('uptime'), 10)
          raw: {
            isAdmin: $(this).attr('isAdmin') === 'true'
            uptime: parseInt($(this).attr('uptime'), 10)
          }
        })
      }
    })

But it is not within the scope. As @CosminPerRam outlined,

the majority of the protocols would have to provide it.

It must (or should) be supported by many games, and that's currently not the case, as far as I know. If you were to stabilize fields, there should be a certain number of games that feature a field like this. This is because developers can rely on the field across many games. If only a few games support it, it offers no real benefit to anyone—only confusion, since it appears this field is so frequently used that it has its own designated stabilized field. Just pointing out my opinion on this. Could be of value for somebody else :)

But to be honest, what's the trade-off of calling let time = yourVar.players[0].raw.uptime || yourVar.players[0].raw.time For your provided games

But ofc you are welcome and convince me :) Just my opinion

CosminPerRam commented 4 months ago

Closing this as per my first comment and @Vito0912's last comment.