Client Hooks

The official, full and up-to-date list of Carbon for client hooks.

Entity

  • Gets called when a skinned entity updates its skin.

  • Patches BaseEntity.OnSkinChanged.

Example
void OnSkinChanged (BaseEntity entity, ulong oldSkinId, ulong newSkinId)
{
    Log("OnSkinChanged works!");
}
  • Gets called when the skin finished loading.

  • Patches BaseEntity.OnSkinRefreshed.

Example
void OnSkinRefreshed (BaseEntity entity, Rust.Workshop.Skin skin)
{
    Log("OnSkinRefreshed works!");
}
  • Gets called when the client reacts to a deployed flashbang.

  • Patches Flashbang.FlashFrom.

Example
void OnFlashbangFlash (Flashbang bang, Vector3 position, float amount)
{
    Log("OnFlashbangFlash works!");
}

Inventory

  • Gets called when the inspected item gets deselected.

  • Patches SelectedItem.ClearSelection.

Example
void OnInventoryInspectedItemDeselect (SelectedItem view, ItemIcon item)
{
    Log("OnInventoryInspectedItemDeselect works!");
}
  • Gets called when the item inspector pops up.

  • Patches SelectedItem.TrySelect.

Example
void OnInventoryInspectedItemSelect (SelectedItem view, ItemIcon slot, bool silent)
{
    Log("OnInventoryInspectedItemSelect works!");
}
  • Called when an inspected item is no longer inspected.

  • Patches ItemIcon.Deselect.

Example
void OnInventoryItemDeselect (ItemIcon slot, Item item)
{
    Log("OnInventoryItemDeselect works!");
}
  • Gets called when an inspected item action is executed.

  • Patches ItemOptionButton.Pressed.

Example
void OnInventoryItemOptionClick (ItemOptionButton button, Option option, Item item)
{
    Log("OnInventoryItemOptionClick works!");
}
  • Called when an item is selected.

  • Patches ItemIcon.Select.

Example
void OnInventoryItemSelect (ItemIcon slot, Item item)
{
    Log("OnInventoryItemSelect works!");
}
  • Called when an item is selected silently.

  • Patches ItemIcon.SelectSilent.

Example
void OnInventoryItemSelectSilent (ItemIcon slot, Item item)
{
    Log("OnInventoryItemSelectSilent works!");
}
  • Gets called when a container the client's watching gets updated/marked dirty by the server.

  • Patches ItemContainer.OnChanged.

Example
void OnItemContainerChanged (ItemContainer container)
{
    Log("OnItemContainerChanged works!");
}
  • Gets called when the inventory toggles.

  • Patches UIInventory.ToggleInventory.

Example
void OnInventoryToggle (bool wasOpen)
{
    Log("OnInventoryToggle works!");
}
  • Gets called when the text input of the console gets submitted.

  • Patches ConsoleUI.SubmitCommand.

Example
void OnCommandSubmit (ConsoleUI console, string text)
{
    Log("OnCommandSubmit works!");
}
  • Gets called when a layer has been toggled in the F1 -> Tools dev panel.

  • Patches ToggleLayer.OnToggleChanged.

Example
void OnDevToolsLayerToggle (int layer, bool isOn)
{
    Log("OnDevToolsLayerToggle works!");
}
  • Gets called when the main menu becomes hidden.

  • Server hook: OnClientMenuHide(CarbonClient client)

  • Patches MainMenuSystem.Hide.

Example
void OnMenuHide (MainMenuSystem menu)
{
    Log("OnMenuHide works!");
}
  • Gets called when the main menu becomes visible.

  • Server hook: OnClientMenuShow(CarbonClient client)

  • Patches MainMenuSystem.Show.

Example
void OnMenuShow (MainMenuSystem menu)
{
    Log("OnMenuShow works!");
}

Network

  • Gets called when the server sends the approval packet allowing the client to connect.

  • Patches Client.OnApproved.

Example
void OnClientApproved (Client client, Network.Message packet)
{
    Log("OnClientApproved works!");
}
  • Gets called when a client-side entity gets destroyed due to it being out of the group/server destroyed.

  • Patches BaseNetworkable.EntityDestroy.

Example
void OnClientEntityDestroy (BaseNetworkable net)
{
    Log("OnClientEntityDestroy works!");
}
  • Gets called when a client side entity has been spawned.

  • Patches BaseNetworkable.ClientSpawn.

Example
void OnClientEntitySpawn (BaseNetworkable net, ProtoBuf.Entity info, bool justCreated)
{
    Log("OnClientEntitySpawn works!");
}
  • Gets called when the server calls the CreateOrUpdateEntity RPC.

  • Patches Client.CreateOrUpdateEntity.

