RustTip

OnXmasGiftsDistribute

OxideCarbonSeasonal

Called when xmas gifts distribute occurs.

object OnXmasGiftsDistribute(XMasRefill xMasRefill, BasePlayer player)
Works — the game method in this build is the one the hook was written for.

Parameters

xMasRefill
XMasRefill
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 OnXmasGiftsDistribute(XMasRefill xMasRefill, BasePlayer player)
{
    Puts("OnXmasGiftsDistribute");

    // 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 XMasRefill.DistributeGiftsForPlayer(BasePlayer)

Passes: XMasRefill xMasRefill, BasePlayer player

WorksReturnBehavior: CustomAssembly-CSharp.dll

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

public bool DistributeGiftsForPlayer(BasePlayer player)
{
	object result = Interface.CallHook("OnXmasGiftsDistribute", this, player);
	// … проверка результата (Modify-хук, см. Rust.opj)
	int num = GiftsPerPlayer();
	int num2 = GiftSpawnAttempts();
	for (int i = 0; i < num2; i++)
	{
		if (num <= 0)
		{
			break;
// …

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.