Trying to set the bullets amount inside a weapon, but it seems i can't --'
Copy-Paste for Rust | Oxide
As the weapon is inside a loot container, the usually .HeldEntity() doesn't work to get the BaseProjectile then get the Magazine.
I wasn't able to find a way to get to the magazine from a weapon inside a box :/
Any ideas?
Setting bullets amount
Discussion in 'Rust Development' started by Reneb, Jun 11, 2016.
-
Grabbing the item from the itemList and then using .GetHeldEntity() works for me. Here is some code from my test plugin that is full of useless stuff

Code:private void GetAmmo(StorageContainer container) { var item = container.inventory.itemList[0]; if (item != null) { var heldent = item.GetHeldEntity() as BaseProjectile; var ammo = heldent.primaryMagazine.contents; } } -
.GetHeldEntity works even if the entity is inside a box? and not held by a player?
-
Yep, you just need the Item. Its the same way I collect all the weapon info from a players inventory prior to starting a event.
-
thx
works
