RustTip

OnRefreshVendingStock

OxideCarbonVending

Called when refresh vending stock occurs.

void OnRefreshVendingStock(VendingMachine vendingMachine, ItemDefinition itemDef)
Works — the game method in this build is the one the hook was written for.

Parameters

vendingMachine
VendingMachine
itemDef
ItemDefinition

Return value

voidThe return value is ignored — the hook only notifies.

Example

private void OnRefreshVendingStock(VendingMachine vendingMachine, ItemDefinition itemDef)
{
    Puts("OnRefreshVendingStock");
}

Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.

Injection point

Rust.opj (Oxide)
void VendingMachine.RefreshSellOrderStockLevel(ItemDefinition)

Passes: VendingMachine vendingMachine, ItemDefinition itemDef

WorksReturnBehavior: ContinueArgumentBehavior: UseArgumentString (this, a0)Assembly-CSharp.dll

Where it is called (this branch's game code)

// …
List<Item> obj = Pool.Get<List<Item>>();
GetItemsToSell(sellOrder, obj);
int num2 = sellOrder.itemToSellAmount;
if (ItemManager.FindItemDefinition(sellOrder.itemToSellID) == ItemManager.Items.Scrap && sellOrder.receivedQuantityMultiplier != 1f)
{
	num2 = GetTotalPriceForOrder(num2, sellOrder.receivedQuantityMultiplier);
}
sellOrder.inStock = ((obj.Count >= 0) ? (obj.Sum((Item x) => x.amount) / num2) : 0);
Interface.CallHook("OnRefreshVendingStock", this, itemDef);
float itemCondition = 0f;
float itemConditionMax = 0f;
int instanceData = 0;
List<int> list = Pool.Get<List<int>>();
int totalAttachmentSlots = 0;
int ammoType = 0;
int ammoCount = 0;
if (obj.Count > 0)
// …

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.