Finding Current Player Count

How could you ping another server or something to get the current player count out of the maximum player count. For example, if you had 20 players out of a maximum of 40, it would print 20/40.

  • snip - didn’t read

You can’t from client or server. Not without socket module and a lot of parsing.

This, and then you should look at https://developer.valvesoftware.com/wiki/Server_queries

What would be wrong with doing something like


table.GetLastKey(player.GetAll())

Hacky but it works
edit:


print("Current Players: "..table.GetLastKey(player.GetAll()).." / "..game.MaxPlayers())

He is talking about another server… You need to take the time to read Jacob…

That’s an inefficient way of doing it anyway, you can just do “#player.GetAll()”, because it’s a table that starts at the index of one and increases on next index.

The easiest way would be to setup a web service that can run the aforementioned source engine queries for you and send back that data in json for you to work with in game.

MySQL will work, but there are probably better ways?