Skip to content

OnApplicationCommand

Usage

  • No return behavior

Example Autogenerated

csharp
private void OnApplicationCommand( BasePlayer player, string cmd, string[] args )
{
    Puts( "OnApplicationCommand works!" );
}
csharp
private void OnApplicationCommand( IPlayer iplayer, string cmd, string[] args )
{
    Puts( "OnApplicationCommand works!" );
}

Location

  • RustCore::TryRunPlayerCommand(BasePlayer player, string message, string commandPrefix)
  • RustCore::TryRunPlayerCommand(BasePlayer player, string message, string commandPrefix)
csharp
private void TryRunPlayerCommand(BasePlayer basePlayer, string message, string commandPrefix)
{
	if (basePlayer == null)
	{
		return;
	}

	string str = message.Replace("\n", "").Replace("\r", "").Trim();

	// Check if it is a chat command
	if (string.IsNullOrEmpty(str))
	{
		return;
	}

	// Parse the command
	ParseCommand(str.Substring(commandPrefix.Length), out string cmd, out string[] args);
	if (cmd == null)
	{
		return;
	}

	// Check if using Rust+ app
	if (!basePlayer.IsConnected)
	{
		Interface.CallHook("OnApplicationCommand", basePlayer, cmd, args);
		Interface.CallHook("OnApplicationCommand", basePlayer.IPlayer, cmd, args);
		return;
	}

	// Is the command blocked?
	object commandSpecific = Interface.CallHook("OnPlayerCommand", basePlayer, cmd, args);
	object commandCovalence = Interface.CallHook("OnUserCommand", basePlayer.IPlayer, cmd, args);
	object canBlock = commandSpecific is null ? commandCovalence : commandSpecific;
	if (canBlock != null)
	{
		return;
	}

	//---
}
csharp
private void TryRunPlayerCommand(BasePlayer basePlayer, string message, string commandPrefix)
{
	if (basePlayer == null)
	{
		return;
	}

	string str = message.Replace("\n", "").Replace("\r", "").Trim();

	// Check if it is a chat command
	if (string.IsNullOrEmpty(str))
	{
		return;
	}

	// Parse the command
	ParseCommand(str.Substring(commandPrefix.Length), out string cmd, out string[] args);
	if (cmd == null)
	{
		return;
	}

	// Check if using Rust+ app
	if (!basePlayer.IsConnected)
	{
		Interface.CallHook("OnApplicationCommand", basePlayer, cmd, args);
		Interface.CallHook("OnApplicationCommand", basePlayer.IPlayer, cmd, args);
		return;
	}

	// Is the command blocked?
	object commandSpecific = Interface.CallHook("OnPlayerCommand", basePlayer, cmd, args);
	object commandCovalence = Interface.CallHook("OnUserCommand", basePlayer.IPlayer, cmd, args);
	object canBlock = commandSpecific is null ? commandCovalence : commandSpecific;
	if (canBlock != null)
	{
		return;
	}

	//---
}

Released under the MIT License.