Помогите Проблема с кодом

schwf3xlr

22 Фев 2022
36
1
0
C#:
using Oxide.Game.Rust.Cui;
using System.Collections.Generic;

namespace Oxide.Plugins {
      [Info("Health Bar", "Obkurenniy", "1.0")]

    class HealthBar : RustPlugin
    {
        
        class GuiControl
        {
            private Dictionary<BasePlayer, Timer> _Timers = new Dictionary<BasePlayer, Timer>();
            private readonly PluginTimers timer;
            private readonly float destroySeconds;

            public GuiControl(PluginTimers timer, float destroySeconds)
            {
                this._Timer = timer;
                this._DestroySeconds = destroySeconds;
            }

            public void TriggerDamage(BasePlayer player, float health, float maxHealth)
            {
                RemovePlayer(player);
                var progress = health / maxHealth + "";
                var healthText = (int)health + "";
                DrawUI(player, progressText, healthText);
                AddPlayer(player);
            }
            
            public void TriggerDeath(BasePlayer player)
            {
                RemovePlayer(player);
                var progress = "0";
                var healthText = "Убит";
                DrawUI(player, progressText, healthText);
                AddPlayer(player);
            }

            void AddPlayer(BasePlayer player)
            {
                _Timers[player] = _Timer.Once(_DestroySeconds, () =>
                {
                    RemovePlayer(player);
                });
            }

            void RemovePlayer(BasePlayer player)
            {
                Timer pTimer;
                if(_Timers.TryGetValue(player, out pTimer))
                {
                   _Timer.Destroy(ref pTimer);
                   DestroyUI(player);
                   _Timers.Remove(player);
                }
            }

            void DrawUI(BasePlayer player, string progress, string text)
            {
                string json = CUI_MAIN
                .Replace("{progress}", progress)
                .Replace("{text}", text);
                CuiHelper.AddUi(player, json);
            }

            void DestroyUI(BasePlayer player)
            {
                CuiHelper.DestroyUi(player, "hpbar_background");
            }
        }

        GuiControl _GuiControl;

        void Loaded()
        {
           _GuiControl = new GuiControl(timer, 5f);
        }

        void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info)
        {
            var player = info.InitiatorPlayer;
            if (player && player.IsAlive())
            {
                NextTick(() =>
                {
                    if (entity.IsAlive() && player?.IsConnected == true)
                    {
                        var health = entity.health;
                        var maxHealth = entity.MaxHealth();

                        var progress = health / maxHealth;
                        var text = (int) health;
                        _GuiControl.TriggerDamage(player, health, maxHealth);
                    }

                });
            }
        }

        void OnEntityDeath(BaseCombatEntity entity, HitInfo info)
        {
            var player = info.InitiatorPlayer;
            if (player && player.IsAlive())
            {
                _GuiControl.TriggerDeath(player);
            }
        }

        [ChatCommand("testgui")]
        void cmdChatTestGui(BasePlayer player)
        {
            string json = CUI_MAIN
            .Replace("{progress}", "0.5")
            .Replace("{text}", "50");

            CuiHelper.AddUi(player, json);
            timer.Once(10f, () => {
                CuiHelper.DestroyUi(player, "hpbar_background");
            });
        }

            string CUI_MAIN = @"
            [
  {
    ""name"": ""hpbar_background"",
    ""parent"": ""Overlay"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""material"": """",
        ""color"": ""0.5254902 0.5254902 0.5254902 0.2980392""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0.5 0"",
        ""anchormax"": ""0.5 0"",
        ""offsetmin"": ""-106 86"",
        ""offsetmax"": ""86 112""
      }
    ]
  },
  {
    ""name"": ""hpbar_img"",
    ""parent"": ""hpbar_background"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""sprite"": ""assets/icons/health.png"",
        ""material"": ""assets/icons/iconmaterial.mat"",
        ""color"": ""0.9686275 0.9176471 0.8784314 0.6745098""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""0 1"",
        ""offsetmin"": ""4 4"",
        ""offsetmax"": ""22 -4""
      }
    ]
  },
  {
    ""name"": ""hpbar_wrapper"",
    ""parent"": ""hpbar_background"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""material"": """",
        ""color"": ""1 0.4039216 0.4039216 0""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""1 1"",
        ""offsetmin"": ""25 3"",
        ""offsetmax"": ""-3 -3""
      }
    ]
  },
  {
    ""name"": ""hpbar_progress"",
    ""parent"": ""hpbar_wrapper"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""sprite"": ""assets/content/ui/ui.background.tile.psd"",
        ""material"": """",
        ""color"": ""0.6941177 0.2039216 0.003921569 0.5450981""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""{progress} 1"",
        ""offsetmin"": ""0 0"",
        ""offsetmax"": ""0 0""
      }
    ]
  },
  {
    ""name"": ""hpbar_text"",
    ""parent"": ""hpbar_wrapper"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Text"",
        ""text"": ""{text}"",
        ""fontSize"": 15,
        ""font"": ""robotocondensed-bold.ttf"",
        ""align"": ""MiddleLeft"",
        ""color"": ""0.9686275 0.9176471 0.8784314 0.8945568""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""1 1"",
        ""offsetmin"": ""2 0"",
        ""offsetmax"": ""0 0""
      }
    ]
  }
]
        ";

    }
}

Error while compiling: HealthBar.cs(63,31): error CS0038: Cannot access a nonstatic member of outer type `Oxide.Plugins.HealthBar' via nested type `Oxide.Plugins.HealthBar.GuiControl'

Если запенить
public GuiControl(PluginTimers timer, float destroySeconds)
{
this._Timer = timer;
this._DestroySeconds = destroySeconds;
}
на
public GuiControl(HealthBar plugin, PluginTimers timer, float destroySeconds)
{
this._Plugin = plugin;
this._Timer = timer;
this._DestroySeconds = destroySeconds;
}
Тогда будет проблема с 2 аргументами
 
Для решения проблемы необходимо добавить поле _Plugin в класс GuiControl и инициализировать его в методе Loaded() плагина:

Код:
class GuiControl
{
    private readonly HealthBar _Plugin;
    // остальной код класса
}

void Loaded()
{
    _GuiControl = new GuiControl(this, timer, 5f);
}

Затем необходимо заменить все _Timer на _Plugin.timer и убрать поле PluginTimers timer и аргумент timer из конструктора класса GuiControl.

Код:
class GuiControl
{
    private Dictionary<BasePlayer, Timer> _Timers = new Dictionary<BasePlayer, Timer>();
    private readonly HealthBar _Plugin;
    private readonly float _DestroySeconds;
    
    public GuiControl(HealthBar plugin, float destroySeconds)
    {
        this._Plugin = plugin;
        this._DestroySeconds = destroySeconds;
    }
    
    public void TriggerDamage(BasePlayer player, float health, float maxHealth)
    {
        RemovePlayer(player);
        var progress = health / maxHealth + "";
        var healthText = (int)health + "";
        DrawUI(player, progressText, healthText);
        AddPlayer(player);
    }
    
    // остальной код класса
}

void Loaded()
{
    _GuiControl = new GuiControl(this, 5f);
}

void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info)
{
    var player = info.InitiatorPlayer;
    if (player && player.IsAlive())
    {
        NextTick(() =>
        {
            if (entity.IsAlive() && player?.IsConnected == true)
            {
                var health = entity.health;
                var maxHealth = entity.MaxHealth();
                var progress = health / maxHealth;
                var text = (int) health;
                _GuiControl.TriggerDamage(player, health, maxHealth);
            }
        });
    }
}

// остальной код плагина
 
Для решения проблемы необходимо добавить поле _Plugin в класс GuiControl и инициализировать его в методе Loaded() плагина:

Код:
class GuiControl
{
    private readonly HealthBar _Plugin;
    // остальной код класса
}

void Loaded()
{
    _GuiControl = new GuiControl(this, timer, 5f);
}

Затем необходимо заменить все _Timer на _Plugin.timer и убрать поле PluginTimers timer и аргумент timer из конструктора класса GuiControl.

Код:
class GuiControl
{
    private Dictionary<BasePlayer, Timer> _Timers = new Dictionary<BasePlayer, Timer>();
    private readonly HealthBar _Plugin;
    private readonly float _DestroySeconds;
   
    public GuiControl(HealthBar plugin, float destroySeconds)
    {
        this._Plugin = plugin;
        this._DestroySeconds = destroySeconds;
    }
   
    public void TriggerDamage(BasePlayer player, float health, float maxHealth)
    {
        RemovePlayer(player);
        var progress = health / maxHealth + "";
        var healthText = (int)health + "";
        DrawUI(player, progressText, healthText);
        AddPlayer(player);
    }
   
    // остальной код класса
}

void Loaded()
{
    _GuiControl = new GuiControl(this, 5f);
}

void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info)
{
    var player = info.InitiatorPlayer;
    if (player && player.IsAlive())
    {
        NextTick(() =>
        {
            if (entity.IsAlive() && player?.IsConnected == true)
            {
                var health = entity.health;
                var maxHealth = entity.MaxHealth();
                var progress = health / maxHealth;
                var text = (int) health;
                _GuiControl.TriggerDamage(player, health, maxHealth);
            }
        });
    }
}

// остальной код плагина
C#:
using Oxide.Game.Rust.Cui;
using System.Collections.Generic;

namespace Oxide.Plugins {
      [Info("Health Bar", "Obkurenniy", "1.0")]

    class HealthBar : RustPlugin
    {
        
        class GuiControl
        {
            private Dictionary<BasePlayer, Timer> _Timers = new Dictionary<BasePlayer, Timer>();
            private readonly HealthBar _Plugin;
            private readonly float _DestroySeconds;
            
            public GuiControl(HealthBar plugin, float destroySeconds)
            {
                this._Plugin = plugin;
                this._DestroySeconds = destroySeconds;
            }
            
            public void TriggerDamage(BasePlayer player, float health, float maxHealth)
            {
                RemovePlayer(player);
                var progress = health / maxHealth + "";
                var healthText = (int)health + "";
                DrawUI(player, progressText, healthText);
                AddPlayer(player);
            }

            void AddPlayer(BasePlayer player)
            {
                _Timers[player] = _Timer.Once(_DestroySeconds, () =>
                {
                    RemovePlayer(player);
                });
            }

            void RemovePlayer(BasePlayer player)
            {
                Timer pTimer;
                if(_Timers.TryGetValue(player, out pTimer))
                {
                   _Timer.Destroy(ref pTimer);
                   DestroyUI(player);
                   _Timers.Remove(player);
                }
            }

            void DrawUI(BasePlayer player, string progress, string text)
            {
                string json = CUI_MAIN
                .Replace("{progress}", progress)
                .Replace("{text}", text);
                CuiHelper.AddUi(player, json);
            }

            void DestroyUI(BasePlayer player)
            {
                CuiHelper.DestroyUi(player, "hpbar_background");
            }
        }

        GuiControl _GuiControl;

        void Loaded()
        {
            _GuiControl = new GuiControl(this, 5f);
        }

        void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info)
        {
            var player = info.InitiatorPlayer;
            if (player && player.IsAlive())
            {
                NextTick(() =>
                {
                    if (entity.IsAlive() && player?.IsConnected == true)
                    {
                        var health = entity.health;
                        var maxHealth = entity.MaxHealth();
                        var progress = health / maxHealth;
                        var text = (int) health;
                        _GuiControl.TriggerDamage(player, health, maxHealth);
                    }
                });
            }
        }

        void OnEntityDeath(BaseCombatEntity entity, HitInfo info)
        {
            var player = info.InitiatorPlayer;
            if (player && player.IsAlive())
            {
                _GuiControl.TriggerDeath(player);
            }
        }

        [ChatCommand("testgui")]
        void cmdChatTestGui(BasePlayer player)
        {
            string json = CUI_MAIN
            .Replace("{progress}", "0.5")
            .Replace("{text}", "50");

            CuiHelper.AddUi(player, json);
            timer.Once(10f, () => {
                CuiHelper.DestroyUi(player, "hpbar_background");
            });
        }

            string CUI_MAIN = @"
            [
  {
    ""name"": ""hpbar_background"",
    ""parent"": ""Overlay"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""material"": """",
        ""color"": ""0.5254902 0.5254902 0.5254902 0.2980392""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0.5 0"",
        ""anchormax"": ""0.5 0"",
        ""offsetmin"": ""-106 86"",
        ""offsetmax"": ""86 112""
      }
    ]
  },
  {
    ""name"": ""hpbar_img"",
    ""parent"": ""hpbar_background"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""sprite"": ""assets/icons/health.png"",
        ""material"": ""assets/icons/iconmaterial.mat"",
        ""color"": ""0.9686275 0.9176471 0.8784314 0.6745098""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""0 1"",
        ""offsetmin"": ""4 4"",
        ""offsetmax"": ""22 -4""
      }
    ]
  },
  {
    ""name"": ""hpbar_wrapper"",
    ""parent"": ""hpbar_background"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""material"": """",
        ""color"": ""1 0.4039216 0.4039216 0""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""1 1"",
        ""offsetmin"": ""25 3"",
        ""offsetmax"": ""-3 -3""
      }
    ]
  },
  {
    ""name"": ""hpbar_progress"",
    ""parent"": ""hpbar_wrapper"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""sprite"": ""assets/content/ui/ui.background.tile.psd"",
        ""material"": """",
        ""color"": ""0.6941177 0.2039216 0.003921569 0.5450981""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""{progress} 1"",
        ""offsetmin"": ""0 0"",
        ""offsetmax"": ""0 0""
      }
    ]
  },
  {
    ""name"": ""hpbar_text"",
    ""parent"": ""hpbar_wrapper"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Text"",
        ""text"": ""{text}"",
        ""fontSize"": 15,
        ""font"": ""robotocondensed-bold.ttf"",
        ""align"": ""MiddleLeft"",
        ""color"": ""0.9686275 0.9176471 0.8784314 0.8945568""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""1 1"",
        ""offsetmin"": ""2 0"",
        ""offsetmax"": ""0 0""
      }
    ]
  }
]
        ";

    }
}
Error while compiling: HealthBar.cs(97,29): error CS1061: Type `Oxide.Plugins.HealthBar.GuiControl' does not contain a definition for `TriggerDeath' and no extension method `TriggerDeath' of type `Oxide.Plugins.HealthBar.GuiControl' could be found. Are you missing an assembly reference?
 
C#:
using Oxide.Game.Rust.Cui;
using System.Collections.Generic;

namespace Oxide.Plugins {
      [Info("Health Bar", "Obkurenniy", "1.0")]

    class HealthBar : RustPlugin
    {
        
        class GuiControl
        {
            private Dictionary<BasePlayer, Timer> _Timers = new Dictionary<BasePlayer, Timer>();
            private readonly HealthBar _Plugin;
            private readonly float _DestroySeconds;
            
            public GuiControl(HealthBar plugin, float destroySeconds)
            {
                this._Plugin = plugin;
                this._DestroySeconds = destroySeconds;
            }
            
            public void TriggerDamage(BasePlayer player, float health, float maxHealth)
            {
                RemovePlayer(player);
                var progress = health / maxHealth + "";
                var healthText = (int)health + "";
                DrawUI(player, progressText, healthText);
                AddPlayer(player);
            }

            void AddPlayer(BasePlayer player)
            {
                _Timers[player] = _Timer.Once(_DestroySeconds, () =>
                {
                    RemovePlayer(player);
                });
            }

            void RemovePlayer(BasePlayer player)
            {
                Timer pTimer;
                if(_Timers.TryGetValue(player, out pTimer))
                {
                   _Timer.Destroy(ref pTimer);
                   DestroyUI(player);
                   _Timers.Remove(player);
                }
            }

            void DrawUI(BasePlayer player, string progress, string text)
            {
                string json = CUI_MAIN
                .Replace("{progress}", progress)
                .Replace("{text}", text);
                CuiHelper.AddUi(player, json);
            }

            void DestroyUI(BasePlayer player)
            {
                CuiHelper.DestroyUi(player, "hpbar_background");
            }
        }

        GuiControl _GuiControl;

        void Loaded()
        {
            _GuiControl = new GuiControl(this, 5f);
        }

        void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info)
        {
            var player = info.InitiatorPlayer;
            if (player && player.IsAlive())
            {
                NextTick(() =>
                {
                    if (entity.IsAlive() && player?.IsConnected == true)
                    {
                        var health = entity.health;
                        var maxHealth = entity.MaxHealth();
                        var progress = health / maxHealth;
                        var text = (int) health;
                        _GuiControl.TriggerDamage(player, health, maxHealth);
                    }
                });
            }
        }

        void OnEntityDeath(BaseCombatEntity entity, HitInfo info)
        {
            var player = info.InitiatorPlayer;
            if (player && player.IsAlive())
            {
                _GuiControl.TriggerDeath(player);
            }
        }

        [ChatCommand("testgui")]
        void cmdChatTestGui(BasePlayer player)
        {
            string json = CUI_MAIN
            .Replace("{progress}", "0.5")
            .Replace("{text}", "50");

            CuiHelper.AddUi(player, json);
            timer.Once(10f, () => {
                CuiHelper.DestroyUi(player, "hpbar_background");
            });
        }

            string CUI_MAIN = @"
            [
  {
    ""name"": ""hpbar_background"",
    ""parent"": ""Overlay"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""material"": """",
        ""color"": ""0.5254902 0.5254902 0.5254902 0.2980392""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0.5 0"",
        ""anchormax"": ""0.5 0"",
        ""offsetmin"": ""-106 86"",
        ""offsetmax"": ""86 112""
      }
    ]
  },
  {
    ""name"": ""hpbar_img"",
    ""parent"": ""hpbar_background"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""sprite"": ""assets/icons/health.png"",
        ""material"": ""assets/icons/iconmaterial.mat"",
        ""color"": ""0.9686275 0.9176471 0.8784314 0.6745098""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""0 1"",
        ""offsetmin"": ""4 4"",
        ""offsetmax"": ""22 -4""
      }
    ]
  },
  {
    ""name"": ""hpbar_wrapper"",
    ""parent"": ""hpbar_background"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""material"": """",
        ""color"": ""1 0.4039216 0.4039216 0""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""1 1"",
        ""offsetmin"": ""25 3"",
        ""offsetmax"": ""-3 -3""
      }
    ]
  },
  {
    ""name"": ""hpbar_progress"",
    ""parent"": ""hpbar_wrapper"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""sprite"": ""assets/content/ui/ui.background.tile.psd"",
        ""material"": """",
        ""color"": ""0.6941177 0.2039216 0.003921569 0.5450981""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""{progress} 1"",
        ""offsetmin"": ""0 0"",
        ""offsetmax"": ""0 0""
      }
    ]
  },
  {
    ""name"": ""hpbar_text"",
    ""parent"": ""hpbar_wrapper"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Text"",
        ""text"": ""{text}"",
        ""fontSize"": 15,
        ""font"": ""robotocondensed-bold.ttf"",
        ""align"": ""MiddleLeft"",
        ""color"": ""0.9686275 0.9176471 0.8784314 0.8945568""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""1 1"",
        ""offsetmin"": ""2 0"",
        ""offsetmax"": ""0 0""
      }
    ]
  }
]
        ";

    }
}
Error while compiling: HealthBar.cs(97,29): error CS1061: Type `Oxide.Plugins.HealthBar.GuiControl' does not contain a definition for `TriggerDeath' and no extension method `TriggerDeath' of type `Oxide.Plugins.HealthBar.GuiControl' could be found. Are you missing an assembly reference?
Эта ошибка возникает потому, что в классе GuiControl не определен метод TriggerDeath, который используется в обработчике события OnEntityDeath плагина. Добавьте метод TriggerDeath в класс GuiControl, который будет удалять UI при смерти игрока:

