shouldn't you have a list of the players on the server? Then you can simply count them. Or increment how many players are there when someone connects and decrement when someone disconnects.
Yes but this program is for games that already exist , such as arma 2 , counter strike and many more
So it needs to be able to grab the information from the game and tell the program