Ok, hello.
In my code i need to move items from inventory to box, all is working good, BUT.
When i try to move weapon - it moves withous mods, e.t.c.
I fixed that with new function MakeWeapon,
But, when i try to copy MEELE weapon i have an error: Object reference not set to an instance of object.Code:{ if (item.info.category.ToString() == "Weapon") { var weapon = original.GetHeldEntity() as BaseProjectile; (item.GetHeldEntity() as BaseProjectile).primaryMagazine.contents = weapon.primaryMagazine.contents; (item.GetHeldEntity() as BaseProjectile).primaryMagazine.ammoType = weapon.primaryMagazine.ammoType; if (original.contents.SlotTaken(0)) { var atta = makeattach(original.contents.GetSlot(0).info.itemid); item.contents.AddItem(atta.info, 1); } if (original.contents.SlotTaken(1)) { var atta = makeattach(original.contents.GetSlot(1).info.itemid); item.contents.AddItem(atta.info, 2); } if (original.contents.SlotTaken(2)) { var atta = makeattach(original.contents.GetSlot(2).info.itemid); item.contents.AddItem(atta.info, 3); } } return item;
So, i need help.
1) How to check, is item - meele weapon?
or
2) How to easily move item from inventory to box?
(Now i am moving items like that
Code:StorageContainer container = Box.GetComponent<StorageContainer>(); PInventory[player.userID] = new Item[player.inventory.containerMain.itemList.Count]; player.inventory.containerMain.itemList.CopyTo(PInventory[player.userID]);foreach (var check in PInventory[player.userID]) { if (check.info.category.ToString() == BoxType || BoxType == "All") { if (container.inventory.IsFull()) { SendReply(player, "space"); PInventory.Remove(player.userID); return; } Traded++; Item create = ItemManager.CreateByItemID(check.info.itemid, check.amount, check.skin); SetModules(create, check); create.MoveToContainer(container.inventory); check.Remove(); } }
Solved Type of weapon
Discussion in 'Rust Development' started by HOUGAN_Y, Jun 19, 2017.