Код:
public void TriggerDeath(BasePlayer player)
{
    RemovePlayer(player);
}
 
Эта ошибка возникает потому, что в классе GuiControl не определен метод TriggerDeath, который используется в обработчике события OnEntityDeath плагина. Добавьте метод TriggerDeath в класс GuiControl, который будет удалять UI при смерти игрока:

Код:
public void TriggerDeath(BasePlayer player)
{
    RemovePlayer(player);
}
C#:
using Oxide.Game.Rust.Cui;
using System.Collections.Generic;

namespace Oxide.Plugins {
      [Info("Health Bar", "Obkurenniy", "1.0")]

    class HealthBar : RustPlugin
    {
        
        class GuiControl
        {
            private Dictionary<BasePlayer, Timer> _Timers = new Dictionary<BasePlayer, Timer>();
            private readonly HealthBar _Plugin;
            private readonly float _DestroySeconds;
            
            public GuiControl(HealthBar plugin, float destroySeconds)
            {
                this._Plugin = plugin;
                this._DestroySeconds = destroySeconds;
            }
            
            public void TriggerDamage(BasePlayer player, float health, float maxHealth)
            {
                RemovePlayer(player);
                var progress = health / maxHealth + "";
                var healthText = (int)health + "";
                DrawUI(player, progressText, healthText);
                AddPlayer(player);
            }
            
            void TriggerDeath(BasePlayer player)
            {
                RemovePlayer(player);
            }

            void AddPlayer(BasePlayer player)
            {
                _Timers[player] = _Timer.Once(_DestroySeconds, () =>
                {
                    RemovePlayer(player);
                });
            }

            void RemovePlayer(BasePlayer player)
            {
                Timer pTimer;
                if(_Timers.TryGetValue(player, out pTimer))
                {
                   _Timer.Destroy(ref pTimer);
                   DestroyUI(player);
                   _Timers.Remove(player);
                }
            }

            void DrawUI(BasePlayer player, string progress, string text)
            {
                string json = CUI_MAIN
                .Replace("{progress}", progress)
                .Replace("{text}", text);
                CuiHelper.AddUi(player, json);
            }

            void DestroyUI(BasePlayer player)
            {
                CuiHelper.DestroyUi(player, "hpbar_background");
            }
        }

        GuiControl _GuiControl;

        void Loaded()
        {
            _GuiControl = new GuiControl(this, 5f);
        }

        void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info)
        {
            var player = info.InitiatorPlayer;
            if (player && player.IsAlive())
            {
                NextTick(() =>
                {
                    if (entity.IsAlive() && player?.IsConnected == true)
                    {
                        var health = entity.health;
                        var maxHealth = entity.MaxHealth();
                        var progress = health / maxHealth;
                        var text = (int) health;
                        _GuiControl.TriggerDamage(player, health, maxHealth);
                    }
                });
            }
        }

        void OnEntityDeath(BaseCombatEntity entity, HitInfo info)
        {
            var player = info.InitiatorPlayer;
            if (player && player.IsAlive())
            {
                _GuiControl.TriggerDeath(player);
            }
        }

        [ChatCommand("testgui")]
        void cmdChatTestGui(BasePlayer player)
        {
            string json = CUI_MAIN
            .Replace("{progress}", "0.5")
            .Replace("{text}", "50");

            CuiHelper.AddUi(player, json);
            timer.Once(10f, () => {
                CuiHelper.DestroyUi(player, "hpbar_background");
            });
        }

