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

FREE POPCheck : 1.0.1 1.0.1

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

namespace Oxide.Plugins
{
    [Info("POPCheck", "Miho", "1.0.1")]
    [Description("A plugin that shows POP when /pop, !pop is entered")]
    public class POPCheck : RustPlugin
    {
        private Configuration _configuration;

        private class Configuration
        {
            [JsonProperty(PropertyName = "Server Message")]
            public string Serversay = "Server";

            [JsonProperty(PropertyName = "Color")]
            public string Color = "FF5733";

            [JsonProperty(PropertyName = "Steam Avatar User ID")]
            public ulong SteamIdIcon = 0;

            [JsonProperty(PropertyName = "Public")]
            public bool Public = true;

            public static Configuration DefaultConfig()
            {
                return new Configuration
                {
                    Serversay = "Server",
                    Color = "FF5733",
                    SteamIdIcon = 0,
                    Public = true
                };
            }
        }

        protected override void LoadDefaultConfig()
        {
            _configuration = Configuration.DefaultConfig();
            SaveConfig();
        }

        protected override void LoadConfig()
        {
            base.LoadConfig();
            _configuration = Config.ReadObject<Configuration>();
        }

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

        void OnPlayerChat(BasePlayer player, string message)
        {
            if (message.StartsWith("!pop"))
            {
                SendMessage(player);
            }
        }

        [ChatCommand("pop")]
        private void SendResult(BasePlayer player)
        {
            SendMessage(player);
        }

        private void SendMessage(BasePlayer player)
        {
            var max = ConVar.Server.maxplayers;
            var online = BasePlayer.activePlayerList.Count;
            var queue = ServerMgr.Instance.connectionQueue;
            var joining = queue.joining.Count;
            var queued = queue.queue.Count;
            string say = $"<color=#{_configuration.Color}>{_configuration.Serversay}</color>";
            ulong steamIdIcon = _configuration.SteamIdIcon;

            StringBuilder message = new StringBuilder($"There are {online}/{max} players playing");

            if (queued != 0)
            {
                message.Append($" and {queued} players in queue");
            }
            else if (joining != 0)
            {
                message.Append($" and joining {joining} players");
            }

            message.Append(" in the server.");

            NextFrame(() =>
            {
                if (_configuration.Public)
                {
                    Server.Broadcast(message.ToString(), say, steamIdIcon);
                }
                else
                {
                    Player.Message(player, message.ToString(), say, steamIdIcon);
                }
            });
        }
    }
}

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