OnDispenserBonus
OxideCarbonResourceCalled when dispenser bonus occurs.
object OnDispenserBonus(ResourceDispenser resourceDispenser, BasePlayer player, object l4 => l4)Method changed — check — the game method differs from the one the hook is recorded for in Oxide. The hook is still called, but its place may have shifted — worth checking after an update.
Parameters
- resourceDispenser
- ResourceDispenser
- player
- BasePlayer
- l4 => l4
- 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 OnDispenserBonus(ResourceDispenser resourceDispenser, BasePlayer player, object l4 => l4)
{
Puts("OnDispenserBonus");
// change nothing — the game continues as usual
return null;
// to affect the game:
// return default(Item); // 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 ResourceDispenser.AssignFinishBonus(BasePlayer, float, AttackEntity)
Passes: ResourceDispenser resourceDispenser, BasePlayer player, object l4 => l4
Method changed — checkReturnBehavior: UseArgumentStringArgumentBehavior: UseArgumentString (this, a0, l4 => l4)Assembly-CSharp.dll
Where it is called (this branch's game code)
// …
return;
}
foreach (ItemAmount finishBonu in finishBonus)
{
int num = Mathf.CeilToInt((float)(int)finishBonu.amount * Mathf.Clamp01(fraction));
int num2 = CalculateGatherBonus(player, finishBonu, num);
int iAmount = BaseGameMode.ScaleGatherAmount(num + num2);
Item item = ItemManager.Create(finishBonu.itemDef, iAmount, 0uL, isServerSide: true, 0uL);
Interface.CallHook("OnDispenserBonus", this, player, l4 => l4);
if (item != null)
{
ApplyItemOwnership(player, item);
Analytics.Azure.OnGatherItem(item.info.shortname, item.amount, baseEntity, player, weapon);
while (item.amount > item.MaxStackable())
{
Item item2 = item.SplitItem(item.MaxStackable());
player.GiveItem(item2, BaseEntity.GiveItemReason.ResourceHarvested, GiveItemOptions.BackpackOverflow);
// …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.