            string CUI_MAIN = @"
            [
  {
    ""name"": ""hpbar_background"",
    ""parent"": ""Overlay"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""material"": """",
        ""color"": ""0.5254902 0.5254902 0.5254902 0.2980392""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0.5 0"",
        ""anchormax"": ""0.5 0"",
        ""offsetmin"": ""-106 86"",
        ""offsetmax"": ""86 112""
      }
    ]
  },
  {
    ""name"": ""hpbar_img"",
    ""parent"": ""hpbar_background"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""sprite"": ""assets/icons/health.png"",
        ""material"": ""assets/icons/iconmaterial.mat"",
        ""color"": ""0.9686275 0.9176471 0.8784314 0.6745098""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""0 1"",
        ""offsetmin"": ""4 4"",
        ""offsetmax"": ""22 -4""
      }
    ]
  },
  {
    ""name"": ""hpbar_wrapper"",
    ""parent"": ""hpbar_background"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""material"": """",
        ""color"": ""1 0.4039216 0.4039216 0""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""1 1"",
        ""offsetmin"": ""25 3"",
        ""offsetmax"": ""-3 -3""
      }
    ]
  },
  {
    ""name"": ""hpbar_progress"",
    ""parent"": ""hpbar_wrapper"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""sprite"": ""assets/content/ui/ui.background.tile.psd"",
        ""material"": """",
        ""color"": ""0.6941177 0.2039216 0.003921569 0.5450981""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""{progress} 1"",
        ""offsetmin"": ""0 0"",
        ""offsetmax"": ""0 0""
      }
    ]
  },
  {
    ""name"": ""hpbar_text"",
    ""parent"": ""hpbar_wrapper"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Text"",
        ""text"": ""{text}"",
        ""fontSize"": 15,
        ""font"": ""robotocondensed-bold.ttf"",
        ""align"": ""MiddleLeft"",
        ""color"": ""0.9686275 0.9176471 0.8784314 0.8945568""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""1 1"",
        ""offsetmin"": ""2 0"",
        ""offsetmax"": ""0 0""
      }
    ]
  }
]
        ";

    }
}
Error while compiling: HealthBar.cs(102,29): error CS0122: `Oxide.Plugins.HealthBar.GuiControl.TriggerDeath(BasePlayer)' is inaccessible due to its protection level
 
C#:
using Oxide.Game.Rust.Cui;
using System.Collections.Generic;

namespace Oxide.Plugins {
      [Info("Health Bar", "Obkurenniy", "1.0")]

    class HealthBar : RustPlugin
    {
        
        class GuiControl
        {
            private Dictionary<BasePlayer, Timer> _Timers = new Dictionary<BasePlayer, Timer>();
            private readonly HealthBar _Plugin;
            private readonly float _DestroySeconds;
            
            public GuiControl(HealthBar plugin, float destroySeconds)
            {
                this._Plugin = plugin;
                this._DestroySeconds = destroySeconds;
            }
            
            public void TriggerDamage(BasePlayer player, float health, float maxHealth)
            {
                RemovePlayer(player);
                var progress = health / maxHealth + "";
                var healthText = (int)health + "";
                DrawUI(player, progressText, healthText);
                AddPlayer(player);
            }
            
            void TriggerDeath(BasePlayer player)
            {
                RemovePlayer(player);
            }

            void AddPlayer(BasePlayer player)
            {
                _Timers[player] = _Timer.Once(_DestroySeconds, () =>
                {
                    RemovePlayer(player);
                });
            }

            void RemovePlayer(BasePlayer player)
            {
                Timer pTimer;
                if(_Timers.TryGetValue(player, out pTimer))
                {
                   _Timer.Destroy(ref pTimer);
                   DestroyUI(player);
                   _Timers.Remove(player);
                }
            }

            void DrawUI(BasePlayer player, string progress, string text)
            {
                string json = CUI_MAIN
                .Replace("{progress}", progress)
                .Replace("{text}", text);
                CuiHelper.AddUi(player, json);
            }

            void DestroyUI(BasePlayer player)
            {
                CuiHelper.DestroyUi(player, "hpbar_background");
            }
        }

        GuiControl _GuiControl;

        void Loaded()
        {
            _GuiControl = new GuiControl(this, 5f);
        }

        void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info)
        {
            var player = info.InitiatorPlayer;
            if (player && player.IsAlive())
            {
                NextTick(() =>
                {
                    if (entity.IsAlive() && player?.IsConnected == true)
                    {
                        var health = entity.health;
                        var maxHealth = entity.MaxHealth();
                        var progress = health / maxHealth;
                        var text = (int) health;
                        _GuiControl.TriggerDamage(player, health, maxHealth);
                    }
                });
            }
        }

        void OnEntityDeath(BaseCombatEntity entity, HitInfo info)
        {
            var player = info.InitiatorPlayer;
            if (player && player.IsAlive())
            {
                _GuiControl.TriggerDeath(player);
            }
        }

        [ChatCommand("testgui")]
        void cmdChatTestGui(BasePlayer player)
        {
            string json = CUI_MAIN
            .Replace("{progress}", "0.5")
            .Replace("{text}", "50");

            CuiHelper.AddUi(player, json);
            timer.Once(10f, () => {
                CuiHelper.DestroyUi(player, "hpbar_background");
            });
        }

            string CUI_MAIN = @"
            [
  {
    ""name"": ""hpbar_background"",
    ""parent"": ""Overlay"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""material"": """",
        ""color"": ""0.5254902 0.5254902 0.5254902 0.2980392""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0.5 0"",
        ""anchormax"": ""0.5 0"",
        ""offsetmin"": ""-106 86"",
        ""offsetmax"": ""86 112""
      }
    ]
  },
  {
    ""name"": ""hpbar_img"",
    ""parent"": ""hpbar_background"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""sprite"": ""assets/icons/health.png"",
        ""material"": ""assets/icons/iconmaterial.mat"",
        ""color"": ""0.9686275 0.9176471 0.8784314 0.6745098""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""0 1"",
        ""offsetmin"": ""4 4"",
        ""offsetmax"": ""22 -4""
      }
    ]
  },
  {
    ""name"": ""hpbar_wrapper"",
    ""parent"": ""hpbar_background"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""material"": """",
        ""color"": ""1 0.4039216 0.4039216 0""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""1 1"",
        ""offsetmin"": ""25 3"",
        ""offsetmax"": ""-3 -3""
      }
    ]
  },
  {
    ""name"": ""hpbar_progress"",
    ""parent"": ""hpbar_wrapper"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""sprite"": ""assets/content/ui/ui.background.tile.psd"",
        ""material"": """",
        ""color"": ""0.6941177 0.2039216 0.003921569 0.5450981""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""{progress} 1"",
        ""offsetmin"": ""0 0"",
        ""offsetmax"": ""0 0""
      }
    ]
  },
  {
    ""name"": ""hpbar_text"",
    ""parent"": ""hpbar_wrapper"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Text"",
        ""text"": ""{text}"",
        ""fontSize"": 15,
        ""font"": ""robotocondensed-bold.ttf"",
        ""align"": ""MiddleLeft"",
        ""color"": ""0.9686275 0.9176471 0.8784314 0.8945568""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""1 1"",
        ""offsetmin"": ""2 0"",
        ""offsetmax"": ""0 0""
      }
    ]
  }
]
        ";

    }
}
Error while compiling: HealthBar.cs(102,29): error CS0122: `Oxide.Plugins.HealthBar.GuiControl.TriggerDeath(BasePlayer)' is inaccessible due to its protection level
Исправьте уровень доступа метода TriggerDeath в классе GuiControl на public:

Код:
public void TriggerDeath(BasePlayer player)
{
    RemovePlayer(player);
}
 
Исправьте уровень доступа метода TriggerDeath в классе GuiControl на public:

Код:
public void TriggerDeath(BasePlayer player)
{
    RemovePlayer(player);
}
C#:
using Oxide.Game.Rust.Cui;
using System.Collections.Generic;

namespace Oxide.Plugins {
      [Info("Health Bar", "Obkurenniy", "1.0")]

    class HealthBar : RustPlugin
    {
        
        class GuiControl
        {
            private Dictionary<BasePlayer, Timer> _Timers = new Dictionary<BasePlayer, Timer>();
            private readonly HealthBar _Plugin;
            private readonly float _DestroySeconds;
            
            public GuiControl(HealthBar plugin, float destroySeconds)
            {
                this._Plugin = plugin;
                this._DestroySeconds = destroySeconds;
            }
            
            public void TriggerDamage(BasePlayer player, float health, float maxHealth)
            {
                RemovePlayer(player);
                var progress = health / maxHealth + "";
                var healthText = (int)health + "";
                DrawUI(player, progressText, healthText);
                AddPlayer(player);
            }
            
            public void TriggerDeath(BasePlayer player)
            {
                RemovePlayer(player);
            }

            void AddPlayer(BasePlayer player)
            {
                _Timers[player] = _Timer.Once(_DestroySeconds, () =>
                {
                    RemovePlayer(player);
                });
            }

            void RemovePlayer(BasePlayer player)
            {
                Timer pTimer;
                if(_Timers.TryGetValue(player, out pTimer))
                {
                   _Timer.Destroy(ref pTimer);
                   DestroyUI(player);
                   _Timers.Remove(player);
                }
            }

            void DrawUI(BasePlayer player, string progress, string text)
            {
                string json = CUI_MAIN
                .Replace("{progress}", progress)
                .Replace("{text}", text);
                CuiHelper.AddUi(player, json);
            }

            void DestroyUI(BasePlayer player)
            {
                CuiHelper.DestroyUi(player, "hpbar_background");
            }
        }

        GuiControl _GuiControl;

        void Loaded()
        {
            _GuiControl = new GuiControl(this, 5f);
        }

        void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info)
        {
            var player = info.InitiatorPlayer;
            if (player && player.IsAlive())
            {
                NextTick(() =>
                {
                    if (entity.IsAlive() && player?.IsConnected == true)
                    {
                        var health = entity.health;
                        var maxHealth = entity.MaxHealth();
                        var progress = health / maxHealth;
                        var text = (int) health;
                        _GuiControl.TriggerDamage(player, health, maxHealth);
                    }
                });
            }
        }

        void OnEntityDeath(BaseCombatEntity entity, HitInfo info)
        {
            var player = info.InitiatorPlayer;
            if (player && player.IsAlive())
            {
                _GuiControl.TriggerDeath(player);
            }
        }

        [ChatCommand("testgui")]
        void cmdChatTestGui(BasePlayer player)
        {
            string json = CUI_MAIN
            .Replace("{progress}", "0.5")
            .Replace("{text}", "50");

            CuiHelper.AddUi(player, json);
            timer.Once(10f, () => {
                CuiHelper.DestroyUi(player, "hpbar_background");
            });
        }

            string CUI_MAIN = @"
            [
  {
    ""name"": ""hpbar_background"",
    ""parent"": ""Overlay"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""material"": """",
        ""color"": ""0.5254902 0.5254902 0.5254902 0.2980392""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0.5 0"",
        ""anchormax"": ""0.5 0"",
        ""offsetmin"": ""-106 86"",
        ""offsetmax"": ""86 112""
      }
    ]
  },
  {
    ""name"": ""hpbar_img"",
    ""parent"": ""hpbar_background"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""sprite"": ""assets/icons/health.png"",
        ""material"": ""assets/icons/iconmaterial.mat"",
        ""color"": ""0.9686275 0.9176471 0.8784314 0.6745098""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""0 1"",
        ""offsetmin"": ""4 4"",
        ""offsetmax"": ""22 -4""
      }
    ]
  },
  {
    ""name"": ""hpbar_wrapper"",
    ""parent"": ""hpbar_background"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""material"": """",
        ""color"": ""1 0.4039216 0.4039216 0""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""1 1"",
        ""offsetmin"": ""25 3"",
        ""offsetmax"": ""-3 -3""
      }
    ]
  },
  {
    ""name"": ""hpbar_progress"",
    ""parent"": ""hpbar_wrapper"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""sprite"": ""assets/content/ui/ui.background.tile.psd"",
        ""material"": """",
        ""color"": ""0.6941177 0.2039216 0.003921569 0.5450981""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""{progress} 1"",
        ""offsetmin"": ""0 0"",
        ""offsetmax"": ""0 0""
      }
    ]
  },
  {
    ""name"": ""hpbar_text"",
    ""parent"": ""hpbar_wrapper"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Text"",
        ""text"": ""{text}"",
        ""fontSize"": 15,
        ""font"": ""robotocondensed-bold.ttf"",
        ""align"": ""MiddleLeft"",
        ""color"": ""0.9686275 0.9176471 0.8784314 0.8945568""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""1 1"",
        ""offsetmin"": ""2 0"",
        ""offsetmax"": ""0 0""
      }
    ]
  }
]
        ";

    }
}
Error while compiling: HealthBar.cs(59,31): error CS0038: Cannot access a nonstatic member of outer type `Oxide.Plugins.HealthBar' via nested type `Oxide.Plugins.HealthBar.GuiControl'
 
C#:
using Oxide.Game.Rust.Cui;
using System.Collections.Generic;

namespace Oxide.Plugins {
      [Info("Health Bar", "Obkurenniy", "1.0")]

    class HealthBar : RustPlugin
    {
        
        class GuiControl
        {
            private Dictionary<BasePlayer, Timer> _Timers = new Dictionary<BasePlayer, Timer>();
            private readonly HealthBar _Plugin;
            private readonly float _DestroySeconds;
            
            public GuiControl(HealthBar plugin, float destroySeconds)
            {
                this._Plugin = plugin;
                this._DestroySeconds = destroySeconds;
            }
            
            public void TriggerDamage(BasePlayer player, float health, float maxHealth)
            {
                RemovePlayer(player);
                var progress = health / maxHealth + "";
                var healthText = (int)health + "";
                DrawUI(player, progressText, healthText);
                AddPlayer(player);
            }
            
            public void TriggerDeath(BasePlayer player)
            {
                RemovePlayer(player);
            }

            void AddPlayer(BasePlayer player)
            {
                _Timers[player] = _Timer.Once(_DestroySeconds, () =>
                {
                    RemovePlayer(player);
                });
            }

            void RemovePlayer(BasePlayer player)
            {
                Timer pTimer;
                if(_Timers.TryGetValue(player, out pTimer))
                {
                   _Timer.Destroy(ref pTimer);
                   DestroyUI(player);
                   _Timers.Remove(player);
                }
            }

            void DrawUI(BasePlayer player, string progress, string text)
            {
                string json = CUI_MAIN
                .Replace("{progress}", progress)
                .Replace("{text}", text);
                CuiHelper.AddUi(player, json);
            }

            void DestroyUI(BasePlayer player)
            {
                CuiHelper.DestroyUi(player, "hpbar_background");
            }
        }

        GuiControl _GuiControl;

        void Loaded()
        {
            _GuiControl = new GuiControl(this, 5f);
        }

        void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info)
        {
            var player = info.InitiatorPlayer;
            if (player && player.IsAlive())
            {
                NextTick(() =>
                {
                    if (entity.IsAlive() && player?.IsConnected == true)
                    {
                        var health = entity.health;
                        var maxHealth = entity.MaxHealth();
                        var progress = health / maxHealth;
                        var text = (int) health;
                        _GuiControl.TriggerDamage(player, health, maxHealth);
                    }
                });
            }
        }

        void OnEntityDeath(BaseCombatEntity entity, HitInfo info)
        {
            var player = info.InitiatorPlayer;
            if (player && player.IsAlive())
            {
                _GuiControl.TriggerDeath(player);
            }
        }

        [ChatCommand("testgui")]
        void cmdChatTestGui(BasePlayer player)
        {
            string json = CUI_MAIN
            .Replace("{progress}", "0.5")
            .Replace("{text}", "50");

            CuiHelper.AddUi(player, json);
            timer.Once(10f, () => {
                CuiHelper.DestroyUi(player, "hpbar_background");
            });
        }

