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

FREE KillOptions : 1.0.0 1.0.0

Нет прав для скачивания
C#:
/*
 * Exotic Plugins © 2021
 * Stealing my plugins is prohibited (even if you edited them)
 * Sharing my plugins with others is prohibited
 * For support join our discord - https://discord.gg/YnbYaugRMh
 */

using System.Collections.Generic;
using Newtonsoft.Json;

namespace Oxide.Plugins
{
    [Info("Kill Options", "Tryhard", "1.0.0")]
    [Description("Refills players magazine, heals the player and stops bleeding after getting a kill")]
    public class KillOptions : RustPlugin
    {
        #region Config

        private ConfigFile _config;

        private class ConfigFile
        {
            [JsonProperty("Fill player magazine after getting a kill")]
            public bool eAmmo = true;
            [JsonProperty("Heal player after getting a kill")]
            public bool eHealth = true;
            [JsonProperty("Stop bleeding after getting a kill")]
            public bool eBleed = true;
        }

        protected override void LoadConfig()
        {
            base.LoadConfig();

            try
            {
                _config = Config.ReadObject<ConfigFile>();

                if (_config == null) LoadDefaultConfig();
            }

            catch
            {
                PrintError("Configuration file is corrupt, check your config file at https://jsonlint.com/!");
                LoadDefaultConfig();
                return;
            }

            SaveConfig();
        }

        protected override void LoadDefaultConfig() => _config = new ConfigFile();

        protected override void SaveConfig() => Config.WriteObject(_config);

        #endregion

        #region Language

        protected override void LoadDefaultMessages()
        {
            lang.RegisterMessages(new Dictionary<string, string>
            {
                ["aRefill"] = "You just killed {0}"
            }, this);
        }

        #endregion

        #region Hooks

        private void Init() => permission.RegisterPermission("KillOptions.on", this);

        private void OnPlayerDeath(BasePlayer victim, HitInfo hitInfo)
        {
            if (hitInfo == null || victim == null || victim.IsNpc) return;

            var attacker = hitInfo.InitiatorPlayer;

            if (attacker == victim || attacker == null) return;
         
            var projectile = attacker.GetHeldEntity() as BaseProjectile;
                
            if (attacker is BasePlayer && victim is BasePlayer)
            {
                if (permission.UserHasPermission(attacker.UserIDString, "KillOptions.on"))
                {
                    SendReply(attacker, lang.GetMessage("aRefill", this, victim.UserIDString), victim.displayName);

                    if (_config.eAmmo)
                    {
                        if (projectile == null)
                        {
                            return;
                        }

                        projectile.TopUpAmmo();
                        projectile.SendNetworkUpdateImmediate();
                    }

                    if (_config.eHealth)
                    {
                        attacker.Heal(100f);
                    }

                    if (_config.eHealth)
                    {
                        attacker.metabolism.bleeding.value = 0;
                    }
                }
            }
        }
        #endregion
    }
}

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