I am having a little trouble figuring our what properties of an item contain the map / lock data in order to duplicate the item.
Any pointers or examples would be greatly appreciated, I did search but couldn't find anything, not entirely sure I know what I am looking for either >.<
Edit, updated:
Code:private Item copyItem(Item item) { Item copy = ItemManager.CreateByItemID(item.info.itemid, item.amount, item.IsBlueprint()); // If weapon get ammo type and amount var weapon = item.GetHeldEntity() as BaseProjectile; if (weapon != null) { (copy.GetHeldEntity() as BaseProjectile).primaryMagazine.contents = weapon.primaryMagazine.contents; (copy.GetHeldEntity() as BaseProjectile).primaryMagazine.ammoType = weapon.primaryMagazine.ammoType; } // If map copy images var map = item.GetHeldEntity() as MapEntity; if (map != null) { (copy.GetHeldEntity() as MapEntity).fogImages = map.fogImages; (copy.GetHeldEntity() as MapEntity).paintImages = map.paintImages; } copy.skin = item.skin; copy.condition = item.condition; copy.instanceData = item.instanceData; copy.contents = item.contents; return copy; }
Solved C# copying items, maps and key data
Discussion in 'Rust Development' started by Kayzor, Aug 14, 2015.
-
item.GetHeldEntity() as MapEntity? and what lock data do you want?
-
Perfect! Just what I needed for the map thanks
For the lock I was referring to the door.key item but I have just found that the lock information is contained in item.instanceData -
I am trying to copy a gun, it copies the attachments but then the contents of the gun becomes glitched and the attachments wont view, removing the attachment will give you it but then the slots of the weapon become glitched and cant accept attachments again.
-
Code:
copy.contents = item.contents;
You should create a new instance of every item in item.contents and only then move it to copy.contents.
You may use copyItem(Item item) in recursion for neatness. -
can you please show me an example of copying an item and its contents please