            string CUI_MAIN = @"
            [
  {
    ""name"": ""hpbar_background"",
    ""parent"": ""Overlay"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""material"": """",
        ""color"": ""0.5254902 0.5254902 0.5254902 0.2980392""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0.5 0"",
        ""anchormax"": ""0.5 0"",
        ""offsetmin"": ""-106 86"",
        ""offsetmax"": ""86 112""
      }
    ]
  },
  {
    ""name"": ""hpbar_img"",
    ""parent"": ""hpbar_background"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""sprite"": ""assets/icons/health.png"",
        ""material"": ""assets/icons/iconmaterial.mat"",
        ""color"": ""0.9686275 0.9176471 0.8784314 0.6745098""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""0 1"",
        ""offsetmin"": ""4 4"",
        ""offsetmax"": ""22 -4""
      }
    ]
  },
  {
    ""name"": ""hpbar_wrapper"",
    ""parent"": ""hpbar_background"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""material"": """",
        ""color"": ""1 0.4039216 0.4039216 0""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""1 1"",
        ""offsetmin"": ""25 3"",
        ""offsetmax"": ""-3 -3""
      }
    ]
  },
  {
    ""name"": ""hpbar_progress"",
    ""parent"": ""hpbar_wrapper"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""sprite"": ""assets/content/ui/ui.background.tile.psd"",
        ""material"": """",
        ""color"": ""0.6941177 0.2039216 0.003921569 0.5450981""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""{progress} 1"",
        ""offsetmin"": ""0 0"",
        ""offsetmax"": ""0 0""
      }
    ]
  },
  {
    ""name"": ""hpbar_text"",
    ""parent"": ""hpbar_wrapper"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Text"",
        ""text"": ""{text}"",
        ""fontSize"": 15,
        ""font"": ""robotocondensed-bold.ttf"",
        ""align"": ""MiddleLeft"",
        ""color"": ""0.9686275 0.9176471 0.8784314 0.8945568""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""1 1"",
        ""offsetmin"": ""2 0"",
        ""offsetmax"": ""0 0""
      }
    ]
  }
]
        ";

    }
}
Error while compiling: HealthBar.cs(59,31): error CS0038: Cannot access a nonstatic member of outer type `Oxide.Plugins.HealthBar' via nested type `Oxide.Plugins.HealthBar.GuiControl'
Проблема заключается в том, что в методе OnEntityDeath вы пытаетесь обратиться к методу TriggerDeath, который имеет уровень доступа private. Чтобы это исправить, установите уровень доступа метода TriggerDeath в public:

Код:
public class GuiControl
{
   ...
   public void TriggerDeath(BasePlayer player)
   {
      RemovePlayer(player);
   }
}
 
Проблема заключается в том, что в методе OnEntityDeath вы пытаетесь обратиться к методу TriggerDeath, который имеет уровень доступа private. Чтобы это исправить, установите уровень доступа метода TriggerDeath в public:

Код:
public class GuiControl
{
   ...
   public void TriggerDeath(BasePlayer player)
   {
      RemovePlayer(player);
   }
}
C#:
using Oxide.Game.Rust.Cui;
using System.Collections.Generic;

namespace Oxide.Plugins {
      [Info("Health Bar", "Obkurenniy", "1.0")]

    class HealthBar : RustPlugin
    {
        
        public class GuiControl
        {
            private Dictionary<BasePlayer, Timer> _Timers = new Dictionary<BasePlayer, Timer>();
            private readonly HealthBar _Plugin;
            private readonly float _DestroySeconds;
            
            public GuiControl(HealthBar plugin, float destroySeconds)
            {
                this._Plugin = plugin;
                this._DestroySeconds = destroySeconds;
            }
            
            public void TriggerDamage(BasePlayer player, float health, float maxHealth)
            {
                RemovePlayer(player);
                var progress = health / maxHealth + "";
                var healthText = (int)health + "";
                DrawUI(player, progressText, healthText);
                AddPlayer(player);
            }
            
            public void TriggerDeath(BasePlayer player)
            {
                RemovePlayer(player);
            }

            void AddPlayer(BasePlayer player)
            {
                _Timers[player] = _Timer.Once(_DestroySeconds, () =>
                {
                    RemovePlayer(player);
                });
            }

            void RemovePlayer(BasePlayer player)
            {
                Timer pTimer;
                if(_Timers.TryGetValue(player, out pTimer))
                {
                   _Timer.Destroy(ref pTimer);
                   DestroyUI(player);
                   _Timers.Remove(player);
                }
            }

            void DrawUI(BasePlayer player, string progress, string text)
            {
                string json = CUI_MAIN
                .Replace("{progress}", progress)
                .Replace("{text}", text);
                CuiHelper.AddUi(player, json);
            }

            void DestroyUI(BasePlayer player)
            {
                CuiHelper.DestroyUi(player, "hpbar_background");
            }
        }

        GuiControl _GuiControl;

        void Loaded()
        {
            _GuiControl = new GuiControl(this, 5f);
        }

        void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info)
        {
            var player = info.InitiatorPlayer;
            if (player && player.IsAlive())
            {
                NextTick(() =>
                {
                    if (entity.IsAlive() && player?.IsConnected == true)
                    {
                        var health = entity.health;
                        var maxHealth = entity.MaxHealth();
                        var progress = health / maxHealth;
                        var text = (int) health;
                        _GuiControl.TriggerDamage(player, health, maxHealth);
                    }
                });
            }
        }

        void OnEntityDeath(BaseCombatEntity entity, HitInfo info)
        {
            var player = info.InitiatorPlayer;
            if (player && player.IsAlive())
            {
                _GuiControl.TriggerDeath(player);
            }
        }

        [ChatCommand("testgui")]
        void cmdChatTestGui(BasePlayer player)
        {
            string json = CUI_MAIN
            .Replace("{progress}", "0.5")
            .Replace("{text}", "50");

            CuiHelper.AddUi(player, json);
            timer.Once(10f, () => {
                CuiHelper.DestroyUi(player, "hpbar_background");
            });
        }

            string CUI_MAIN = @"
            [
  {
    ""name"": ""hpbar_background"",
    ""parent"": ""Overlay"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""material"": """",
        ""color"": ""0.5254902 0.5254902 0.5254902 0.2980392""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0.5 0"",
        ""anchormax"": ""0.5 0"",
        ""offsetmin"": ""-106 86"",
        ""offsetmax"": ""86 112""
      }
    ]
  },
  {
    ""name"": ""hpbar_img"",
    ""parent"": ""hpbar_background"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""sprite"": ""assets/icons/health.png"",
        ""material"": ""assets/icons/iconmaterial.mat"",
        ""color"": ""0.9686275 0.9176471 0.8784314 0.6745098""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""0 1"",
        ""offsetmin"": ""4 4"",
        ""offsetmax"": ""22 -4""
      }
    ]
  },
  {
    ""name"": ""hpbar_wrapper"",
    ""parent"": ""hpbar_background"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""material"": """",
        ""color"": ""1 0.4039216 0.4039216 0""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""1 1"",
        ""offsetmin"": ""25 3"",
        ""offsetmax"": ""-3 -3""
      }
    ]
  },
  {
    ""name"": ""hpbar_progress"",
    ""parent"": ""hpbar_wrapper"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""sprite"": ""assets/content/ui/ui.background.tile.psd"",
        ""material"": """",
        ""color"": ""0.6941177 0.2039216 0.003921569 0.5450981""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""{progress} 1"",
        ""offsetmin"": ""0 0"",
        ""offsetmax"": ""0 0""
      }
    ]
  },
  {
    ""name"": ""hpbar_text"",
    ""parent"": ""hpbar_wrapper"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Text"",
        ""text"": ""{text}"",
        ""fontSize"": 15,
        ""font"": ""robotocondensed-bold.ttf"",
        ""align"": ""MiddleLeft"",
        ""color"": ""0.9686275 0.9176471 0.8784314 0.8945568""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""1 1"",
        ""offsetmin"": ""2 0"",
        ""offsetmax"": ""0 0""
      }
    ]
  }
]
        ";

    }
}
Error while compiling: HealthBar.cs(59,31): error CS0038: Cannot access a nonstatic member of outer type `Oxide.Plugins.HealthBar' via nested type `Oxide.Plugins.HealthBar.GuiControl'
 
C#:
using Oxide.Game.Rust.Cui;
using System.Collections.Generic;

namespace Oxide.Plugins {
      [Info("Health Bar", "Obkurenniy", "1.0")]

    class HealthBar : RustPlugin
    {
        
        public class GuiControl
        {
            private Dictionary<BasePlayer, Timer> _Timers = new Dictionary<BasePlayer, Timer>();
            private readonly HealthBar _Plugin;
            private readonly float _DestroySeconds;
            
            public GuiControl(HealthBar plugin, float destroySeconds)
            {
                this._Plugin = plugin;
                this._DestroySeconds = destroySeconds;
            }
            
            public void TriggerDamage(BasePlayer player, float health, float maxHealth)
            {
                RemovePlayer(player);
                var progress = health / maxHealth + "";
                var healthText = (int)health + "";
                DrawUI(player, progressText, healthText);
                AddPlayer(player);
            }
            
            public void TriggerDeath(BasePlayer player)
            {
                RemovePlayer(player);
            }

            void AddPlayer(BasePlayer player)
            {
                _Timers[player] = _Timer.Once(_DestroySeconds, () =>
                {
                    RemovePlayer(player);
                });
            }

            void RemovePlayer(BasePlayer player)
            {
                Timer pTimer;
                if(_Timers.TryGetValue(player, out pTimer))
                {
                   _Timer.Destroy(ref pTimer);
                   DestroyUI(player);
                   _Timers.Remove(player);
                }
            }

            void DrawUI(BasePlayer player, string progress, string text)
            {
                string json = CUI_MAIN
                .Replace("{progress}", progress)
                .Replace("{text}", text);
                CuiHelper.AddUi(player, json);
            }

            void DestroyUI(BasePlayer player)
            {
                CuiHelper.DestroyUi(player, "hpbar_background");
            }
        }

        GuiControl _GuiControl;

        void Loaded()
        {
            _GuiControl = new GuiControl(this, 5f);
        }

        void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info)
        {
            var player = info.InitiatorPlayer;
            if (player && player.IsAlive())
            {
                NextTick(() =>
                {
                    if (entity.IsAlive() && player?.IsConnected == true)
                    {
                        var health = entity.health;
                        var maxHealth = entity.MaxHealth();
                        var progress = health / maxHealth;
                        var text = (int) health;
                        _GuiControl.TriggerDamage(player, health, maxHealth);
                    }
                });
            }
        }

        void OnEntityDeath(BaseCombatEntity entity, HitInfo info)
        {
            var player = info.InitiatorPlayer;
            if (player && player.IsAlive())
            {
                _GuiControl.TriggerDeath(player);
            }
        }

        [ChatCommand("testgui")]
        void cmdChatTestGui(BasePlayer player)
        {
            string json = CUI_MAIN
            .Replace("{progress}", "0.5")
            .Replace("{text}", "50");

            CuiHelper.AddUi(player, json);
            timer.Once(10f, () => {
                CuiHelper.DestroyUi(player, "hpbar_background");
            });
        }

            string CUI_MAIN = @"
            [
  {
    ""name"": ""hpbar_background"",
    ""parent"": ""Overlay"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""material"": """",
        ""color"": ""0.5254902 0.5254902 0.5254902 0.2980392""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0.5 0"",
        ""anchormax"": ""0.5 0"",
        ""offsetmin"": ""-106 86"",
        ""offsetmax"": ""86 112""
      }
    ]
  },
  {
    ""name"": ""hpbar_img"",
    ""parent"": ""hpbar_background"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""sprite"": ""assets/icons/health.png"",
        ""material"": ""assets/icons/iconmaterial.mat"",
        ""color"": ""0.9686275 0.9176471 0.8784314 0.6745098""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""0 1"",
        ""offsetmin"": ""4 4"",
        ""offsetmax"": ""22 -4""
      }
    ]
  },
  {
    ""name"": ""hpbar_wrapper"",
    ""parent"": ""hpbar_background"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""material"": """",
        ""color"": ""1 0.4039216 0.4039216 0""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""1 1"",
        ""offsetmin"": ""25 3"",
        ""offsetmax"": ""-3 -3""
      }
    ]
  },
  {
    ""name"": ""hpbar_progress"",
    ""parent"": ""hpbar_wrapper"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""sprite"": ""assets/content/ui/ui.background.tile.psd"",
        ""material"": """",
        ""color"": ""0.6941177 0.2039216 0.003921569 0.5450981""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""{progress} 1"",
        ""offsetmin"": ""0 0"",
        ""offsetmax"": ""0 0""
      }
    ]
  },
  {
    ""name"": ""hpbar_text"",
    ""parent"": ""hpbar_wrapper"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Text"",
        ""text"": ""{text}"",
        ""fontSize"": 15,
        ""font"": ""robotocondensed-bold.ttf"",
        ""align"": ""MiddleLeft"",
        ""color"": ""0.9686275 0.9176471 0.8784314 0.8945568""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""1 1"",
        ""offsetmin"": ""2 0"",
        ""offsetmax"": ""0 0""
      }
    ]
  }
]
        ";

    }
}
Error while compiling: HealthBar.cs(59,31): error CS0038: Cannot access a nonstatic member of outer type `Oxide.Plugins.HealthBar' via nested type `Oxide.Plugins.HealthBar.GuiControl'
Ошибка заключается в том, что вы пытаетесь обратиться к нестатическому члену внешнего типа HealthBar из вложенного типа GuiControl. Чтобы это исправить, вы можете передать экземпляр HealthBar в конструктор GuiControl как аргумент и сохранить его в приватном поле:

Код:
public class GuiControl
{
    private readonly HealthBar _Plugin;
    private readonly float _DestroySeconds;
    
    public GuiControl(HealthBar plugin, float destroySeconds)
    {
        this._Plugin = plugin;
        this._DestroySeconds = destroySeconds;
    }
    
    ...
}

И в методе Loaded() создайте экземпляр GuiControl, передавая текущий экземпляр плагина:

Код:
void Loaded()
{
    _GuiControl = new GuiControl(this, 5f);
}

Тогда вы можете обращаться к экземпляру HealthBar через поле _Plugin внутри класса GuiControl.
 
Ошибка заключается в том, что вы пытаетесь обратиться к нестатическому члену внешнего типа HealthBar из вложенного типа GuiControl. Чтобы это исправить, вы можете передать экземпляр HealthBar в конструктор GuiControl как аргумент и сохранить его в приватном поле:

Код:
public class GuiControl
{
    private readonly HealthBar _Plugin;
    private readonly float _DestroySeconds;
   
    public GuiControl(HealthBar plugin, float destroySeconds)
    {
        this._Plugin = plugin;
        this._DestroySeconds = destroySeconds;
    }
   
    ...
}

И в методе Loaded() создайте экземпляр GuiControl, передавая текущий экземпляр плагина:

Код:
void Loaded()
{
    _GuiControl = new GuiControl(this, 5f);
}

Тогда вы можете обращаться к экземпляру HealthBar через поле _Plugin внутри класса GuiControl.
C#:
using System.Collections.Generic;
using Oxide.Game.Rust.Cui;
namespace Oxide.Plugins 
{
    [Info ("Health Bar", "Raskolov", "0.1.0")]
    class HealthBar : RustPlugin 
    {
        class GuiControl
        {
            private Dictionary<BasePlayer, Timer> _Timers = new Dictionary<BasePlayer, Timer>();
            private readonly PluginTimers _Timer;
            private readonly float destroySeconds;
            public GuiControl(PluginTimers timer, float destroySeconds)
            {
                this._Timer = timer;
                this._DestroySeconds = destroySeconds;
            }
            public void TriggerDamage(BasePlayer player, float health, float maxHelth)
            {
                RemovePlayer(player);
                var progressText = health / maxHelth + "";
                var healthText = (int)health + "";
                DrawUI(player, progressText, healthText);
                AddPlayer(player);
            }
            public void TriggerDeath(BasePlayer player, float health, float maxHelth)
            {
              
            }
            void AddPlayer(BasePlayer player)
            {
                _Timers[player] = _Timer.Once(_DestroySeconds, () => 
                {
                    RemovePlayer(player);
                });
            }
            void RemovePlayer(BasePlayer player)
            {
                Timer pTimer;
                if (_Timers.TryGetValue(player, out pTimer))
                {
                    _Timer.Destroy(ref pTimer);
                    DestroyUI(player);
                    _Timers.Remove(player);
                }
            }
            void DrawUI (BasePlayer player, string progress, string text)
            {
                string json = CUI_MAIN
                    .Replace("{progress}", progress)
                    .Replace("{text}", text);
                CuiHelper.AddUi(player, json);
            }
            void DestroyUI(BasePlayer player)
            {
                CuiHelper.DestroyUi(player, "hpbar_background");
            }
        }
        GuiControl _GuiControl;

        void Loaded()
        {
            Puts("Loaded");
        }
        void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info)
        {
           var player = info.InitiatorPlayer;
           if (player && player.IsAlive())
           {
               NextTick(() => 
               {
                   if (entity.IsAlive() && player?.IsConnected == true)
                   {
                      var health = entity.health;
                      var maxHelth = entity.MaxHealth();
                      var progress = health / maxHelth;
                      var text = (int) health;
                      string json = CUI_MAIN
                          .Replace("{progress}", progress.ToString())
                          .Replace("{text}", text.ToString());
                      CuiHelper.DestroyUi(player, "hpbar_background");
                      CuiHelper.AddUi(player, json);
                   }
               });
           }
        }
        void OnEntityDeath(BaseCombatEntity entity, HitInfo info)
        {
           var player = info.InitiatorPlayer;
           if (player && player.IsAlive())
           {
                string json = CUI_MAIN
                    .Replace("{progress}", "0")
                    .Replace("{text}", "Убит!");
                CuiHelper.DestroyUi(player, "hpbar_background");
                CuiHelper.AddUi(player, json);
           }
        }
        [ChatCommand("gui")]
        void cmdChatGui(BasePlayer player)
        {
            string json = CUI_MAIN
                .Replace("{progress}", "0.5")
                .Replace("{text}", "50");
            CuiHelper.AddUi(player, json);
            timer.Once(5f, () => 
            {
                CuiHelper.DestroyUi(player, "hpbar_background");
            });
        }
        string CUI_MAIN = @"
            [
  {
    ""name"": ""hpbar_background"",
    ""parent"": ""Overlay"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""material"": """",
        ""color"": ""0.5254902 0.5254902 0.5254902 0.2980392""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0.5 0"",
        ""anchormax"": ""0.5 0"",
        ""offsetmin"": ""-106 86"",
        ""offsetmax"": ""86 112""
      }
    ]
  },
  {
    ""name"": ""hpbar_img"",
    ""parent"": ""hpbar_background"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""sprite"": ""assets/icons/health.png"",
        ""material"": ""assets/icons/iconmaterial.mat"",
        ""color"": ""0.9686275 0.9176471 0.8784314 0.6745098""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""0 1"",
        ""offsetmin"": ""4 4"",
        ""offsetmax"": ""22 -4""
      }
    ]
  },
  {
    ""name"": ""hpbar_wrapper"",
    ""parent"": ""hpbar_background"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""material"": """",
        ""color"": ""1 0.4039216 0.4039216 0""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""1 1"",
        ""offsetmin"": ""25 3"",
        ""offsetmax"": ""-3 -3""
      }
    ]
  },
  {
    ""name"": ""hpbar_progress"",
    ""parent"": ""hpbar_wrapper"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""sprite"": ""assets/content/ui/ui.background.tile.psd"",
        ""material"": """",
        ""color"": ""0.6941177 0.2039216 0.003921569 0.5450981""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""{progress} 1"",
        ""offsetmin"": ""0 0"",
        ""offsetmax"": ""0 0""
      }
    ]
  },
  {
    ""name"": ""hpbar_text"",
    ""parent"": ""hpbar_wrapper"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Text"",
        ""text"": ""{text}"",
        ""fontSize"": 15,
        ""font"": ""robotocondensed-bold.ttf"",
        ""align"": ""MiddleLeft"",
        ""color"": ""0.9686275 0.9176471 0.8784314 0.8945568""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""1 1"",
        ""offsetmin"": ""2 0"",
        ""offsetmax"": ""0 0""
      }
    ]
  }
]
        ";
    }
}
Error while compiling: HealthBar.cs(61,31): error CS0038: Cannot access a nonstatic member of outer type `Oxide.Plugins.HealthBar' via nested type `Oxide.Plugins.HealthBar.GuiControl'
 
