I need to make a system that displays the number of users who are currently in the game. When entering the application, 1 is added to the number of online users, but how to make sure that when closing the application, 1 is deducted from the number of online users
If you just want to monitor when the app is exited, you can use system events, however, they won’t be able to detect if the game crashes or is terminated via non-standard means, or if the user’s device loses power or connection to the Internet, etc.
Since you can’t rely on the number of times the game has been launched and closed by individual users, you’ll need to have the game send a message to your server every N seconds while it’s running and then you’ll just count the number of messages from unique users within your chosen time period.
I don’t think your solution would work to keep track of online players. There are too many ways the tracking can get messed up depending on a players internet connection.
You’ll need to constantly ping your server every X seconds like @XeduR mentioned if you want a reliable player count.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.