OnVendingTransaction
OxideCarbonVendingCalled when vending transaction occurs.
object OnVendingTransaction(VendingMachine vendingMachine, BasePlayer buyer, int sellOrderId, int numberOfTransactions, ItemContainer targetContainer)Works — the game method in this build is the one the hook was written for.
Parameters
- vendingMachine
- VendingMachine
- buyer
- BasePlayer
- sellOrderId
- int
- numberOfTransactions
- int
- targetContainer
- ItemContainer
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 OnVendingTransaction(VendingMachine vendingMachine, BasePlayer buyer, int sellOrderId, int numberOfTransactions, ItemContainer targetContainer)
{
Puts("OnVendingTransaction");
// change nothing — the game continues as usual
return null;
// to affect the game:
// return false; // your value instead of the game result
}Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.
Injection point
Rust.opj (Oxide)
bool VendingMachine.DoTransaction(BasePlayer, int, int, ItemContainer, Action<BasePlayer, Item>, Action<BasePlayer, Item>, MarketTerminal)
Passes: VendingMachine vendingMachine, BasePlayer buyer, int sellOrderId, int numberOfTransactions, ItemContainer targetContainer
WorksReturnBehavior: ExitWhenValidTypeArgumentBehavior: UseArgumentString (this, a0, a1, a2, a3)Assembly-CSharp.dll
Where it is called (this branch's game code)
// …
if (sellOrderId < 0 || sellOrderId >= sellOrders.sellOrders.Count)
{
return false;
}
if (targetContainer == null && Vector3.Distance(buyer.transform.position, transform.position) > 4f)
{
return false;
}
object returnvar = Interface.CallHook("OnVendingTransaction", this, buyer, sellOrderId, numberOfTransactions, targetContainer);
if (returnvar is bool)
{
return (bool)returnvar;
}
ProtoBuf.VendingMachine.SellOrder sellOrder = sellOrders.sellOrders[sellOrderId];
List<Item> obj = Pool.Get<List<Item>>();
GetItemsToSell(sellOrder, obj);
if (obj == null || 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.