OnInventoryNetworkUpdate
OxideCarbonPlayerCalled when an inventory network is updated.
object OnInventoryNetworkUpdate(PlayerInventory playerInventory, ItemContainer container, ProtoBuf.UpdateItemContainer local0, PlayerInventory.Type type, PlayerInventory.NetworkInventoryMode mode)Works — the game method in this build is the one the hook was written for.
Parameters
- playerInventory
- PlayerInventory
- container
- ItemContainer
- local0
- ProtoBuf.UpdateItemContainer
- type
- PlayerInventory.Type
- mode
- PlayerInventory.NetworkInventoryMode
Return value
objectReturn non-null to cancel the game action.
Example
object — you can affect the game: return a value to change or cancel the action.
private object OnInventoryNetworkUpdate(PlayerInventory playerInventory, ItemContainer container, ProtoBuf.UpdateItemContainer local0, PlayerInventory.Type type, PlayerInventory.NetworkInventoryMode mode)
{
Puts("OnInventoryNetworkUpdate");
// change nothing — the game continues as usual
return null;
// to affect the game:
// return false; // non-null cancels the game action
}Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.
Injection point
Rust.opj (Oxide)
void PlayerInventory.SendUpdatedInventoryInternal(PlayerInventory.Type, ItemContainer, PlayerInventory.NetworkInventoryMode)
Passes: PlayerInventory playerInventory, ItemContainer container, ProtoBuf.UpdateItemContainer local0, PlayerInventory.Type type, PlayerInventory.NetworkInventoryMode mode
WorksReturnBehavior: ExitWhenValidTypeArgumentBehavior: UseArgumentString (this, a1, l0, a0, a2)Assembly-CSharp.dll
Where it is called (this branch's game code)
// …
bool flag = type == Type.Belt && mode == NetworkInventoryMode.EveryoneButLocal && ConVar.AntiHack.hotbar_network_mode == 1;
if (container != null)
{
container.dirty = false;
updateItemContainer.container = Facepunch.Pool.Get<List<ProtoBuf.ItemContainer>>();
bool bIncludeContainer = type != Type.Wear || mode == NetworkInventoryMode.LocalPlayer;
updateItemContainer.container.Add(container.Save(bIncludeContainer, flag));
}
if (Interface.CallHook("OnInventoryNetworkUpdate", this, container, local0, type, mode) != null)
{
return;
}
switch (mode)
{
case NetworkInventoryMode.Everyone:
baseEntity.ClientRPC(RpcTarget.NetworkGroup("UpdatedItemContainer"), updateItemContainer);
break;
// …Sources: Rust.opj from OxideMod/Oxide.Rust (MIT) and hook metadata of the Carbon documentation (MIT). Method code is decompiled from this branch's server.