OnCuttingTake
OxideCarbonPlayerobject OnCuttingTake(GrowableEntity growableEntity, BasePlayer player, Item local1)
object OnCuttingTake(object arg0)Works — the game method in this build is the one the hook was written for.
Parameters
- growableEntity
- GrowableEntity
- player
- BasePlayer
- local1
- Item
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 OnCuttingTake(GrowableEntity growableEntity, BasePlayer player, Item local1)
{
Puts("OnCuttingTake");
// 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 GrowableEntity.TakeClones(BasePlayer)
Passes: GrowableEntity growableEntity, BasePlayer player, Item local1
WorksReturnBehavior: ExitWhenNonNullArgumentBehavior: UseArgumentString (this, a0, l1)Assembly-CSharp.dll
Where it is called (this branch's game code)
// …
return;
}
int num = Properties.BaseCloneCount + Genes.GetGeneTypeCount(GrowableGenetics.GeneType.Yield) / 2;
if (num > 0)
{
Item item = ItemManager.Create(Properties.CloneItem, num, 0uL, isServerSide: true, 0uL);
item.SetItemOwnership(player, ItemOwnershipPhrases.Cloned);
GrowableGeneEncoding.EncodeGenesToItem(this, item);
if (Interface.CallHook("OnCuttingTake", this, player, item) != null)
{
return;
}
Analytics.Azure.OnGatherItem(item.info.shortname, item.amount, this, player);
player.GiveItem(item, GiveItemReason.ResourceHarvested, GiveItemOptions.BackpackOverflow);
if (Properties.pickEffect.isValid)
{
Effect.server.Run(Properties.pickEffect.resourcePath, transform.position, Vector3.up);
// …Injection point 2
Rust.opj (Oxide)
void GrowableEntity.TakeClones(BasePlayer)
Passes: object arg0
WorksReturnBehavior: ContinueAssembly-CSharp.dll
Where it is called (this branch's game code)
// …
int num = Properties.BaseCloneCount + Genes.GetGeneTypeCount(GrowableGenetics.GeneType.Yield) / 2;
if (num > 0)
{
Item item = ItemManager.Create(Properties.CloneItem, num, 0uL, isServerSide: true, 0uL);
item.SetItemOwnership(player, ItemOwnershipPhrases.Cloned);
GrowableGeneEncoding.EncodeGenesToItem(this, item);
Analytics.Azure.OnGatherItem(item.info.shortname, item.amount, this, player);
player.GiveItem(item, GiveItemReason.ResourceHarvested, GiveItemOptions.BackpackOverflow);
Interface.CallHook("OnCuttingTake", item.Remove(0f));
if (Properties.pickEffect.isValid)
{
Effect.server.Run(Properties.pickEffect.resourcePath, transform.position, Vector3.up);
}
TellPlanter();
Die();
}
}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.