Rust NPC loot drops

Discussion in 'Plugin Requests' started by Wombat, Jul 1, 2017.

  1. is there anyway i can get this dude to drop random loot on his body when getting killed i dont want to do the long process of making kits for 20 ish npcs lol


    [​IMG]

    [​IMG]
     
  2. Code:
    void OnEntityDeath(BaseCombatEntity entity, HitInfo info)
            {
                if (entity.ShortPrefabName == "zombie")
                {
                    var random = ListLootZombie.GetRandom();
                    ItemManager.CreateByItemID(random.itemID, random.count).Drop(new Vector3(0, 2f, 0f)+ entity.transform.position, new Vector3(0, -0.005f, 0));
                }
            }
    ListLootZombie.Add(new ZombieLoot() { itemID = -533875561, count = 10 });
    class ZombieLoot
            {
                public int itemID { get; set; }
                public int count { get; set; }
            }
    List<ZombieLoot> ListLootZombie = new List<ZombieLoot>();
     

  3. where would i put this bud ?
     
  4. Wulf

    Wulf Community Admin

    Wherever you want really, they're just showing how you can do what you want. If you're looking for a full plugin, you may want to post a plugin request.
     
  5. ahh ok lol that would be nice if anyone would like to make me one please not anything to special just want to beable to assign npc ids and have them drop random loot on death :D
     
  6. ok getting somewhere with help from @Kappasaurus (Thanks for helping me ) but getting this error in console if anyone has any pointers :)

    Code:
     (18:18:03) | [Oxide] 18:18 [Error] Failed to call hook 'OnKillNPC' on plugin 'NPCRewards v1.0.0' (InvalidCastException: Cannot cast from source type to destination type.)
    (18:18:03) | [Oxide] 18:18 [Stacktrace]   at Oxide.Plugins.NPCRewards.DirectCallHook (System.String name, System.Object& ret, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.CSharpPlugin.InvokeMethod (HookMethod method, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Core.Plugins.CSPlugin.OnCallHook (System.String name, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Core.Plugins.Plugin.CallHook (System.String hook, System.Object[] args) [0x00000] in <filename unknown>:0