Example
object OnCreateOrUpdateEntity (Client client, ProtoBuf.Entity info, uint size)
{
    Log("OnCreateOrUpdateEntity works!");
    return (BaseEntity)null;
}
  • Gets called when the server updates the flags of the player.

  • Patches Client.OnEntityFlags.

Example
void OnEntityFlagsUpdate (Client client, Network.Message msg)
{
    Log("OnEntityFlagsUpdate works!");
}
  • Gets called when the server updates the position of the player.

  • Patches Client.OnEntityPosition.

Example
void OnEntityPositionUpdate (Client client, Network.Message msg)
{
    Log("OnEntityPositionUpdate works!");
}
  • Gets called when the client enters a network group.

  • Patches BaseNetworkable.OnNetworkGroupEnter.

Example
void OnNetworkGroupEnter (BaseNetworkable net, Network.Visibility.Group group)
{
    Log("OnNetworkGroupEnter works!");
}
  • Gets called when a player leaves a network group.

  • Patches BaseNetworkable.OnNetworkGroupLeave.

Example
void OnNetworkGroupLeave (BaseNetworkable net, Network.Visibility.Group group)
{
    Log("OnNetworkGroupLeave works!");
}
  • Gets called when there's an entity network update from the server.

  • Patches BaseNetworkable.OnNetworkUpdate.

Example
void OnNetworkUpdate (BaseNetworkable net, ProtoBuf.Entity entity)
{
    Log("OnNetworkUpdate works!");
}
  • Gets called when the server delivers the OnRpcMessage RPC.

  • Patches BaseEntity.OnRpcMessage.

Example
object OnRPCMessage (BaseEntity entity, BasePlayer player, int rpc, Network.Message msg)
{
    Log("OnRPCMessage works!");
    return (bool)null;
}
  • Gets called when there's an incoming network message from the server.

  • Patches Client.OnNetworkMessage.

Example
void OnNetworkMessage (Client client, Network.Message msg)
{
    Log("OnNetworkMessage works!");
}

Player

  • Gets called when the client checks if it's in a safe-zone trigger or not.

  • Return `boolean` to override original method logic.

  • Patches BasePlayer.InSafeZone.

Example
object InSafeZone (BasePlayer player)
{
    Log("InSafeZone works!");
    return (bool)null;
}
  • Gets called when the client receives an attack from the server.

  • Patches BasePlayer.OnAttacked.

Example
void OnAttacked (BasePlayer player, HitInfo info)
{
    Log("OnAttacked works!");
}
  • Gets called when the player held item gets changed.

  • Patches BasePlayer.HeldEntityStart.

Example
void OnHeldChanged (BasePlayer player, Item item)
{
    Log("OnHeldChanged works!");
}
  • Gets called when the player held item becomes null.

  • Patches BasePlayer.HeldEntityEnd.

Example
void OnHeldEmpty (BasePlayer player, Item item)
{
    Log("OnHeldEmpty works!");
}
  • Gets called when the player lands on a surface.

  • Patches BasePlayer.OnLand.

Example
void OnLand (BasePlayer player, float velocity)
{
    Log("OnLand works!");
}
  • Gets called when the client gets disconnected from a server.

  • Patches Network.Client.OnDisconnected.

Example
void OnPlayerDisconnect (Network.Client client, string reason)
{
    Log("OnPlayerDisconnect works!");
}

ViewModel

  • Gets called when the held viewmodel is holstered.

  • Patches ViewModel.Clear.

Example
void OnViewModelClear (ViewModel vm, HeldEntity held)
{
    Log("OnViewModelClear works!");
}
  • Gets called when the viewmodel deploys a new held entity (right before animation starts).

  • Patches ViewModel.Deploy.

Example
void OnViewModelDeploy (ViewModel vm, HeldEntity held)
{
    Log("OnViewModelDeploy works!");
}
  • Gets called when the held viewmodel is holstered.

  • Patches ViewModel.Holster.

Example
void OnViewModelHolster (ViewModel vm, HeldEntity held)
{
    Log("OnViewModelHolster works!");
}
  • Gets when an animation starts playing on the current viewmodel.

  • Patches ViewModel.Play.

Example
void OnViewModelPlay (ViewModel vm, HeldEntity held, string name, int layer)
{
    Log("OnViewModelPlay works!");
}

Miscellaneous

  • Overrides the OS name method of the client.

  • Patches Client.GetOSName.

Example
object OnOSNameOverride ()
{
    Log("OnOSNameOverride works!");
    return (string)null;
}

Last updated