szutilpack-cd2025/szutil_nowonline
Aaron Suen 543f5cfd5f Announce empty server on restart if needed
When an MT server shuts down, it doesn't always kick the players
and announce their departure before the shutdown process runs,
so it's possible for players to be "connected" at the time the
server actually stops running mod code.  This means that there is
no opportunity to announce that the server is now empty once it's
actually shut down.

Here we assume that in most cases, the server will be brought
back up immediately, and better late than never.  If there were any
players online at the time the server was shut down, announce the
server status (i.e. that it's now empty) upon the next startup.

This should mitigate the issue where a a player joins the server,
then the server is shutdown silently, and then the same player
joins again, making chat logs nonsensical.  At least this way
you will see that the player is no longer connected at some point
before they reconnect.
2024-08-20 07:46:38 -04:00
..
2023-06-20 07:30:35 -04:00

When players log in or log out, reannounce the cumulative list of online players. This is particularly useful for szutil_chatsocket connections to external chat bridges, where no command is provided for getting the list of online players.

Player lists are only sent if either a certain amount of time has passed, or a certain number of public chat lines, since the last announcement (configurable) to prevent a ton of noise on busy servers.

The maximum number of names listed is configurable; beyond that limit, a random sample of players will be shown, and "(# more)" displayed at the end of the list.