How would I detect what type of ammo ATTACKER used to killed VICTIM (ie HV, Explosive or Incendiary) using OnEntityDeath?
I currently use
to get the Weapon Name.Code:var weapon = info?.Weapon?.GetItem().info?.displayName?.english?.ToString()
Getting ammo type from OnEntityDeath (C#)
Discussion in 'Rust Development' started by mvrb, Oct 13, 2015.
-
Try this:
Code:string ammoType = info?.Weapon?.GetItem().GetHeldEntity().primaryMagazine.ammoType?.displayName.english
-
Thanks for your reply.
When I add that line and try to compile it it says:
Line 56 is the code you sent me.Code:[Oxide] 2:12 PM [Error] Damage.cs(76,59): error CS1061: Type `BaseEntity' does n ot contain a definition for `primaryMagazine' and no extension method `primaryMa gazine' of type `BaseEntity' could be found. Are you missing an assembly referen ce?
-
Right. I forgot something. This working fine.
Code:var weapon = info?.Weapon?.GetItem()?.GetHeldEntity() as BaseProjectile ?? null; if (!weapon) return; string ammoType = weapon.primaryMagazine.ammoType?.displayName.english ?? "Melee";
-
That works, thank you very much!
