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

FREE ToxicCrossbow : 1.0.1 1.0.1

Нет прав для скачивания
C#:
using ConVar;
using Newtonsoft.Json;
using Oxide.Core.Plugins;
using System.Collections.Generic;

namespace Oxide.Plugins
{
    [Info("ToxicCrossbow", "DezLife", "1.0.1")]
    [Description("Арбалет, который имеет возможность выпустить один заряд радиационной стрелы!")]
    class ToxicCrossbow : RustPlugin
    {
        [PluginReference] Plugin IQChat;

        #region Configuration

        private static Configuration config = new Configuration();
        private class Configuration
        {
            [JsonProperty("SkinID для предмета")]
            public ulong SkinID;
            [JsonProperty("DisplayName для предмета")]
            public string DisplayName;
            [JsonProperty("Количевство радиации каторое будет даваться каждые 3 секунды")]
            public float Radiations;
            [JsonProperty("Радиус излучения")]
            public float RadiationsRadius;
            [JsonProperty("Время действия облучения в секундах")]
            public float RadiationsTime;

            public static Configuration GetNewConfiguration()
            {
                return new Configuration
                {
                    SkinID = 1956876693,
                    DisplayName = "Токсичный арбалет",
                    Radiations = 10,
                    RadiationsRadius = 30,
                    RadiationsTime = 30
                };
            }
        }

        protected override void LoadConfig()
        {
            base.LoadConfig();
            try
            {
                config = Config.ReadObject<Configuration>();
                if (config == null) LoadDefaultConfig();
            }
            catch
            {
                PrintWarning("Ошибка #810" + $"чтения конфигурации 'oxide/config/{Name}', создаём новую конфигурацию!!");
                LoadDefaultConfig();
            }
            NextTick(SaveConfig);
        }

        protected override void LoadDefaultConfig() => config = Configuration.GetNewConfiguration();
        protected override void SaveConfig() => Config.WriteObject(config);

        #endregion

        void OnPlayerAttack(BasePlayer attacker, HitInfo info)
        {
            if (attacker == null) return;
            if (info == null) return;

            if (info.Weapon.skinID == config.SkinID)
                if (info.damageProperties.name == "Damage.Arrow")
                {
                    info.Weapon.GetItem().skin = 0;
                    info.Weapon.GetItem().name = "Арбалет";

                    Timer timers = null;
                    timers = timer.Every(3, () =>
                    {
                        List<BasePlayer> players = new List<BasePlayer>();
                        Vis.Entities<BasePlayer>(info.HitPositionOnRay(), config.RadiationsRadius, players);
                        players.ForEach(p => p.metabolism.radiation_poison.value += config.Radiations);
                    });
                    timer.Once(config.RadiationsTime, () =>
                    {
                        timers.Destroy();
                    });
                }
        }

        #region Metods

        void CreateItem(BasePlayer player)
        {
            Item item = ItemManager.CreateByName("crossbow", 1, config.SkinID);
            item.name = config.DisplayName;
            item.condition = 0.1f;
            player.GiveItem(item);
        }

        #endregion

        #region Commands

        [ConsoleCommand("tc")]
        void ConsoleCommandBlade(ConsoleSystem.Arg arg)
        {
            Puts($"Игроку успешно выдан  {config.DisplayName} !") ;
            BasePlayer player = BasePlayer.FindByID(ulong.Parse(arg.Args[0]));
            if (player == null) return;
            CreateItem(player);
            SendChat($"Вы успешно получили {config.DisplayName}", player);
        }

        #endregion

        #region Helps
        public void SendChat(string Message, BasePlayer player, Chat.ChatChannel channel = Chat.ChatChannel.Global)
        {
            if (IQChat)
                IQChat?.Call("API_ALERT_PLAYER", player, Message);
            else for(int i = 0; i < BasePlayer.activePlayerList.Count; i++)
                {
                    BasePlayer.activePlayerList[i].SendConsoleCommand("chat.add", channel, 0, Message);
                }
        }
        #endregion

    }
}

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