Skip to content

OnRconCommand

Called when a rcon command is received

Usage

  • Return a non-null value to override default behavior

Example Autogenerated

csharp
private object OnRconCommand( IPEndPoint UserEndPoint, string command, string[] args )
{
    Puts( "OnRconCommand works!" );
    return null;
}
csharp
private object OnRconCommand( IPAddress ipAddress, string message, string[] arg )
{
    Puts( "OnRconCommand works!" );
    return null;
}

Location

  • RemoteConsole::OnMessage(MessageEventArgs event, WebSocketContext connection)
  • RustCore::IOnRconMessage(IPAddress ipAddress, string command)
csharp
private void OnMessage(MessageEventArgs e, WebSocketContext connection)
{
	if (covalence == null)
	{
		Interface.Oxide.LogError("[Rcon] Failed to process command, Covalence is null");
		return;
	}
	RemoteMessage message = RemoteMessage.GetMessage(e.Data);
	if (message == null)
	{
		Interface.Oxide.LogError("[Rcon] Failed to process command, RemoteMessage is null");
		return;
	}
	if (string.IsNullOrEmpty(message.Message))
	{
		Interface.Oxide.LogError("[Rcon] Failed to process command, RemoteMessage.Text is not set");
		return;
	}
	string[] fullCommand = CommandLine.Split(message.Message);
	string command = fullCommand[0].ToLower();
	string[] args = fullCommand.Skip(1).ToArray();
	if (Interface.CallHook("OnRconCommand", connection.UserEndPoint, command, args) != null)
	{
		return;
	}
	covalence.Server.Command(command, args);
}
csharp
private object IOnRconMessage(IPAddress ipAddress, string command)
{
	if (ipAddress != null && !string.IsNullOrEmpty(command))
	{
		RemoteMessage message = RemoteMessage.GetMessage(command);

		if (string.IsNullOrEmpty(message?.Message))
		{
			return null;
		}

		if (Interface.CallHook("OnRconMessage", ipAddress, message) != null)
		{
			return true;
		}

		string[] fullCommand = CommandLine.Split(message.Message);

		if (fullCommand.Length >= 1)
		{
			string cmd = fullCommand[0].ToLower();
			string[] args = fullCommand.Skip(1).ToArray();

			if (Interface.CallHook("OnRconCommand", ipAddress, cmd, args) != null)
			{
				return true;
			}
		}
	}

	return null;
}

Released under the MIT License.