OnItemUse
OxideCarbonItemCalled when an item uses.
object OnItemUse(Item item, object a0 => a0)Works — the game method in this build is the one the hook was written for.
Parameters
- item
- Item
- a0 => a0
- object
Return value
objectThe returned value modifies the result, the game continues.
Example
object — you can affect the game: return a value to change or cancel the action.
private object OnItemUse(Item item, object a0 => a0)
{
Puts("OnItemUse");
// change nothing — the game continues as usual
return null;
// to affect the game:
// return default(int); // your value instead of the game result
}Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.
Injection point
Rust.opj (Oxide)
void Item.UseItem(int)
Passes: Item item, object a0 => a0
WorksReturnBehavior: UseArgumentStringArgumentBehavior: UseArgumentString (this, a0 => a0)Assembly-CSharp.dll
Where it is called (this branch's game code)
public void UseItem(int amountToConsume = 1)
{
if (amountToConsume > 0)
{
Interface.CallHook("OnItemUse", this, a0 => a0);
amount -= amountToConsume;
ReduceItemOwnership(amountToConsume);
if (amount <= 0)
{
amount = 0;
Remove();
}
else
// …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.