OnInventoryItemsCount
OxideCarbonItemCalled when inventory items count occurs.
object OnInventoryItemsCount(PlayerInventory playerInventory, int itemid, bool includeBackpack, bool redirectAllowed)Works — the game method in this build is the one the hook was written for.
Parameters
- playerInventory
- PlayerInventory
- itemid
- int
- includeBackpack
- bool
- redirectAllowed
- bool
Return value
objectThe returned value replaces the game result; null lets the game decide.
Example
object — you can affect the game: return a value to change or cancel the action.
private object OnInventoryItemsCount(PlayerInventory playerInventory, int itemid, bool includeBackpack, bool redirectAllowed)
{
Puts("OnInventoryItemsCount");
// change nothing — the game continues as usual
return null;
// to affect the game:
// return default(int); // your value instead of the game result
}Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.
Injection point
Rust.opj (Oxide)
int PlayerInventory.GetAmount(int, bool, bool)
Passes: PlayerInventory playerInventory, int itemid, bool includeBackpack, bool redirectAllowed
WorksReturnBehavior: ExitWhenValidTypeArgumentBehavior: AllAssembly-CSharp.dll
Where it is called (this branch's game code)
public int GetAmount(int itemid, bool includeBackpack = false, bool redirectAllowed = false)
{
if (itemid == 0)
{
return 0;
}
object returnvar = Interface.CallHook("OnInventoryItemsCount", this, itemid, includeBackpack, redirectAllowed);
if (returnvar is int)
{
return (int)returnvar;
}
int num = 0;
if (containerMain != null)
{
num += containerMain.GetAmount(itemid, onlyUsableAmounts: true, redirectAllowed);
// …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.