Author Topic: how to know PlayersCount?  (Read 433 times)

DioAlias

  • Jr. Member
  • **
  • Thank You
  • -Given: 60
  • -Receive: 1
  • Posts: 62
    • View Profile
how to know PlayersCount?
« on: January 09, 2018, 11:58:03 PM »
how to know PlayerCount on remote server(wich you connected)? (not in the channel, I need all players in server wich I connected)

by the way, I can take it from "TNLobbyClient.knownServers.list" - but it's not cool, because I need take all of them

On local server it is: TNServerInstance.playerCount;
but it's work only for localServer

cmifwdll

  • Global Moderator
  • Sr. Member
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 149
  • Posts: 285
  • TNet Alchemist
    • View Profile
Re: how to know PlayersCount?
« Reply #1 on: January 10, 2018, 12:07:59 AM »
Not possible on the client. You can get a list of players given a channel ID but you have to be in that channel for it to work (TNManager.GetPlayers)
You could implement a custom packet and use that. The GameServer has an onCustomPacket delegate.

Though I'd ask why the client needs to know about every player on the server instead of just the ones in their channel. Only the players in the client's channel(s) are relevant.

DioAlias

  • Jr. Member
  • **
  • Thank You
  • -Given: 60
  • -Receive: 1
  • Posts: 62
    • View Profile
Re: how to know PlayersCount?
« Reply #2 on: January 10, 2018, 01:22:22 AM »
just need to know about server populations in lobby(before connect to some channel) - if there online are not to much -> player can change the server

ok, thanks, I'll go to try CustomPacket for this
or I can connect by default all in one channel for use TNManager.GetPlayers(channelID);
« Last Edit: January 31, 2018, 06:49:48 AM by Elmo »

devomage

  • Sr. Member
  • ****
  • Thank You
  • -Given: 7
  • -Receive: 67
  • Posts: 250
    • View Profile
Re: how to know PlayersCount?
« Reply #3 on: January 10, 2018, 07:08:37 PM »
TNManager.GetChannelList() gives a player count - use after onConnect or after player verification.  Channel.Info contains "limit" and "players".

using TNet's http functionality might be another choice?  i havent mod'd it much yet, but seems it'd be helpful when not connected.

DioAlias

  • Jr. Member
  • **
  • Thank You
  • -Given: 60
  • -Receive: 1
  • Posts: 62
    • View Profile
Re: how to know PlayersCount?
« Reply #4 on: January 11, 2018, 09:49:09 AM »
just uncomment in TNGameClient line 1067 (its income with ResponsePing)