C#:
using System.Collections.Generic;
using Oxide.Game.Rust.Cui;
namespace Oxide.Plugins 
{
    [Info ("Health Bar", "Raskolov", "0.1.0")]
    class HealthBar : RustPlugin 
    {
        class GuiControl
        {
            private Dictionary<BasePlayer, Timer> _Timers = new Dictionary<BasePlayer, Timer>();
            private readonly PluginTimers _Timer;
            private readonly float destroySeconds;
            public GuiControl(PluginTimers timer, float destroySeconds)
            {
                this._Timer = timer;
                this._DestroySeconds = destroySeconds;
            }
            public void TriggerDamage(BasePlayer player, float health, float maxHelth)
            {
                RemovePlayer(player);
                var progressText = health / maxHelth + "";
                var healthText = (int)health + "";
                DrawUI(player, progressText, healthText);
                AddPlayer(player);
            }
            public void TriggerDeath(BasePlayer player, float health, float maxHelth)
            {
              
            }
            void AddPlayer(BasePlayer player)
            {
                _Timers[player] = _Timer.Once(_DestroySeconds, () => 
                {
                    RemovePlayer(player);
                });
            }
            void RemovePlayer(BasePlayer player)
            {
                Timer pTimer;
                if (_Timers.TryGetValue(player, out pTimer))
                {
                    _Timer.Destroy(ref pTimer);
                    DestroyUI(player);
                    _Timers.Remove(player);
                }
            }
            void DrawUI (BasePlayer player, string progress, string text)
            {
                string json = CUI_MAIN
                    .Replace("{progress}", progress)
                    .Replace("{text}", text);
                CuiHelper.AddUi(player, json);
            }
            void DestroyUI(BasePlayer player)
            {
                CuiHelper.DestroyUi(player, "hpbar_background");
            }
        }
        GuiControl _GuiControl;

        void Loaded()
        {
            Puts("Loaded");
        }
        void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info)
        {
           var player = info.InitiatorPlayer;
           if (player && player.IsAlive())
           {
               NextTick(() => 
               {
                   if (entity.IsAlive() && player?.IsConnected == true)
                   {
                      var health = entity.health;
                      var maxHelth = entity.MaxHealth();
                      var progress = health / maxHelth;
                      var text = (int) health;
                      string json = CUI_MAIN
                          .Replace("{progress}", progress.ToString())
                          .Replace("{text}", text.ToString());
                      CuiHelper.DestroyUi(player, "hpbar_background");
                      CuiHelper.AddUi(player, json);
                   }
               });
           }
        }
        void OnEntityDeath(BaseCombatEntity entity, HitInfo info)
        {
           var player = info.InitiatorPlayer;
           if (player && player.IsAlive())
           {
                string json = CUI_MAIN
                    .Replace("{progress}", "0")
                    .Replace("{text}", "Убит!");
                CuiHelper.DestroyUi(player, "hpbar_background");
                CuiHelper.AddUi(player, json);
           }
        }
        [ChatCommand("gui")]
        void cmdChatGui(BasePlayer player)
        {
            string json = CUI_MAIN
                .Replace("{progress}", "0.5")
                .Replace("{text}", "50");
            CuiHelper.AddUi(player, json);
            timer.Once(5f, () => 
            {
                CuiHelper.DestroyUi(player, "hpbar_background");
            });
        }
        string CUI_MAIN = @"
            [
  {
    ""name"": ""hpbar_background"",
    ""parent"": ""Overlay"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""material"": """",
        ""color"": ""0.5254902 0.5254902 0.5254902 0.2980392""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0.5 0"",
        ""anchormax"": ""0.5 0"",
        ""offsetmin"": ""-106 86"",
        ""offsetmax"": ""86 112""
      }
    ]
  },
  {
    ""name"": ""hpbar_img"",
    ""parent"": ""hpbar_background"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""sprite"": ""assets/icons/health.png"",
        ""material"": ""assets/icons/iconmaterial.mat"",
        ""color"": ""0.9686275 0.9176471 0.8784314 0.6745098""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""0 1"",
        ""offsetmin"": ""4 4"",
        ""offsetmax"": ""22 -4""
      }
    ]
  },
  {
    ""name"": ""hpbar_wrapper"",
    ""parent"": ""hpbar_background"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""material"": """",
        ""color"": ""1 0.4039216 0.4039216 0""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""1 1"",
        ""offsetmin"": ""25 3"",
        ""offsetmax"": ""-3 -3""
      }
    ]
  },
  {
    ""name"": ""hpbar_progress"",
    ""parent"": ""hpbar_wrapper"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""sprite"": ""assets/content/ui/ui.background.tile.psd"",
        ""material"": """",
        ""color"": ""0.6941177 0.2039216 0.003921569 0.5450981""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""{progress} 1"",
        ""offsetmin"": ""0 0"",
        ""offsetmax"": ""0 0""
      }
    ]
  },
  {
    ""name"": ""hpbar_text"",
    ""parent"": ""hpbar_wrapper"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Text"",
        ""text"": ""{text}"",
        ""fontSize"": 15,
        ""font"": ""robotocondensed-bold.ttf"",
        ""align"": ""MiddleLeft"",
        ""color"": ""0.9686275 0.9176471 0.8784314 0.8945568""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""1 1"",
        ""offsetmin"": ""2 0"",
        ""offsetmax"": ""0 0""
      }
    ]
  }
]
        ";
    }
}
Error while compiling: HealthBar.cs(61,31): error CS0038: Cannot access a nonstatic member of outer type `Oxide.Plugins.HealthBar' via nested type `Oxide.Plugins.HealthBar.GuiControl'
Ошибка заключается в том, что вы пытаетесь обратиться к нестатическому члену внешнего типа HealthBar из вложенного типа GuiControl. Чтобы это исправить, вы можете передать экземпляр HealthBar в конструктор GuiControl как аргумент и сохранить его в приватном поле:

Код:
public class GuiControl
{
    private readonly HealthBar _Plugin;
    private readonly PluginTimers _Timer;
    private readonly float destroySeconds;
   
    public GuiControl(HealthBar plugin, PluginTimers timer, float destroySeconds)
    {
        this._Plugin = plugin;
        this._Timer = timer;
        this._DestroySeconds = destroySeconds;
    }
   
    ...
}

И в методе Loaded() создайте экземпляр GuiControl, передавая текущий экземпляр плагина и таймеры:

Код:
void Loaded()
{
    _GuiControl = new GuiControl(this, plugin.Timer, 5f);
}

Тогда вы можете обращаться к экземпляру HealthBar через поле _Plugin внутри класса GuiControl.
 
Ошибка заключается в том, что вы пытаетесь обратиться к нестатическому члену внешнего типа HealthBar из вложенного типа GuiControl. Чтобы это исправить, вы можете передать экземпляр HealthBar в конструктор GuiControl как аргумент и сохранить его в приватном поле:

Код:
public class GuiControl
{
    private readonly HealthBar _Plugin;
    private readonly PluginTimers _Timer;
    private readonly float destroySeconds;
  
    public GuiControl(HealthBar plugin, PluginTimers timer, float destroySeconds)
    {
        this._Plugin = plugin;
        this._Timer = timer;
        this._DestroySeconds = destroySeconds;
    }
  
    ...
}

И в методе Loaded() создайте экземпляр GuiControl, передавая текущий экземпляр плагина и таймеры:

Код:
void Loaded()
{
    _GuiControl = new GuiControl(this, plugin.Timer, 5f);
}

Тогда вы можете обращаться к экземпляру HealthBar через поле _Plugin внутри класса GuiControl.
C#:
using System.Collections.Generic;
using Oxide.Game.Rust.Cui;

namespace Oxide.Plugins
{
    [Info ("Health Bar", "Raskolov", "0.1.0")]

    class HealthBar : RustPlugin
    {

        public class GuiControl
        {
            private Dictionary<BasePlayer, Timer> _Timers = new Dictionary<BasePlayer, Timer>();

            private readonly HealthBar _Plugin;
            private readonly PluginTimers _Timer;
            private readonly float destroySeconds;

            public GuiControl(HealthBar plugin, PluginTimers timer, float destroySeconds)
            {
                this._Timer = plugin;
                this._Timer = timer;
                this._DestroySeconds = destroySeconds;
            }

            public void TriggerDamage(BasePlayer player, float health, float maxHelth)
            {
                RemovePlayer(player);
                var progressText = health / maxHelth + "";
                var healthText = (int)health + "";
                DrawUI(player, progressText, healthText);
                AddPlayer(player);
            }

            public void TriggerDeath(BasePlayer player, float health, float maxHelth)
            {
              
            }

            void AddPlayer(BasePlayer player)
            {
                _Timers[player] = _Timer.Once(_DestroySeconds, () =>
                {
                    RemovePlayer(player);
                });
            }

            void RemovePlayer(BasePlayer player)
            {
                Timer pTimer;
                if (_Timers.TryGetValue(player, out pTimer))
                {
                    _Timer.Destroy(ref pTimer);
                    DestroyUI(player);
                    _Timers.Remove(player);
                }
            }

            void DrawUI (BasePlayer player, string progress, string text)
            {
                string json = CUI_MAIN
                    .Replace("{progress}", progress)
                    .Replace("{text}", text);
                CuiHelper.AddUi(player, json);
            }

            void DestroyUI(BasePlayer player)
            {
                CuiHelper.DestroyUi(player, "hpbar_background");
            }
        }

        GuiControl _GuiControl;


        void Loaded()
        {
            _GuiControl = new GuiControl(this, plugin.Timer, 5f);
        }

        void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info)
        {
           var player = info.InitiatorPlayer;
           if (player && player.IsAlive())
           {
               NextTick(() =>
               {
                   if (entity.IsAlive() && player?.IsConnected == true)
                   {
                      var health = entity.health;
                      var maxHelth = entity.MaxHealth();

                      var progress = health / maxHelth;
                      var text = (int) health;
                      string json = CUI_MAIN
                          .Replace("{progress}", progress.ToString())
                          .Replace("{text}", text.ToString());
                      CuiHelper.DestroyUi(player, "hpbar_background");
                      CuiHelper.AddUi(player, json);
                   }
               });
           }
        }

        void OnEntityDeath(BaseCombatEntity entity, HitInfo info)
        {
           var player = info.InitiatorPlayer;
           if (player && player.IsAlive())
           {
                string json = CUI_MAIN
                    .Replace("{progress}", "0")
                    .Replace("{text}", "Убит!");
                CuiHelper.DestroyUi(player, "hpbar_background");
                CuiHelper.AddUi(player, json);
           }
        }

        [ChatCommand("gui")]
        void cmdChatGui(BasePlayer player)
        {
            string json = CUI_MAIN
                .Replace("{progress}", "0.5")
                .Replace("{text}", "50");

            CuiHelper.AddUi(player, json);
            timer.Once(5f, () =>
            {
                CuiHelper.DestroyUi(player, "hpbar_background");
            });
        }

        string CUI_MAIN = @"
            [
  {
    ""name"": ""hpbar_background"",
    ""parent"": ""Overlay"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""material"": """",
        ""color"": ""0.5254902 0.5254902 0.5254902 0.2980392""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0.5 0"",
        ""anchormax"": ""0.5 0"",
        ""offsetmin"": ""-106 86"",
        ""offsetmax"": ""86 112""
      }
    ]
  },
  {
    ""name"": ""hpbar_img"",
    ""parent"": ""hpbar_background"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""sprite"": ""assets/icons/health.png"",
        ""material"": ""assets/icons/iconmaterial.mat"",
        ""color"": ""0.9686275 0.9176471 0.8784314 0.6745098""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""0 1"",
        ""offsetmin"": ""4 4"",
        ""offsetmax"": ""22 -4""
      }
    ]
  },
  {
    ""name"": ""hpbar_wrapper"",
    ""parent"": ""hpbar_background"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""material"": """",
        ""color"": ""1 0.4039216 0.4039216 0""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""1 1"",
        ""offsetmin"": ""25 3"",
        ""offsetmax"": ""-3 -3""
      }
    ]
  },
  {
    ""name"": ""hpbar_progress"",
    ""parent"": ""hpbar_wrapper"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""sprite"": ""assets/content/ui/ui.background.tile.psd"",
        ""material"": """",
        ""color"": ""0.6941177 0.2039216 0.003921569 0.5450981""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""{progress} 1"",
        ""offsetmin"": ""0 0"",
        ""offsetmax"": ""0 0""
      }
    ]
  },
  {
    ""name"": ""hpbar_text"",
    ""parent"": ""hpbar_wrapper"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Text"",
        ""text"": ""{text}"",
        ""fontSize"": 15,
        ""font"": ""robotocondensed-bold.ttf"",
        ""align"": ""MiddleLeft"",
        ""color"": ""0.9686275 0.9176471 0.8784314 0.8945568""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""1 1"",
        ""offsetmin"": ""2 0"",
        ""offsetmax"": ""0 0""
      }
    ]
  }
]
        ";
    }
}
Error while compiling: HealthBar.cs(80,48): error CS0103: The name `plugin' does not exist in the current context
 
C#:
using System.Collections.Generic;
using Oxide.Game.Rust.Cui;

namespace Oxide.Plugins
{
    [Info ("Health Bar", "Raskolov", "0.1.0")]

    class HealthBar : RustPlugin
    {

        public class GuiControl
        {
            private Dictionary<BasePlayer, Timer> _Timers = new Dictionary<BasePlayer, Timer>();

            private readonly HealthBar _Plugin;
            private readonly PluginTimers _Timer;
            private readonly float destroySeconds;

            public GuiControl(HealthBar plugin, PluginTimers timer, float destroySeconds)
            {
                this._Timer = plugin;
                this._Timer = timer;
                this._DestroySeconds = destroySeconds;
            }

            public void TriggerDamage(BasePlayer player, float health, float maxHelth)
            {
                RemovePlayer(player);
                var progressText = health / maxHelth + "";
                var healthText = (int)health + "";
                DrawUI(player, progressText, healthText);
                AddPlayer(player);
            }

            public void TriggerDeath(BasePlayer player, float health, float maxHelth)
            {
              
            }

            void AddPlayer(BasePlayer player)
            {
                _Timers[player] = _Timer.Once(_DestroySeconds, () =>
                {
                    RemovePlayer(player);
                });
            }

            void RemovePlayer(BasePlayer player)
            {
                Timer pTimer;
                if (_Timers.TryGetValue(player, out pTimer))
                {
                    _Timer.Destroy(ref pTimer);
                    DestroyUI(player);
                    _Timers.Remove(player);
                }
            }

            void DrawUI (BasePlayer player, string progress, string text)
            {
                string json = CUI_MAIN
                    .Replace("{progress}", progress)
                    .Replace("{text}", text);
                CuiHelper.AddUi(player, json);
            }

            void DestroyUI(BasePlayer player)
            {
                CuiHelper.DestroyUi(player, "hpbar_background");
            }
        }

        GuiControl _GuiControl;


        void Loaded()
        {
            _GuiControl = new GuiControl(this, plugin.Timer, 5f);
        }

        void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info)
        {
           var player = info.InitiatorPlayer;
           if (player && player.IsAlive())
           {
               NextTick(() =>
               {
                   if (entity.IsAlive() && player?.IsConnected == true)
                   {
                      var health = entity.health;
                      var maxHelth = entity.MaxHealth();

                      var progress = health / maxHelth;
                      var text = (int) health;
                      string json = CUI_MAIN
                          .Replace("{progress}", progress.ToString())
                          .Replace("{text}", text.ToString());
                      CuiHelper.DestroyUi(player, "hpbar_background");
                      CuiHelper.AddUi(player, json);
                   }
               });
           }
        }

        void OnEntityDeath(BaseCombatEntity entity, HitInfo info)
        {
           var player = info.InitiatorPlayer;
           if (player && player.IsAlive())
           {
                string json = CUI_MAIN
                    .Replace("{progress}", "0")
                    .Replace("{text}", "Убит!");
                CuiHelper.DestroyUi(player, "hpbar_background");
                CuiHelper.AddUi(player, json);
           }
        }

        [ChatCommand("gui")]
        void cmdChatGui(BasePlayer player)
        {
            string json = CUI_MAIN
                .Replace("{progress}", "0.5")
                .Replace("{text}", "50");

            CuiHelper.AddUi(player, json);
            timer.Once(5f, () =>
            {
                CuiHelper.DestroyUi(player, "hpbar_background");
            });
        }

        string CUI_MAIN = @"
            [
  {
    ""name"": ""hpbar_background"",
    ""parent"": ""Overlay"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""material"": """",
        ""color"": ""0.5254902 0.5254902 0.5254902 0.2980392""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0.5 0"",
        ""anchormax"": ""0.5 0"",
        ""offsetmin"": ""-106 86"",
        ""offsetmax"": ""86 112""
      }
    ]
  },
  {
    ""name"": ""hpbar_img"",
    ""parent"": ""hpbar_background"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""sprite"": ""assets/icons/health.png"",
        ""material"": ""assets/icons/iconmaterial.mat"",
        ""color"": ""0.9686275 0.9176471 0.8784314 0.6745098""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""0 1"",
        ""offsetmin"": ""4 4"",
        ""offsetmax"": ""22 -4""
      }
    ]
  },
  {
    ""name"": ""hpbar_wrapper"",
    ""parent"": ""hpbar_background"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""material"": """",
        ""color"": ""1 0.4039216 0.4039216 0""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""1 1"",
        ""offsetmin"": ""25 3"",
        ""offsetmax"": ""-3 -3""
      }
    ]
  },
  {
    ""name"": ""hpbar_progress"",
    ""parent"": ""hpbar_wrapper"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""sprite"": ""assets/content/ui/ui.background.tile.psd"",
        ""material"": """",
        ""color"": ""0.6941177 0.2039216 0.003921569 0.5450981""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""{progress} 1"",
        ""offsetmin"": ""0 0"",
        ""offsetmax"": ""0 0""
      }
    ]
  },
  {
    ""name"": ""hpbar_text"",
    ""parent"": ""hpbar_wrapper"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Text"",
        ""text"": ""{text}"",
        ""fontSize"": 15,
        ""font"": ""robotocondensed-bold.ttf"",
        ""align"": ""MiddleLeft"",
        ""color"": ""0.9686275 0.9176471 0.8784314 0.8945568""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""1 1"",
        ""offsetmin"": ""2 0"",
        ""offsetmax"": ""0 0""
      }
    ]
  }
]
        ";
    }
}
Error while compiling: HealthBar.cs(80,48): error CS0103: The name `plugin' does not exist in the current context
Ошибка заключается в том, что вы обращаетесь к несуществующей переменной plugin вместо this в конструкторе класса GuiControl. Замените this._Timer = plugin; на this._Plugin = plugin;:

Код:
public GuiControl(HealthBar plugin, PluginTimers timer, float destroySeconds)
{
    this._Plugin = plugin;
    this._Timer = timer;
    this._DestroySeconds = destroySeconds;
}

Также замените _GuiControl = new GuiControl(this, plugin.Timer, 5f); на _GuiControl = new GuiControl(this, timer, 5f);, чтобы передать правильный таймер:

Код:
void Loaded()
{
    _GuiControl = new GuiControl(this, timer, 5f);
}
 
Ошибка заключается в том, что вы обращаетесь к несуществующей переменной plugin вместо this в конструкторе класса GuiControl. Замените this._Timer = plugin; на this._Plugin = plugin;:

Код:
public GuiControl(HealthBar plugin, PluginTimers timer, float destroySeconds)
{
    this._Plugin = plugin;
    this._Timer = timer;
    this._DestroySeconds = destroySeconds;
}

Также замените _GuiControl = new GuiControl(this, plugin.Timer, 5f); на _GuiControl = new GuiControl(this, timer, 5f);, чтобы передать правильный таймер:

Код:
void Loaded()
{
    _GuiControl = new GuiControl(this, timer, 5f);
}
C#:
using System.Collections.Generic;
using Oxide.Game.Rust.Cui;

namespace Oxide.Plugins
{
    [Info ("Health Bar", "Raskolov", "0.1.0")]

    class HealthBar : RustPlugin
    {

        public class GuiControl
        {
            private Dictionary<BasePlayer, Timer> _Timers = new Dictionary<BasePlayer, Timer>();

            private readonly HealthBar _Plugin;
            private readonly PluginTimers _Timer;
            private readonly float destroySeconds;

            public GuiControl(HealthBar plugin, PluginTimers timer, float destroySeconds)
            {
                this._Timer = plugin;
                this._Timer = timer;
                this._DestroySeconds = destroySeconds;
            }

            public void TriggerDamage(BasePlayer player, float health, float maxHelth)
            {
                RemovePlayer(player);
                var progressText = health / maxHelth + "";
                var healthText = (int)health + "";
                DrawUI(player, progressText, healthText);
                AddPlayer(player);
            }

            public void TriggerDeath(BasePlayer player, float health, float maxHelth)
            {
              
            }

            void AddPlayer(BasePlayer player)
            {
                _Timers[player] = _Timer.Once(_DestroySeconds, () =>
                {
                    RemovePlayer(player);
                });
            }

            void RemovePlayer(BasePlayer player)
            {
                Timer pTimer;
                if (_Timers.TryGetValue(player, out pTimer))
                {
                    _Timer.Destroy(ref pTimer);
                    DestroyUI(player);
                    _Timers.Remove(player);
                }
            }

            void DrawUI (BasePlayer player, string progress, string text)
            {
                string json = CUI_MAIN
                    .Replace("{progress}", progress)
                    .Replace("{text}", text);
                CuiHelper.AddUi(player, json);
            }

            void DestroyUI(BasePlayer player)
            {
                CuiHelper.DestroyUi(player, "hpbar_background");
            }
        }

        GuiControl _GuiControl;


        void Loaded()
        {
            _GuiControl = new GuiControl(this, timer, 5f);
        }

        void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info)
        {
           var player = info.InitiatorPlayer;
           if (player && player.IsAlive())
           {
               NextTick(() =>
               {
                   if (entity.IsAlive() && player?.IsConnected == true)
                   {
                      var health = entity.health;
                      var maxHelth = entity.MaxHealth();

                      var progress = health / maxHelth;
                      var text = (int) health;
                      string json = CUI_MAIN
                          .Replace("{progress}", progress.ToString())
                          .Replace("{text}", text.ToString());
                      CuiHelper.DestroyUi(player, "hpbar_background");
                      CuiHelper.AddUi(player, json);
                   }
               });
           }
        }

        void OnEntityDeath(BaseCombatEntity entity, HitInfo info)
        {
           var player = info.InitiatorPlayer;
           if (player && player.IsAlive())
           {
                string json = CUI_MAIN
                    .Replace("{progress}", "0")
                    .Replace("{text}", "Убит!");
                CuiHelper.DestroyUi(player, "hpbar_background");
                CuiHelper.AddUi(player, json);
           }
        }

        [ChatCommand("gui")]
        void cmdChatGui(BasePlayer player)
        {
            string json = CUI_MAIN
                .Replace("{progress}", "0.5")
                .Replace("{text}", "50");

            CuiHelper.AddUi(player, json);
            timer.Once(5f, () =>
            {
                CuiHelper.DestroyUi(player, "hpbar_background");
            });
        }

