Getting cartridge type of weapon?
Discussion in 'Rust Development' started by Kuhulin, Oct 24, 2016.
-
Null operators (the question marks) are there in case it's a melee weapon, in which that has no magazine.Code:
var ammoType = info?.Weapon?.GetItem()?.GetHeldEntity()?.GetComponent<BaseProjectile>()?.primaryMagazine?.ammoType ?? null; var ammoName = ammoType?.shortname ?? string.Empty;
I pasted the ammo type and ammo name separately, in case you had more things in mind than just the name.
