Skip to content

OnSwitchToggle

Usage

  • Return a non-null value to override default behavior

Example Autogenerated

csharp
private void OnSwitchToggle( ElectricSwitch instance, BasePlayer player )
{
    Puts( "OnSwitchToggle works!" );
}
csharp
private void OnSwitchToggle( FuelGenerator instance, BasePlayer player )
{
    Puts( "OnSwitchToggle works!" );
}
csharp
private void OnSwitchToggle( IndustrialConveyor instance, BasePlayer player )
{
    Puts( "OnSwitchToggle works!" );
}

Location

  • ElectricSwitch::RPC_Switch(BaseEntity/RPCMessage msg)
  • FuelGenerator::RPC_EngineSwitch(BaseEntity/RPCMessage msg)
  • IndustrialConveyor::SvSwitch(BaseEntity/RPCMessage msg)
csharp
[BaseEntity.RPC_Server, BaseEntity.RPC_Server.IsVisible(3f)]
public void RPC_Switch(BaseEntity.RPCMessage msg)
{
	if (Interface.CallHook("OnSwitchToggle", this, msg.player) != null)
	{
		return;
	}
	bool @switch = msg.read.Bool();
	this.SetSwitch(@switch);
//---
csharp
[BaseEntity.RPC_Server, BaseEntity.RPC_Server.IsVisible(3f)]
public void RPC_EngineSwitch(BaseEntity.RPCMessage msg)
{
	if (Interface.CallHook("OnSwitchToggle", this, msg.player) != null)
	{
		return;
	}
	bool generatorState = msg.read.Bit();
	this.SetGeneratorState(generatorState);
//---
csharp
[BaseEntity.RPC_Server, BaseEntity.RPC_Server.CallsPerSecond(2uL), BaseEntity.RPC_Server.IsVisible(3f)]
private void SvSwitch(BaseEntity.RPCMessage msg)
{
	if (Interface.CallHook("OnSwitchToggle", this, msg.player) != null)
	{
		return;
	}
	this.SetSwitch(!base.IsOn());
}

Released under the MIT License.