OnLootEntity
OxideCarbonPlayerCalled when loot entity occurs.
void OnLootEntity(PlayerLoot playerLoot, BaseEntity targetEntity)Works — the game method in this build is the one the hook was written for.
Parameters
- playerLoot
- PlayerLoot
- targetEntity
- BaseEntity
Return value
voidThe return value is ignored — the hook only notifies.
Example
private void OnLootEntity(PlayerLoot playerLoot, BaseEntity targetEntity)
{
Puts("OnLootEntity");
}Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.
Injection point
Rust.opj (Oxide)
void PlayerLoot.StartLootingEntity(BaseEntity, bool)
Passes: PlayerLoot playerLoot, BaseEntity targetEntity
WorksReturnBehavior: ContinueArgumentBehavior: UseArgumentString (this, a0)Assembly-CSharp.dll
Where it is called (this branch's game code)
// …
if (!targetEntity.OnStartBeingLooted(baseEntity))
{
return false;
}
Assert.IsTrue(targetEntity.isServer, "Assure is server");
PositionChecks = doPositionChecks;
entitySource = targetEntity;
itemSource = null;
Interface.CallHook("OnLootEntity", this, targetEntity);
MarkDirty();
if (targetEntity is ILootableEntity lootableEntity)
{
lootableEntity.LastLootedBy = baseEntity.userID;
lootableEntity.LastLootedByPlayer = baseEntity;
}
return true;
}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.