Skip to content

OnClientCommand

Usage

  • Return a non-null value to override default behavior

Example Autogenerated

csharp
private void OnClientCommand( Connection connection, string text )
{
    Puts( "OnClientCommand works!" );
}

Location

  • ConsoleNetwork::OnClientCommand(Network.Message packet)
csharp
//---
	if (packet.connection == null || !packet.connection.connected)
	{
		Debug.LogWarning("Client without connection tried to run command: " + text);
		return;
	}
	if (Interface.CallHook("OnClientCommand", packet.connection, text) != null)
	{
		return;
	}
	ConsoleSystem.CommandResult commandResult = ConsoleSystem.RunWithResult(ConsoleSystem.Option.Server.FromConnection(packet.connection).Quiet(), text, Array.Empty<object>());
	if (commandResult.Result == ConsoleSystem.CommandResultType.Success && (packet.connection.authLevel > 0u || (commandResult.Command.ServerAdmin && !commandResult.Command.ServerUser)))
//---

Released under the MIT License.