Wrong list used for halloween bags and eggsFixed

Hi FastBurn

Thanks for your great work with all your plugins - you make rust a better game!

I am preparing for Easter and set up item lists for silver and gold eggs, but when I tested silver eggs they used wrong item list.

I checked you code and found an error in the methos CreateItems. For all halloween lootbags and easter eggs you use largeList (large presents item list) you need to use mediumListHalloween/largeListHalloween/mediumListEaster/largeListEaster respectively (inside each case you use list twice - when you call CheckFor100Items and when you call TryMakeItem).

I fixed it in my local version of the plugin and it works like a charm when the right lists are used.

I hope this will help you fix the little mistake that is currently making halloween bag and eggs use wrong list.

Thanks again for your great work!

/David

If you have a fix message me with the updated file and I will take a look at it.

 private List<Item> CreateItems(string presentname)
        {
            List<Item> x = new List<Item>();
            int itemCount = 0;
            switch (presentname)
            {
                case "xmas.present.small":
                    {
                        if (sureItemsWillAlwaysSpawn)
                            foreach (var entry in CheckFor100Items(smallList))
                            {
                                x.Add(entry);
                                itemCount++;
                            }
                        int maxItemAmount = Mathf.RoundToInt(UnityEngine.Random.Range(Convert.ToSingle(smallMinItems), Convert.ToSingle(smallMaxItems)));
                        while (itemCount < maxItemAmount)
                        {
                            Item item = TryMakeItem(smallList);
                            if (item == null)
                                continue;
                            x.Add(item);
                            itemCount++;
                        }
                        return x;
                    }

                case "xmas.present.medium":
                    {
                        if (sureItemsWillAlwaysSpawn)
                            foreach (var entry in CheckFor100Items(mediumList))
                            {
                                x.Add(entry);
                                itemCount++;
                            }
                        int maxItemAmount = Mathf.RoundToInt(UnityEngine.Random.Range(Convert.ToSingle(mediumMinItems), Convert.ToSingle(mediumMaxItems)));
                        while (itemCount < maxItemAmount)
                        {
                            Item item = TryMakeItem(mediumList);
                            if (item == null)
                                continue;
                            x.Add(item);
                            itemCount++;
                        }
                        return x;
                    }

                case "xmas.present.large":
                    {
                        if (sureItemsWillAlwaysSpawn)
                            foreach (var entry in CheckFor100Items(largeList))
                            {
                                x.Add(entry);
                                itemCount++;
                            }
                        int maxItemAmount = Mathf.RoundToInt(UnityEngine.Random.Range(Convert.ToSingle(largeMinItems), Convert.ToSingle(largeMaxItems)));
                        while (itemCount < maxItemAmount)
                        {
                            Item item = TryMakeItem(largeList);
                            if (item == null)
                                continue;
                            x.Add(item);
                            itemCount++;
                        }
                        return x;
                    }
                case "halloween.lootbag.medium":
                    {
                        if (sureItemsWillAlwaysSpawn)
                            foreach (var entry in CheckFor100Items(mediumListHalloween))
                            {
                                x.Add(entry);
                                itemCount++;
                            }
                        int maxItemAmount = Mathf.RoundToInt(UnityEngine.Random.Range(Convert.ToSingle(largeMinItems), Convert.ToSingle(mediumMaxBagsItems)));
                        while (itemCount < maxItemAmount)
                        {
                            Item item = TryMakeItem(mediumListHalloween);
                            if (item == null)
                                continue;
                            x.Add(item);
                            itemCount++;
                        }
                        return x;
                    }
                case "halloween.lootbag.large":
                    {
                        if (sureItemsWillAlwaysSpawn)
                            foreach (var entry in CheckFor100Items(largeListHalloween))
                            {
                                x.Add(entry);
                                itemCount++;
                            }
                        int maxItemAmount = Mathf.RoundToInt(UnityEngine.Random.Range(Convert.ToSingle(largeMinItems), Convert.ToSingle(largeMaxBagsItems)));
                        while (itemCount < maxItemAmount)
                        {
                            Item item = TryMakeItem(largeListHalloween);
                            if (item == null)
                                continue;
                            x.Add(item);
                            itemCount++;
                        }
                        return x;
                    }
                case "easter.silveregg":
                    {
                        if (sureItemsWillAlwaysSpawn)
                            foreach (var entry in CheckFor100Items(mediumListEaster))
                            {
                                x.Add(entry);
                                itemCount++;
                            }
                        int maxItemAmount = Mathf.RoundToInt(UnityEngine.Random.Range(Convert.ToSingle(largeMinItems), Convert.ToSingle(mediumMaxEggsItems)));
                        while (itemCount < maxItemAmount)
                        {
                            Item item = TryMakeItem(mediumListEaster);
                            if (item == null)
                                continue;
                            x.Add(item);
                            itemCount++;
                        }
                        return x;
                    }
                case "easter.goldegg":
                    {
                        if (sureItemsWillAlwaysSpawn)
                            foreach (var entry in CheckFor100Items(largeListEaster))
                            {
                                x.Add(entry);
                                itemCount++;
                            }
                        int maxItemAmount = Mathf.RoundToInt(UnityEngine.Random.Range(Convert.ToSingle(largeMinItems), Convert.ToSingle(largeMaxEggsItems)));
                        while (itemCount < maxItemAmount)
                        {
                            Item item = TryMakeItem(largeListEaster);
                            if (item == null)
                                continue;
                            x.Add(item);
                            itemCount++;
                        }
                        return x;
                    }
            }
            return x;
        }


Merged post

Here is the new CreateItems method - just replace old method in plugin.

Thanks for the good catch updated and corrected.

Locked automatically