1. itemObj = ItemManager.CreateByItemID(item['itemID'], item['Amount'])

    Can anyone help me with this Python plugin update. How do I use the CreateByItemID in Python?
    [DOUBLEPOST=1453658105,1453442127][/DOUBLEPOST]@Wulf

    Can you help me here?!
     
  2. Wulf is not a python guy as far as I know :p
     
  3. Aren't you? I steam messaged you you about this too.
     
  4. Nope. I am not.
     
  5. I'm using ItemManager.CreateByItemID in a Python plugin I'm developing, so I've boiled it down to a tiny working example of how you might use it without a ton of unrelated garbage.

    This plugin (should) add a candy cane to any entity as it spawns with an inventory if there's room. I added a print statement just to make it clear that it's doing things.

    Code:
    import Rust
    import ItemManager
    import ItemContainerclass FreeCandy:
        def __init__(self):
            self.Title = "FreeCandy"
            self.Author = "Hoober"
            self.Version = V(0, 0, 1)
            self.HasConfig = False    def OnEntitySpawned(self, entity):
            if hasattr(entity, "inventory") and type(entity.inventory) == ItemContainer:
                candy_cane = ItemManager.CreateByItemID(523409530)
                candy_cane.MoveToContainer(entity.inventory, -1, False);            # If there's a better way to get a clean name, I'd love to find it
                prefab_name = entity.ToString().split("/")[-1].split(".prefab")[0]
                print "Adding candy to {}".format(prefab_name)
    

    If you want a testable example that you won't need to wait on (spawns can take a while), you could do this instead and then just go hit any barrel, crate, chest, etc. to add blood to it.
    Code:
        def OnEntityTakeDamage(self, entity, info):
            if hasattr(entity, "inventory") and type(entity.inventory) == ItemContainer:
                blood = ItemManager.CreateByItemID(93832698)
                blood.MoveToContainer(entity.inventory, -1, False);            prefab_name = entity.ToString().split("/")[-1].split(".prefab")[0]
                print "Adding blood to {}".format(prefab_name)