        string CUI_MAIN = @"
            [
  {
    ""name"": ""hpbar_background"",
    ""parent"": ""Overlay"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""material"": """",
        ""color"": ""0.5254902 0.5254902 0.5254902 0.2980392""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0.5 0"",
        ""anchormax"": ""0.5 0"",
        ""offsetmin"": ""-106 86"",
        ""offsetmax"": ""86 112""
      }
    ]
  },
  {
    ""name"": ""hpbar_img"",
    ""parent"": ""hpbar_background"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""sprite"": ""assets/icons/health.png"",
        ""material"": ""assets/icons/iconmaterial.mat"",
        ""color"": ""0.9686275 0.9176471 0.8784314 0.6745098""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""0 1"",
        ""offsetmin"": ""4 4"",
        ""offsetmax"": ""22 -4""
      }
    ]
  },
  {
    ""name"": ""hpbar_wrapper"",
    ""parent"": ""hpbar_background"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""material"": """",
        ""color"": ""1 0.4039216 0.4039216 0""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""1 1"",
        ""offsetmin"": ""25 3"",
        ""offsetmax"": ""-3 -3""
      }
    ]
  },
  {
    ""name"": ""hpbar_progress"",
    ""parent"": ""hpbar_wrapper"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""sprite"": ""assets/content/ui/ui.background.tile.psd"",
        ""material"": """",
        ""color"": ""0.6941177 0.2039216 0.003921569 0.5450981""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""{progress} 1"",
        ""offsetmin"": ""0 0"",
        ""offsetmax"": ""0 0""
      }
    ]
  },
  {
    ""name"": ""hpbar_text"",
    ""parent"": ""hpbar_wrapper"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Text"",
        ""text"": ""{text}"",
        ""fontSize"": 15,
        ""font"": ""robotocondensed-bold.ttf"",
        ""align"": ""MiddleLeft"",
        ""color"": ""0.9686275 0.9176471 0.8784314 0.8945568""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""1 1"",
        ""offsetmin"": ""2 0"",
        ""offsetmax"": ""0 0""
      }
    ]
  }
]
        ";
    }
}
Error while compiling: HealthBar.cs(63,31): error CS0038: Cannot access a nonstatic member of outer type `Oxide.Plugins.HealthBar' via nested type `Oxide.Plugins.HealthBar.GuiControl'
 
C#:
using System.Collections.Generic;
using Oxide.Game.Rust.Cui;

namespace Oxide.Plugins
{
    [Info ("Health Bar", "Raskolov", "0.1.0")]

    class HealthBar : RustPlugin
    {

        public class GuiControl
        {
            private Dictionary<BasePlayer, Timer> _Timers = new Dictionary<BasePlayer, Timer>();

            private readonly HealthBar _Plugin;
            private readonly PluginTimers _Timer;
            private readonly float destroySeconds;

            public GuiControl(HealthBar plugin, PluginTimers timer, float destroySeconds)
            {
                this._Timer = plugin;
                this._Timer = timer;
                this._DestroySeconds = destroySeconds;
            }

            public void TriggerDamage(BasePlayer player, float health, float maxHelth)
            {
                RemovePlayer(player);
                var progressText = health / maxHelth + "";
                var healthText = (int)health + "";
                DrawUI(player, progressText, healthText);
                AddPlayer(player);
            }

            public void TriggerDeath(BasePlayer player, float health, float maxHelth)
            {
              
            }

            void AddPlayer(BasePlayer player)
            {
                _Timers[player] = _Timer.Once(_DestroySeconds, () =>
                {
                    RemovePlayer(player);
                });
            }

            void RemovePlayer(BasePlayer player)
            {
                Timer pTimer;
                if (_Timers.TryGetValue(player, out pTimer))
                {
                    _Timer.Destroy(ref pTimer);
                    DestroyUI(player);
                    _Timers.Remove(player);
                }
            }

            void DrawUI (BasePlayer player, string progress, string text)
            {
                string json = CUI_MAIN
                    .Replace("{progress}", progress)
                    .Replace("{text}", text);
                CuiHelper.AddUi(player, json);
            }

            void DestroyUI(BasePlayer player)
            {
                CuiHelper.DestroyUi(player, "hpbar_background");
            }
        }

        GuiControl _GuiControl;


        void Loaded()
        {
            _GuiControl = new GuiControl(this, timer, 5f);
        }

        void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info)
        {
           var player = info.InitiatorPlayer;
           if (player && player.IsAlive())
           {
               NextTick(() =>
               {
                   if (entity.IsAlive() && player?.IsConnected == true)
                   {
                      var health = entity.health;
                      var maxHelth = entity.MaxHealth();

                      var progress = health / maxHelth;
                      var text = (int) health;
                      string json = CUI_MAIN
                          .Replace("{progress}", progress.ToString())
                          .Replace("{text}", text.ToString());
                      CuiHelper.DestroyUi(player, "hpbar_background");
                      CuiHelper.AddUi(player, json);
                   }
               });
           }
        }

        void OnEntityDeath(BaseCombatEntity entity, HitInfo info)
        {
           var player = info.InitiatorPlayer;
           if (player && player.IsAlive())
           {
                string json = CUI_MAIN
                    .Replace("{progress}", "0")
                    .Replace("{text}", "Убит!");
                CuiHelper.DestroyUi(player, "hpbar_background");
                CuiHelper.AddUi(player, json);
           }
        }

        [ChatCommand("gui")]
        void cmdChatGui(BasePlayer player)
        {
            string json = CUI_MAIN
                .Replace("{progress}", "0.5")
                .Replace("{text}", "50");

            CuiHelper.AddUi(player, json);
            timer.Once(5f, () =>
            {
                CuiHelper.DestroyUi(player, "hpbar_background");
            });
        }

        string CUI_MAIN = @"
            [
  {
    ""name"": ""hpbar_background"",
    ""parent"": ""Overlay"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""material"": """",
        ""color"": ""0.5254902 0.5254902 0.5254902 0.2980392""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0.5 0"",
        ""anchormax"": ""0.5 0"",
        ""offsetmin"": ""-106 86"",
        ""offsetmax"": ""86 112""
      }
    ]
  },
  {
    ""name"": ""hpbar_img"",
    ""parent"": ""hpbar_background"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""sprite"": ""assets/icons/health.png"",
        ""material"": ""assets/icons/iconmaterial.mat"",
        ""color"": ""0.9686275 0.9176471 0.8784314 0.6745098""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""0 1"",
        ""offsetmin"": ""4 4"",
        ""offsetmax"": ""22 -4""
      }
    ]
  },
  {
    ""name"": ""hpbar_wrapper"",
    ""parent"": ""hpbar_background"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""material"": """",
        ""color"": ""1 0.4039216 0.4039216 0""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""1 1"",
        ""offsetmin"": ""25 3"",
        ""offsetmax"": ""-3 -3""
      }
    ]
  },
  {
    ""name"": ""hpbar_progress"",
    ""parent"": ""hpbar_wrapper"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""sprite"": ""assets/content/ui/ui.background.tile.psd"",
        ""material"": """",
        ""color"": ""0.6941177 0.2039216 0.003921569 0.5450981""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""{progress} 1"",
        ""offsetmin"": ""0 0"",
        ""offsetmax"": ""0 0""
      }
    ]
  },
  {
    ""name"": ""hpbar_text"",
    ""parent"": ""hpbar_wrapper"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Text"",
        ""text"": ""{text}"",
        ""fontSize"": 15,
        ""font"": ""robotocondensed-bold.ttf"",
        ""align"": ""MiddleLeft"",
        ""color"": ""0.9686275 0.9176471 0.8784314 0.8945568""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""1 1"",
        ""offsetmin"": ""2 0"",
        ""offsetmax"": ""0 0""
      }
    ]
  }
]
        ";
    }
}
Error while compiling: HealthBar.cs(63,31): error CS0038: Cannot access a nonstatic member of outer type `Oxide.Plugins.HealthBar' via nested type `Oxide.Plugins.HealthBar.GuiControl'
Ошибка заключается в том, что вы пытаетесь использовать несуществующую переменную plugin, в то время как вы уже создали переменную this._Plugin в конструкторе класса GuiControl. Замените this._Timer = plugin; на this._Plugin = plugin;:

Код:
public GuiControl(HealthBar plugin, PluginTimers timer, float destroySeconds)
{
    this._Plugin = plugin;
    this._Timer = timer;
    this._DestroySeconds = destroySeconds;
}

Также замените this._Timer = plugin; на this._Plugin = plugin;, чтобы передать правильный плагин:

Код:
void Loaded()
{
    _GuiControl = new GuiControl(this, timer, 5f);
}
 
Ошибка заключается в том, что вы пытаетесь использовать несуществующую переменную plugin, в то время как вы уже создали переменную this._Plugin в конструкторе класса GuiControl. Замените this._Timer = plugin; на this._Plugin = plugin;:

Код:
public GuiControl(HealthBar plugin, PluginTimers timer, float destroySeconds)
{
    this._Plugin = plugin;
    this._Timer = timer;
    this._DestroySeconds = destroySeconds;
}

Также замените this._Timer = plugin; на this._Plugin = plugin;, чтобы передать правильный плагин:

Код:
void Loaded()
{
    _GuiControl = new GuiControl(this, timer, 5f);
}
C#:
using System.Collections.Generic;
using Oxide.Game.Rust.Cui;

namespace Oxide.Plugins
{
    [Info ("Health Bar", "Raskolov", "0.1.0")]

    class HealthBar : RustPlugin
    {

        public class GuiControl
        {
            private Dictionary<BasePlayer, Timer> _Timers = new Dictionary<BasePlayer, Timer>();

            private readonly PluginTimers _Timer;
            private readonly float destroySeconds;

            public GuiControl(PluginTimers timer, float destroySeconds)
            {
                this._Timer = timer;
                this._DestroySeconds = destroySeconds;
            }

            public void TriggerDamage(BasePlayer player, float health, float maxHelth)
            {
                RemovePlayer(player);
                var progressText = health / maxHelth + "";
                var healthText = (int)health + "";
                DrawUI(player, progressText, healthText);
                AddPlayer(player);
            }

            public void TriggerDeath(BasePlayer player)
            {
                RemovePlayer(player);
                var progressText = "0";
                var healthText = "Убит!";
                DrawUI(player, progressText, healthText);
                AddPlayer(player);
            }

            void AddPlayer(BasePlayer player)
            {
                _Timers[player] = _Timer.Once(_DestroySeconds, () =>
                {
                    RemovePlayer(player);
                });
            }

            void RemovePlayer(BasePlayer player)
            {
                Timer pTimer;
                if (_Timers.TryGetValue(player, out pTimer))
                {
                    _Timer.Destroy(ref pTimer);
                    DestroyUI(player);
                    _Timers.Remove(player);
                }
            }

            void DrawUI (BasePlayer player, string progress, string text)
            {
                string json = CUI_MAIN
                    .Replace("{progress}", progress)
                    .Replace("{text}", text);
                CuiHelper.AddUi(player, json);
            }

            void DestroyUI(BasePlayer player)
            {
                CuiHelper.DestroyUi(player, "hpbar_background");
            }
        }

        GuiControl _GuiControl;

        void Loaded()
        {
            _GuiControl = new GuiControl(timer, 5f);
        }

        void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info)
        {
           var player = info.InitiatorPlayer;
           if (player && player.IsAlive())
           {
               NextTick(() =>
               {
                   if (entity.IsAlive() && player?.IsConnected == true)
                   {
                      var health = entity.health;
                      var maxHelth = entity.MaxHealth();

                      _GuiControl.TriggerDamage(player, health, maxHelth);
                   }
               });
           }
        }

        void OnEntityDeath(BaseCombatEntity entity, HitInfo info)
        {
           var player = info.InitiatorPlayer;
           if (player && player.IsAlive())
           {
              _GuiControl.TriggerDeath(player);
           }
        }

        [ChatCommand("gui")]
        void cmdChatGui(BasePlayer player)
        {
            string json = CUI_MAIN
                .Replace("{progress}", "0.5")
                .Replace("{text}", "50");

            CuiHelper.AddUi(player, json);
            timer.Once(5f, () =>
            {
                CuiHelper.DestroyUi(player, "hpbar_background");
            });
        }

        string CUI_MAIN = @"
            [
  {
    ""name"": ""hpbar_background"",
    ""parent"": ""Overlay"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""material"": """",
        ""color"": ""0.5254902 0.5254902 0.5254902 0.2980392""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0.5 0"",
        ""anchormax"": ""0.5 0"",
        ""offsetmin"": ""-106 86"",
        ""offsetmax"": ""86 112""
      }
    ]
  },
  {
    ""name"": ""hpbar_img"",
    ""parent"": ""hpbar_background"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""sprite"": ""assets/icons/health.png"",
        ""material"": ""assets/icons/iconmaterial.mat"",
        ""color"": ""0.9686275 0.9176471 0.8784314 0.6745098""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""0 1"",
        ""offsetmin"": ""4 4"",
        ""offsetmax"": ""22 -4""
      }
    ]
  },
  {
    ""name"": ""hpbar_wrapper"",
    ""parent"": ""hpbar_background"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""material"": """",
        ""color"": ""1 0.4039216 0.4039216 0""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""1 1"",
        ""offsetmin"": ""25 3"",
        ""offsetmax"": ""-3 -3""
      }
    ]
  },
  {
    ""name"": ""hpbar_progress"",
    ""parent"": ""hpbar_wrapper"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""sprite"": ""assets/content/ui/ui.background.tile.psd"",
        ""material"": """",
        ""color"": ""0.6941177 0.2039216 0.003921569 0.5450981""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""{progress} 1"",
        ""offsetmin"": ""0 0"",
        ""offsetmax"": ""0 0""
      }
    ]
  },
  {
    ""name"": ""hpbar_text"",
    ""parent"": ""hpbar_wrapper"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Text"",
        ""text"": ""{text}"",
        ""fontSize"": 15,
        ""font"": ""robotocondensed-bold.ttf"",
        ""align"": ""MiddleLeft"",
        ""color"": ""0.9686275 0.9176471 0.8784314 0.8945568""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""1 1"",
        ""offsetmin"": ""2 0"",
        ""offsetmax"": ""0 0""
      }
    ]
  }
]
        ";
    }
}
Error while compiling: HealthBar.cs(65,31): error CS0038: Cannot access a nonstatic member of outer type `Oxide.Plugins.HealthBar' via nested type `Oxide.Plugins.HealthBar.GuiControl'
 
C#:
using System.Collections.Generic;
using Oxide.Game.Rust.Cui;

namespace Oxide.Plugins
{
    [Info ("Health Bar", "Raskolov", "0.1.0")]

    class HealthBar : RustPlugin
    {

        public class GuiControl
        {
            private Dictionary<BasePlayer, Timer> _Timers = new Dictionary<BasePlayer, Timer>();

            private readonly PluginTimers _Timer;
            private readonly float destroySeconds;

            public GuiControl(PluginTimers timer, float destroySeconds)
            {
                this._Timer = timer;
                this._DestroySeconds = destroySeconds;
            }

            public void TriggerDamage(BasePlayer player, float health, float maxHelth)
            {
                RemovePlayer(player);
                var progressText = health / maxHelth + "";
                var healthText = (int)health + "";
                DrawUI(player, progressText, healthText);
                AddPlayer(player);
            }

            public void TriggerDeath(BasePlayer player)
            {
                RemovePlayer(player);
                var progressText = "0";
                var healthText = "Убит!";
                DrawUI(player, progressText, healthText);
                AddPlayer(player);
            }

            void AddPlayer(BasePlayer player)
            {
                _Timers[player] = _Timer.Once(_DestroySeconds, () =>
                {
                    RemovePlayer(player);
                });
            }

            void RemovePlayer(BasePlayer player)
            {
                Timer pTimer;
                if (_Timers.TryGetValue(player, out pTimer))
                {
                    _Timer.Destroy(ref pTimer);
                    DestroyUI(player);
                    _Timers.Remove(player);
                }
            }

            void DrawUI (BasePlayer player, string progress, string text)
            {
                string json = CUI_MAIN
                    .Replace("{progress}", progress)
                    .Replace("{text}", text);
                CuiHelper.AddUi(player, json);
            }

            void DestroyUI(BasePlayer player)
            {
                CuiHelper.DestroyUi(player, "hpbar_background");
            }
        }

        GuiControl _GuiControl;

        void Loaded()
        {
            _GuiControl = new GuiControl(timer, 5f);
        }

        void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info)
        {
           var player = info.InitiatorPlayer;
           if (player && player.IsAlive())
           {
               NextTick(() =>
               {
                   if (entity.IsAlive() && player?.IsConnected == true)
                   {
                      var health = entity.health;
                      var maxHelth = entity.MaxHealth();

                      _GuiControl.TriggerDamage(player, health, maxHelth);
                   }
               });
           }
        }

        void OnEntityDeath(BaseCombatEntity entity, HitInfo info)
        {
           var player = info.InitiatorPlayer;
           if (player && player.IsAlive())
           {
              _GuiControl.TriggerDeath(player);
           }
        }

        [ChatCommand("gui")]
        void cmdChatGui(BasePlayer player)
        {
            string json = CUI_MAIN
                .Replace("{progress}", "0.5")
                .Replace("{text}", "50");

            CuiHelper.AddUi(player, json);
            timer.Once(5f, () =>
            {
                CuiHelper.DestroyUi(player, "hpbar_background");
            });
        }

        string CUI_MAIN = @"
            [
  {
    ""name"": ""hpbar_background"",
    ""parent"": ""Overlay"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""material"": """",
        ""color"": ""0.5254902 0.5254902 0.5254902 0.2980392""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0.5 0"",
        ""anchormax"": ""0.5 0"",
        ""offsetmin"": ""-106 86"",
        ""offsetmax"": ""86 112""
      }
    ]
  },
  {
    ""name"": ""hpbar_img"",
    ""parent"": ""hpbar_background"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""sprite"": ""assets/icons/health.png"",
        ""material"": ""assets/icons/iconmaterial.mat"",
        ""color"": ""0.9686275 0.9176471 0.8784314 0.6745098""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""0 1"",
        ""offsetmin"": ""4 4"",
        ""offsetmax"": ""22 -4""
      }
    ]
  },
  {
    ""name"": ""hpbar_wrapper"",
    ""parent"": ""hpbar_background"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""material"": """",
        ""color"": ""1 0.4039216 0.4039216 0""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""1 1"",
        ""offsetmin"": ""25 3"",
        ""offsetmax"": ""-3 -3""
      }
    ]
  },
  {
    ""name"": ""hpbar_progress"",
    ""parent"": ""hpbar_wrapper"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""sprite"": ""assets/content/ui/ui.background.tile.psd"",
        ""material"": """",
        ""color"": ""0.6941177 0.2039216 0.003921569 0.5450981""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""{progress} 1"",
        ""offsetmin"": ""0 0"",
        ""offsetmax"": ""0 0""
      }
    ]
  },
  {
    ""name"": ""hpbar_text"",
    ""parent"": ""hpbar_wrapper"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Text"",
        ""text"": ""{text}"",
        ""fontSize"": 15,
        ""font"": ""robotocondensed-bold.ttf"",
        ""align"": ""MiddleLeft"",
        ""color"": ""0.9686275 0.9176471 0.8784314 0.8945568""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""1 1"",
        ""offsetmin"": ""2 0"",
        ""offsetmax"": ""0 0""
      }
    ]
  }
]
        ";
    }
}
Error while compiling: HealthBar.cs(65,31): error CS0038: Cannot access a nonstatic member of outer type `Oxide.Plugins.HealthBar' via nested type `Oxide.Plugins.HealthBar.GuiControl'
Ошибка заключается в том, что вы пытаетесь использовать переменную timer, которая не определена внутри класса HealthBar. Вместо этого вы должны использовать переменную timer, которая уже объявлена в методе Loaded():

