koraktor / steam-condenser

A multi-language library for querying the Steam Community, Source, GoldSrc servers and Steam master servers
https://koraktor.de/steam-condenser
Other
356 stars 67 forks source link

CSGO : sourceServer.getPlayers().size() always return 1 #247

Closed danielsawan closed 10 years ago

danielsawan commented 10 years ago

Evrything is in the title. When there is 0 player connected, GOTV off, sourceServer.getPlayers().size() always return 1.

Then, when i try sourceServer.getPlayers().get(0).getPlayerName() i got a nullpointer exception.

Any idea ?

danielsawan commented 10 years ago

PS : JAVA Version of condenser

danielsawan commented 10 years ago

1.3.7

danielsawan commented 10 years ago

Didn't even try to get more player on the server to test. This method maybe doesn't work at all...

koraktor commented 10 years ago

Any server-side plugins? What's the player count in Steam's server browser or other tools?

psychonic commented 10 years ago

As of a CS:GO update a few months ago, the players list output changed, as did others.

With the new default, it always returns a single "player" with the name "Max Players", and the score is the max player count.

Set host_players_show to 2 to get the old behavior.

Nicholas Hastings

Sebastian Staudt mailto:notifications@github.com Wednesday, June 4, 2014 7:25 AM

Any server-side plugins? What's the player count in Steam's server browser or other tools?

— Reply to this email directly or view it on GitHub https://github.com/koraktor/steam-condenser/issues/247#issuecomment-45079203.

Daniel SAWAN mailto:notifications@github.com Wednesday, June 4, 2014 2:14 AM

Evrything is in the title. When there is 0 player connected, GOTV off, sourceServer.getPlayers().size() always return 1.

Then, when i try sourceServer.getPlayers().get(0).getPlayerName() i got a nullpointer exception.

Any idea ?

— Reply to this email directly or view it on GitHub https://github.com/koraktor/steam-condenser/issues/247.

koraktor commented 10 years ago

@psychonic Do you know what the SteamPlayer object looks like for that dummy player? Has it any useful data?

@danielsawan Do you have one or more IPs of servers that show this behavior?

danielsawan commented 10 years ago

Yes here is an IP : 62.210.177.75:29011 All others servers hosted are like that :/ I don't have any plugin simple default installation. I know i had no problem before so i guess it is a valve update. It is not since the last update it is for a long time now. I thought it is gonna be fixed but nothing happen that's why i decided to open this tickets.

The CS:go browser show 0 players connected but the condenser say 1.

koraktor commented 10 years ago

Ok, finally found the time to have a look at this.

Because Valve decided to abuse the protocol's S2A_PLAYER packet, there's no simple solution for this problem in Steam Condenser. The servers simply return a player named "Max Player", there's no way to determine if this is a real player or just the dummy to represent the maximum number of players.

The correct way would be to have a look at the host_players_show CVAR using GameServer#getRules() and after that decide what to do with the players returned (e.g. ignore "Max Players").

BTW, the right way to get the first player is not sourceServer.getPlayers().get(0) as #getPlayers() returns a Map. Instead you could use players.values().iterator().next() for testing, but real code should check the size first.

danielsawan commented 10 years ago

Oh so can we say for example that real player always equals to getPlayers() minus 1 ? And what if there is 3 players on the server ? Will getPlayers return a map of 3 or 4 ?

koraktor commented 10 years ago

The Map will always include the dummy player. Sadly, as said before, there's no way to reliably filter this player.

danielsawan commented 9 years ago

Sorry but are you telling me that right now there is now way to get the number of connected player to a csgo server calling server.getPlayers() ? Is there any other way ??

I can't imagine that it is just not possible anymore to get such a usefull information.

danielsawan commented 9 years ago

Oh sorry i just understand the host_players_show 2 tricks. My bad. Thanks again ;)