RustTip

OnItemSubmit

OxideCarbonItem

Called when item submit occurs.

object OnItemSubmit(Item local1, Mailbox mailbox, BasePlayer fromPlayer)
object OnItemSubmit()
Works — the game method in this build is the one the hook was written for.

Parameters

local1
Item
mailbox
Mailbox
fromPlayer
BasePlayer

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 OnItemSubmit(Item local1, Mailbox mailbox, BasePlayer fromPlayer)
{
    Puts("OnItemSubmit");

    // 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 1

Rust.opj (Oxide)
void Mailbox.SubmitInputItems(BasePlayer)

Passes: Item local1, Mailbox mailbox, BasePlayer fromPlayer

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

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

public void SubmitInputItems(BasePlayer fromPlayer)
{
	for (int i = 0; i < InputContainer.capacity; i++)
	{
		Item slot = InputContainer.GetSlot(i);
		if (Interface.CallHook("OnItemSubmit", slot, this, fromPlayer) != null)
		{
			return;
		}
		if (slot == null || !slot.MoveToContainer(inventory))
		{
			continue;
		}
		Effect.server.Run(mailDropSound.resourcePath, GetDropPosition());
// …

Injection point 2

Rust.opj (Oxide)
void Mailbox.SubmitInputItems(BasePlayer)

Passes: —

WorksReturnBehavior: CustomAssembly-CSharp.dll

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

public void SubmitInputItems(BasePlayer fromPlayer)
{
	for (int i = 0; i < InputContainer.capacity; i++)
	{
		Item slot = InputContainer.GetSlot(i);
		object result = Interface.CallHook("OnItemSubmit");
		// … проверка результата (Modify-хук, см. Rust.opj)
		if (slot == null || !slot.MoveToContainer(inventory))
		{
			continue;
		}
		Effect.server.Run(mailDropSound.resourcePath, GetDropPosition());
		if (fromPlayer != null && !PlayerIsOwner(fromPlayer))
		{
// …

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.