OnVendingShopOpen
OxideVendingobject OnVendingShopOpen(VendingMachine vendingMachine, BasePlayer player)
object OnVendingShopOpen(InvisibleVendingMachine invisibleVendingMachine, BasePlayer player)
object OnVendingShopOpen(NPCVendingMachine vendingMachine, BasePlayer player)Method changed — check — the game method differs from the one the hook is recorded for in Oxide. The hook is still called, but its place may have shifted — worth checking after an update.
Parameters
- vendingMachine
- VendingMachine
- player
- BasePlayer
Return value
objectReturn a value of the method's result type and the game returns it immediately; null continues as usual.
Example
object — you can affect the game: return a value to change or cancel the action.
private object OnVendingShopOpen(VendingMachine vendingMachine, BasePlayer player)
{
Puts("OnVendingShopOpen");
// change nothing — the game continues as usual
return null;
// to affect the game:
// return null; // null — the game continues as usual
}Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.
Injection point 1
Rust.opj (Oxide)
void VendingMachine.RPC_OpenShop(BaseEntity.RPCMessage)
Passes: VendingMachine vendingMachine, BasePlayer player
WorksReturnBehavior: ExitWhenValidTypeArgumentBehavior: UseArgumentString (this, a0.player)Assembly-CSharp.dll
Where it is called (this branch's game code)
[RPC_Server]
[RPC_Server.IsVisible(3f)]
public void RPC_OpenShop(RPCMessage msg)
{
if (OccupiedCheck(msg.player))
{
if (Interface.CallHook("OnVendingShopOpen", this, msg.player) != null)
{
return;
}
OpenShop(msg.player, customerPanel);
}
}Injection point 2
Rust.opj (Oxide)
void NPCTalking.OnConversationAction(BasePlayer, string)
Passes: InvisibleVendingMachine invisibleVendingMachine, BasePlayer player
Method changed — checkReturnBehavior: ExitWhenValidTypeArgumentBehavior: UseArgumentString (l1, a0)Assembly-CSharp.dll
Where it is called (this branch's game code)
public virtual void OnConversationAction(BasePlayer player, string action)
{
if (action == "openvending")
{
InvisibleVendingMachine vendingMachine = GetVendingMachine();
if (vendingMachine != null && Vector3.Distance(player.transform.position, transform.position) < 5f)
{
ForceEndConversation(player);
if (Interface.CallHook("OnVendingShopOpen", vendingMachine, player) != null)
{
return;
}
vendingMachine.PlayerOpenLoot(player, "vendingmachine.customer", doPositionChecks: false);
return;
}
}
ItemDefinition itemDefinition = ItemManager.FindItemDefinition("scrap");
// …Injection point 3
Rust.opj (Oxide)
void TravellingVendor.SV_OpenMenu(BaseEntity.RPCMessage)
Passes: NPCVendingMachine vendingMachine, BasePlayer player
WorksReturnBehavior: ExitWhenValidTypeArgumentBehavior: UseArgumentString (this.vendingMachine, a0.player)Assembly-CSharp.dll
Where it is called (this branch's game code)
[RPC_Server]
[RPC_Server.IsVisible(3f)]
public void SV_OpenMenu(RPCMessage msg)
{
if (vendingMachine == null)
{
vendingMachine = GetComponentInChildren<NPCVendingMachine>();
}
if (Interface.CallHook("OnVendingShopOpen", this.vendingMachine, msg.player) != null)
{
return;
}
vendingMachine.OpenShop(msg.player, vendingMachine.customerPanel);
}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.