Код:
void Loaded()
{
    _GuiControl = new GuiControl(timer, 5f);
}

Измените эту строку на _GuiControl = new GuiControl(this.timer, 5f);:

Код:
void Loaded()
{
    _GuiControl = new GuiControl(this.timer, 5f);
}

Теперь код должен быть успешно скомпилирован.
 
Ошибка заключается в том, что вы пытаетесь использовать переменную timer, которая не определена внутри класса HealthBar. Вместо этого вы должны использовать переменную timer, которая уже объявлена в методе Loaded():

Код:
void Loaded()
{
    _GuiControl = new GuiControl(timer, 5f);
}

Измените эту строку на _GuiControl = new GuiControl(this.timer, 5f);:

Код:
void Loaded()
{
    _GuiControl = new GuiControl(this.timer, 5f);
}

Теперь код должен быть успешно скомпилирован.

C#:
using System.Collections.Generic;
using Oxide.Game.Rust.Cui;

namespace Oxide.Plugins
{
    [Info ("Health Bar", "Raskolov", "0.1.0")]

    class HealthBar : RustPlugin
    {

        public class GuiControl
        {
            private Dictionary<BasePlayer, Timer> _Timers = new Dictionary<BasePlayer, Timer>();

            private readonly PluginTimers _Timer;
            private readonly float destroySeconds;

            public GuiControl(PluginTimers timer, float destroySeconds)
            {
                this._Timer = timer;
                this._DestroySeconds = destroySeconds;
            }

            public void TriggerDamage(BasePlayer player, float health, float maxHelth)
            {
                RemovePlayer(player);
                var progressText = health / maxHelth + "";
                var healthText = (int)health + "";
                DrawUI(player, progressText, healthText);
                AddPlayer(player);
            }

            public void TriggerDeath(BasePlayer player)
            {
                RemovePlayer(player);
                var progressText = "0";
                var healthText = "Убит!";
                DrawUI(player, progressText, healthText);
                AddPlayer(player);
            }

            void AddPlayer(BasePlayer player)
            {
                _Timers[player] = _Timer.Once(_DestroySeconds, () =>
                {
                    RemovePlayer(player);
                });
            }

            void RemovePlayer(BasePlayer player)
            {
                Timer pTimer;
                if (_Timers.TryGetValue(player, out pTimer))
                {
                    _Timer.Destroy(ref pTimer);
                    DestroyUI(player);
                    _Timers.Remove(player);
                }
            }

            void DrawUI (BasePlayer player, string progress, string text)
            {
                string json = CUI_MAIN
                    .Replace("{progress}", progress)
                    .Replace("{text}", text);
                CuiHelper.AddUi(player, json);
            }

            void DestroyUI(BasePlayer player)
            {
                CuiHelper.DestroyUi(player, "hpbar_background");
            }
        }

        GuiControl _GuiControl;

        void Loaded()
        {
            _GuiControl = new GuiControl(this.timer, 5f);
        }

        void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info)
        {
           var player = info.InitiatorPlayer;
           if (player && player.IsAlive())
           {
               NextTick(() =>
               {
                   if (entity.IsAlive() && player?.IsConnected == true)
                   {
                      var health = entity.health;
                      var maxHelth = entity.MaxHealth();

                      _GuiControl.TriggerDamage(player, health, maxHelth);
                   }
               });
           }
        }

        void OnEntityDeath(BaseCombatEntity entity, HitInfo info)
        {
           var player = info.InitiatorPlayer;
           if (player && player.IsAlive())
           {
              _GuiControl.TriggerDeath(player);
           }
        }

        [ChatCommand("gui")]
        void cmdChatGui(BasePlayer player)
        {
            string json = CUI_MAIN
                .Replace("{progress}", "0.5")
                .Replace("{text}", "50");

            CuiHelper.AddUi(player, json);
            timer.Once(5f, () =>
            {
                CuiHelper.DestroyUi(player, "hpbar_background");
            });
        }

        string CUI_MAIN = @"
            [
  {
    ""name"": ""hpbar_background"",
    ""parent"": ""Overlay"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""material"": """",
        ""color"": ""0.5254902 0.5254902 0.5254902 0.2980392""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0.5 0"",
        ""anchormax"": ""0.5 0"",
        ""offsetmin"": ""-106 86"",
        ""offsetmax"": ""86 112""
      }
    ]
  },
  {
    ""name"": ""hpbar_img"",
    ""parent"": ""hpbar_background"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""sprite"": ""assets/icons/health.png"",
        ""material"": ""assets/icons/iconmaterial.mat"",
        ""color"": ""0.9686275 0.9176471 0.8784314 0.6745098""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""0 1"",
        ""offsetmin"": ""4 4"",
        ""offsetmax"": ""22 -4""
      }
    ]
  },
  {
    ""name"": ""hpbar_wrapper"",
    ""parent"": ""hpbar_background"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""material"": """",
        ""color"": ""1 0.4039216 0.4039216 0""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""1 1"",
        ""offsetmin"": ""25 3"",
        ""offsetmax"": ""-3 -3""
      }
    ]
  },
  {
    ""name"": ""hpbar_progress"",
    ""parent"": ""hpbar_wrapper"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""sprite"": ""assets/content/ui/ui.background.tile.psd"",
        ""material"": """",
        ""color"": ""0.6941177 0.2039216 0.003921569 0.5450981""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""{progress} 1"",
        ""offsetmin"": ""0 0"",
        ""offsetmax"": ""0 0""
      }
    ]
  },
  {
    ""name"": ""hpbar_text"",
    ""parent"": ""hpbar_wrapper"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Text"",
        ""text"": ""{text}"",
        ""fontSize"": 15,
        ""font"": ""robotocondensed-bold.ttf"",
        ""align"": ""MiddleLeft"",
        ""color"": ""0.9686275 0.9176471 0.8784314 0.8945568""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""1 1"",
        ""offsetmin"": ""2 0"",
        ""offsetmax"": ""0 0""
      }
    ]
  }
]
        ";
    }
}
Error while compiling: HealthBar.cs(65,31): error CS0038: Cannot access a nonstatic member of outer type `Oxide.Plugins.HealthBar' via nested type `Oxide.Plugins.HealthBar.GuiControl'
 
C#:
using System.Collections.Generic;
using Oxide.Game.Rust.Cui;

namespace Oxide.Plugins
{
    [Info ("Health Bar", "Raskolov", "0.1.0")]

    class HealthBar : RustPlugin
    {

        public class GuiControl
        {
            private Dictionary<BasePlayer, Timer> _Timers = new Dictionary<BasePlayer, Timer>();

            private readonly PluginTimers _Timer;
            private readonly float destroySeconds;

            public GuiControl(PluginTimers timer, float destroySeconds)
            {
                this._Timer = timer;
                this._DestroySeconds = destroySeconds;
            }

            public void TriggerDamage(BasePlayer player, float health, float maxHelth)
            {
                RemovePlayer(player);
                var progressText = health / maxHelth + "";
                var healthText = (int)health + "";
                DrawUI(player, progressText, healthText);
                AddPlayer(player);
            }

            public void TriggerDeath(BasePlayer player)
            {
                RemovePlayer(player);
                var progressText = "0";
                var healthText = "Убит!";
                DrawUI(player, progressText, healthText);
                AddPlayer(player);
            }

            void AddPlayer(BasePlayer player)
            {
                _Timers[player] = _Timer.Once(_DestroySeconds, () =>
                {
                    RemovePlayer(player);
                });
            }

            void RemovePlayer(BasePlayer player)
            {
                Timer pTimer;
                if (_Timers.TryGetValue(player, out pTimer))
                {
                    _Timer.Destroy(ref pTimer);
                    DestroyUI(player);
                    _Timers.Remove(player);
                }
            }

            void DrawUI (BasePlayer player, string progress, string text)
            {
                string json = CUI_MAIN
                    .Replace("{progress}", progress)
                    .Replace("{text}", text);
                CuiHelper.AddUi(player, json);
            }

            void DestroyUI(BasePlayer player)
            {
                CuiHelper.DestroyUi(player, "hpbar_background");
            }
        }

        GuiControl _GuiControl;

        void Loaded()
        {
            _GuiControl = new GuiControl(this.timer, 5f);
        }

        void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info)
        {
           var player = info.InitiatorPlayer;
           if (player && player.IsAlive())
           {
               NextTick(() =>
               {
                   if (entity.IsAlive() && player?.IsConnected == true)
                   {
                      var health = entity.health;
                      var maxHelth = entity.MaxHealth();

                      _GuiControl.TriggerDamage(player, health, maxHelth);
                   }
               });
           }
        }

        void OnEntityDeath(BaseCombatEntity entity, HitInfo info)
        {
           var player = info.InitiatorPlayer;
           if (player && player.IsAlive())
           {
              _GuiControl.TriggerDeath(player);
           }
        }

        [ChatCommand("gui")]
        void cmdChatGui(BasePlayer player)
        {
            string json = CUI_MAIN
                .Replace("{progress}", "0.5")
                .Replace("{text}", "50");

            CuiHelper.AddUi(player, json);
            timer.Once(5f, () =>
            {
                CuiHelper.DestroyUi(player, "hpbar_background");
            });
        }

        string CUI_MAIN = @"
            [
  {
    ""name"": ""hpbar_background"",
    ""parent"": ""Overlay"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""material"": """",
        ""color"": ""0.5254902 0.5254902 0.5254902 0.2980392""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0.5 0"",
        ""anchormax"": ""0.5 0"",
        ""offsetmin"": ""-106 86"",
        ""offsetmax"": ""86 112""
      }
    ]
  },
  {
    ""name"": ""hpbar_img"",
    ""parent"": ""hpbar_background"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""sprite"": ""assets/icons/health.png"",
        ""material"": ""assets/icons/iconmaterial.mat"",
        ""color"": ""0.9686275 0.9176471 0.8784314 0.6745098""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""0 1"",
        ""offsetmin"": ""4 4"",
        ""offsetmax"": ""22 -4""
      }
    ]
  },
  {
    ""name"": ""hpbar_wrapper"",
    ""parent"": ""hpbar_background"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""material"": """",
        ""color"": ""1 0.4039216 0.4039216 0""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""1 1"",
        ""offsetmin"": ""25 3"",
        ""offsetmax"": ""-3 -3""
      }
    ]
  },
  {
    ""name"": ""hpbar_progress"",
    ""parent"": ""hpbar_wrapper"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Image"",
        ""sprite"": ""assets/content/ui/ui.background.tile.psd"",
        ""material"": """",
        ""color"": ""0.6941177 0.2039216 0.003921569 0.5450981""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""{progress} 1"",
        ""offsetmin"": ""0 0"",
        ""offsetmax"": ""0 0""
      }
    ]
  },
  {
    ""name"": ""hpbar_text"",
    ""parent"": ""hpbar_wrapper"",
    ""components"": [
      {
        ""type"": ""UnityEngine.UI.Text"",
        ""text"": ""{text}"",
        ""fontSize"": 15,
        ""font"": ""robotocondensed-bold.ttf"",
        ""align"": ""MiddleLeft"",
        ""color"": ""0.9686275 0.9176471 0.8784314 0.8945568""
      },
      {
        ""type"": ""RectTransform"",
        ""anchormin"": ""0 0"",
        ""anchormax"": ""1 1"",
        ""offsetmin"": ""2 0"",
        ""offsetmax"": ""0 0""
      }
    ]
  }
]
        ";
    }
}
Error while compiling: HealthBar.cs(65,31): error CS0038: Cannot access a nonstatic member of outer type `Oxide.Plugins.HealthBar' via nested type `Oxide.Plugins.HealthBar.GuiControl'
Ошибка заключается в том, что вы используете переменную this.timer, которая не определена в классе HealthBar. В классе HealthBar нет такой переменной, но есть переменная timer, объявленная в базовом классе RustPlugin.

Измените эту строку на RustPlugin.timer:

Код:
void Loaded()
{
    _GuiControl = new GuiControl(RustPlugin.timer, 5f);
}

Теперь код должен быть успешно скомпилирован.
 
Активность
Пока никто не печатает сообщение

Похожие темы