I created this library to use for my new version of the ARK Player & Tribe Viewer. It is an easy way to parse player & tribe files from ARK: Survival Evolved to extract information of you users that RCON tools can't provide.
While I plan to add more fields to be read out, there are some things that can't be parsed easily. An example are the tamed dinos which are saved in the world file.
https://www.nuget.org/packages/ArkData/
Install-Package ArkData
Simple creation of a new container
var container = Container.Create();
Advanced creation by providing dependencies. This allows you to provide custom parsers.
var playerParser = new PlayerFileParser();
var tribeParser = new TribeFileParser();
var steamApi = new SteamApi();
var steamServer = new SteamServer();
var container = new Container(playerParser, tribeParser, steamApi, steamServer);
To load player & tribe files you just need the following line. The players and tribes will be loaded and interlinked so tribes are linked to owners/members.
container.LoadDirectory("C:\\ArkDataFiles");
You can also load additional Steam information for the user like bans and its avatar. In addition to that the Steam username is refreshed if it has changed since ARK only saves the user name when the player first joins the server.
container.LoadSteamData("SteamAPIKey");
To see if a player is online the have to request the online players from your server. You can do that with a simple call.
var ip = IPAddress.Parse("127.0.0.1");
var server = new IPEndPoint(ip, 27015);
container.LoadOnlinePlayers(server);
All methods can also be accessed asynchronous using the async pattern.
var container = new Container(playerParser, tribeParser, steamApi, steamServer);
await container.LoadDirectoryAsync("C:\\ArkDataFiles");
await container.LoadSteamData("SteamAPIKey");
await container.LoadOnlinePlayers(ip, 27015);
// Initialize shared dependencies
var playerParser = new PlayerFileParser();
var tribeParser = new TribeFileParser();
var steamApi = new SteamApi();
var steamServer = new SteamServer();
// Define server endpoints
var publicServer = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 27015);
var privateServer = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 27015);
// Public server
var container1 = new Container(playerParser, tribeParser, steamApi, steamServer);
await container1.LoadDirectoryAsync("C:\Server1\SaveData");
await container1.LoadSteamData("MY-STEAM-KEY");
await container1.LoadOnlinePlayers(publicServer);
var onlinePlayers = container1.Players.Where(p => p.Online);
// Private server
// Don't need steam ban information for private server so don't provide steam api
var privateConainer = new Container(playerParser, tribeParser, null, steamServer);
await privateConainer.LoadDirectoryAsync("C:\PrivateServer\SaveData");
await privateContainer.LoadOnlinePlayers(privateServer);
var averageLevel = privateContainer.Players.Average(p => p.Level);