RustTip

OnTeamMemberInvite

OxideTeam
object OnTeamMemberInvite(RelationshipManager.PlayerTeam playerTeam, BasePlayer basePlayer, ulong uInt64, object true)
object OnTeamMemberInvite(BasePlayer basePlayer, EncryptedValue<ulong> userID, object arg2, object arg3)
Works — the game method in this build is the one the hook was written for.

Parameters

playerTeam
RelationshipManager.PlayerTeam
basePlayer
BasePlayer
uInt64
ulong
true
object

Return value

objectReturn a value of the method's result type and the game returns it immediately; null continues as usual.

Example

object — you can affect the game: return a value to change or cancel the action.

private object OnTeamMemberInvite(RelationshipManager.PlayerTeam playerTeam, BasePlayer basePlayer, ulong uInt64, object true)
{
    Puts("OnTeamMemberInvite");

    // 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 1

Rust.opj (Oxide)
void RelationshipManager.sendofflineinvite(ConsoleSystem.Arg)

Passes: RelationshipManager.PlayerTeam playerTeam, BasePlayer basePlayer, ulong uInt64, object true

WorksReturnBehavior: ExitWhenValidTypeArgumentBehavior: UseArgumentString (l1, l0, l2, true)Assembly-CSharp.dll

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

// …
	{
		BasePlayer basePlayer2 = BasePlayer.FindAwakeOrSleepingByID(uLong);
		if (basePlayer2 != null && !basePlayer2.GetInfoBool("client.allowteaminvitesremoteplayers", defaultVal: true))
		{
			basePlayer.ShowToast(GameTip.Styles.Error, RemoteInvitesBlocked, false);
		}
		else if (basePlayer2 == null || (!basePlayer2.IsNpc && basePlayer2.currentTeam == 0L))
		{
			if (Interface.CallHook("OnTeamMemberInvite", playerTeam, basePlayer, uLong, true) != null)
			{
				return;
			}
			playerTeam.SendInvite(basePlayer2, uLong);
		}
	}
}

Injection point 2

Rust.opj (Oxide)
void RelationshipManager.sendinvite(ConsoleSystem.Arg)

Passes: BasePlayer basePlayer, EncryptedValue<ulong> userID, object arg2, object arg3

WorksReturnBehavior: ExitWhenNonNullAssembly-CSharp.dll

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

// …
		return;
	}
	BasePlayer basePlayer2 = BaseNetworkable.serverEntities.Find(new NetworkableId(uLong)) as BasePlayer;
	if ((bool)basePlayer2 && basePlayer2 != basePlayer && !basePlayer2.IsNpc && basePlayer2.currentTeam == 0L)
	{
		float num = 7f;
		if (!(Vector3.Distance(basePlayer2.transform.position, basePlayer.transform.position) > num))
		{
			if (Interface.CallHook("OnTeamMemberInvite", basePlayer, basePlayer2.userID, EncryptedValue.Get(), 0) != null)
			{
				return;
			}
			playerTeam.SendInvite(basePlayer2);
		}
	}
}

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.