RustTip

CanBeAwardedAdventGift

OxideCarbonSeasonal

Called to determine whether the entity can be awarded advent gift.

Return true to allow the action and false to block it.

object CanBeAwardedAdventGift(AdventCalendar adventCalendar, BasePlayer player)
Works — the game method in this build is the one the hook was written for.

Parameters

adventCalendar
AdventCalendar
player
BasePlayer

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 CanBeAwardedAdventGift(AdventCalendar adventCalendar, BasePlayer player)
{
    Puts("CanBeAwardedAdventGift");

    // 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)
bool AdventCalendar.WasAwardedTodaysGift(BasePlayer)

Passes: AdventCalendar adventCalendar, BasePlayer player

WorksReturnBehavior: CustomAssembly-CSharp.dll

Where it is called (this branch's game code)

public bool WasAwardedTodaysGift(BasePlayer player)
{
	object result = Interface.CallHook("CanBeAwardedAdventGift", this, player);
	// … проверка результата (Modify-хук, см. Rust.opj)
	if (!playerRewardHistory.ContainsKey(player.userID))
	{
		return false;
	}
	DateTime now = DateTime.Now;
	if (((overrideAdventCalendarMonth > 0) ? overrideAdventCalendarMonth : now.Month) != startMonth)
	{
// …

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.