Иконка ресурса

FREE ForestBerries : 1.0.3 1.0.3

Нет прав для скачивания
C#:
using Random = UnityEngine.Random;
using Newtonsoft.Json;
using System.Collections.Generic;

namespace Oxide.Plugins
{
    [Info("Forest Berries", "Castom", "1.0.3")]
    class ForestBerries : RustPlugin
    {
	    
	     private Configurarion config;
        public class Configurarion
        {
            [JsonProperty(PropertyName = "[Record Items]")]
            public Dictionary<string, ItemRecord> items = new Dictionary<string, ItemRecord>();
                internal class ItemRecord
                {                   
                    [JsonProperty(PropertyName = "Collectible Pickup Item Name")]
                    public string pickupName;
                    
                    [JsonProperty(PropertyName = "Shortname Item That Will Drop")]
                    public string itemDropped;
                    
                    [JsonProperty(PropertyName = "Chance To Drop Item")]
                    public float chance;

                    [JsonProperty(PropertyName = "Min Amount To Drop")]
                    public int amountMin;
                    
	                [JsonProperty(PropertyName = "Max Amount To Drop")]
	                public int amountMax;
                }

              
        }
    
       

        protected override void LoadDefaultConfig()
        {

	        config = new Configurarion()
            {
                items = new Dictionary<string, Configurarion.ItemRecord>{
                   ["Mushroom"] =  new Configurarion.ItemRecord() {
                        pickupName = "Mushroom",
                        itemDropped = "black.berry",
                        chance  = 100,
                        amountMin = 10,
                        amountMax = 10
                    },
                   ["Sulfur"] =  new Configurarion.ItemRecord() {
	                   pickupName = "Sulfur Ore",
	                   itemDropped = "black.berry",
	                   chance  = 100,
	                   amountMin = 10,
	                   amountMax = 10
                   },
                }
            };
            SaveConfig();
        }
        
        protected override void SaveConfig() => Config.WriteObject(config);

        private void Loaded()
        {
            try
            {
                config = Config.ReadObject<Configurarion>();
            }
            catch
            {
                LoadDefaultConfig();
            }
        }
        

        
		object OnCollectiblePickup(CollectibleEntity item, BasePlayer player)
{	
		// player.ChatMessage(item.itemName.english); To debug the name of the item you need
		// player.ChatMessage(item.itemName.token);   Delete // to enable :)

				var configItem = config.items.Values;
				foreach (var settings in configItem)
				{	
					if (item.itemName.english.Contains(settings.pickupName) || item.itemName.token.Contains(settings.pickupName))
					{
						if (Random.Range(0f, 100f) < settings.chance) //Шанс выпадения ягод : Chance of berries falling out
						{
							var amount = Random.Range(settings.amountMin, settings.amountMax); //Рандомное количество ягод за один сбор (от 1 до 3) : Random number of berries per harvest (from 1 to 3)
							Item berry = ItemManager.CreateByName(settings.itemDropped, amount);
							player.inventory.GiveItem(berry);
						} 
					}
				
			}


			return null;
       }

    }
}

Автор
15FPS
Скачиваний
0
Просмотры
1
Первый выпуск
Обновление
Оценка
0.00 звёзд 0 оценок
Сверху