RustTip

OnPlayerCorpseSpawned

OxideCarbonPlayer

Called when a player corpse is spawned.

void OnPlayerCorpseSpawned(BasePlayer basePlayer, PlayerCorpse local3)
Works — the game method in this build is the one the hook was written for.

Parameters

basePlayer
BasePlayer
local3
PlayerCorpse

Return value

voidThe return value is ignored — the hook only notifies.

Example

private void OnPlayerCorpseSpawned(BasePlayer basePlayer, PlayerCorpse local3)
{
    Puts("OnPlayerCorpseSpawned");
}

Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.

Injection point

Rust.opj (Oxide)
BaseCorpse BasePlayer.CreateCorpse(BasePlayer.PlayerFlags, Vector3, Quaternion, List<TriggerBase>, bool)

Passes: BasePlayer basePlayer, PlayerCorpse local3

WorksReturnBehavior: ContinueArgumentBehavior: UseArgumentString (this, l3)Assembly-CSharp.dll

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

// …
		if (lifeStory != null)
		{
			num += Mathf.Clamp(Mathf.FloorToInt(lifeStory.secondsAlive / 180f), 0, 20);
		}
		component2.containedItems.Add(new ItemAmount(ItemManager.FindItemDefinition("fat.animal"), num));
		return playerCorpse;
	}
}
Interface.CallHook("OnPlayerCorpseSpawned", this, playerCorpse);
return null;
static float GetFloatBasedOnUserID(ulong steamid, ulong seed)
{
	Random.State state = Random.state;
	Random.InitState((int)(seed + steamid));
	float result = Random.Range(0f, 1f);
	Random.state = state;
	return result;
// …

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.