http://pastebin.com/M2FN2kwm
You just need to save this in the root folder of your dedicated server (as e.g. "baron.cs"), and add this line to your main.cs file:
- Code: Select all
exec("baron.cs");
Next time you start your server, it will save all active players to the baron_players table every 10 seconds, or whatever you specify in the script. The baron_players table is just a table with an auto-increment integer ID and a CharacterID integer field.
You can then query this table to fetch all active players. Other in-game data can be stored as well, such as player name, position, health, etc.
Hope someone finds it useful, as it seems to be a common question in the modding community.
P.S.- For more adventurous modders, you can most likely hook into client connect/disconnect events and update a list that way, so you don't have to poll every # of seconds. I just didn't feel the need to do so.