OnPlayerAddModifiers
OxideCarbonPlayerCalled when player add modifiers occurs.
object OnPlayerAddModifiers(BasePlayer player, Item item, ItemModConsumable itemModConsumable)Works — the game method in this build is the one the hook was written for.
Parameters
- player
- BasePlayer
- item
- Item
- itemModConsumable
- ItemModConsumable
Return value
objectThe result is checked in a special way — see the call code below.
Example
object — you can affect the game: return a value to change or cancel the action.
private object OnPlayerAddModifiers(BasePlayer player, Item item, ItemModConsumable itemModConsumable)
{
Puts("OnPlayerAddModifiers");
// 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
Rust.opj (Oxide)
void ItemModConsume.DoAction(Item, BasePlayer)
Passes: BasePlayer player, Item item, ItemModConsumable itemModConsumable
WorksReturnBehavior: CustomAssembly-CSharp.dll
Where it is called (this branch's game code)
// …
else
{
player.metabolism.ApplyChange(effect.type, effect.amount * num3 * num4, effect.time * num3 * num4);
}
}
player.ProcessMissionEvent(BaseMission.MissionEventType.CONSUME, item.info.itemid, 1f);
if (player.modifiers != null)
{
object result = Interface.CallHook("OnPlayerAddModifiers", player, item, consumable);
// … проверка результата (Modify-хук, см. Rust.opj)
player.modifiers.Add(consumable.modifiers);
}
if (product != null)
{
ItemAmountRandom[] array = product;
foreach (ItemAmountRandom itemAmountRandom in array)
{
// …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.