CanMoveItem
OxideCarbonItemCalled to determine whether to move item.
Return true to allow the action and false to block it.
object CanMoveItem(Item local5, PlayerInventory playerInventory, ItemContainerId local1, int local2, int local3, ItemMoveModifier local4)Works — the game method in this build is the one the hook was written for.
Parameters
- local5
- Item
- playerInventory
- PlayerInventory
- local1
- ItemContainerId
- local2
- int
- local3
- int
- local4
- ItemMoveModifier
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 CanMoveItem(Item local5, PlayerInventory playerInventory, ItemContainerId local1, int local2, int local3, ItemMoveModifier local4)
{
Puts("CanMoveItem");
// 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
Rust.opj (Oxide)
void PlayerInventory.MoveItem(BaseEntity.RPCMessage)
Passes: Item local5, PlayerInventory playerInventory, ItemContainerId local1, int local2, int local3, ItemMoveModifier local4
WorksReturnBehavior: ExitWhenValidTypeArgumentBehavior: UseArgumentString (l5, this, l1, l2, l3, l4)Assembly-CSharp.dll
Where it is called (this branch's game code)
// …
Item item = FindItemByUID(id);
if (item == null)
{
msg.player.ShowToast(GameTip.Styles.Error, PlayerInventoryErrors.InvalidItem, false);
ConstructionErrors.Log(msg.player, id.ToString());
}
else
{
if (Interface.CallHook("CanMoveItem", item, this, itemContainerId, num, num2, itemMoveModifier) != null)
{
return;
}
if (item.IsLocked() || (item.parent != null && item.parent.IsLocked()))
{
return;
}
BaseEntity entityOwner = item.GetEntityOwner();
// …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.