- Server
- Get ServerInfo.
- Stop/Restart server.
- Send console command.
- On chat/console message events.
- Player
- Kick/Ban player.
- Get players ban list.
- Kill player.
- Get player info.
- Oxide
- Get plugin list.
- Reload plugin.
- Load/Unload plugin.
You should compile the library project and add a dependency to your project RustRcon.dll
RustRcon is available on the NuGet Gallery, as still a release version:
You can add RustRcon to your project with the NuGet Package Manager, by using the following command in the Package Manager Console.
PM> Install-Package RustRcon_Client
Required namespace.
using RustRcon;
The RconClient class exists in the RustRcon namespace.
Creating a new instance of the RconClient class with the adress, port and password.
RconClient rconClient = new RconClient("localhost", 28016, "root");
Setting the events, example:
rconClient.OnChatMessage += (e) =>
{
Console.WriteLine($"{e.Username}: {e.Message}");
e.Dispose();
};
rconClient.OnConsoleMessage += (e) =>
{
Console.WriteLine($"{e.Message}");
e.Dispose();
};
Connecting to server.
await rconClient.ConnectAsync();
When sending a command to the server, commands take the necessary arguments in their constructor, after asynchronous waiting for the result the response will be in command.ServerResponse.Content (json) and if the command has a unique response, it will be in command.Result
var command = GetServerInfo.Create();
await rconClient.SendCommandAsync(command);
Console.WriteLine($"{command.Id} - {command.ServerResponse?.Id} : {command.Result?.Hostname}");
command.Dispose();
Attention: don't forget to call Dispose
on commands and messages after use.