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

FREE WData : 0.0.1 0.0.1

Нет прав для скачивания
C#:
using Newtonsoft.Json;
using Oxide.Core;
using Oxide.Core.Configuration;
using Oxide.Core.Database;
using Oxide.Core.Libraries.Covalence;
using Oxide.Core.Plugins;
using System;
using System.Collections.Generic;
using System.Linq;
using Oxide.Core.SQLite.Libraries;
using System.Text.RegularExpressions;
using UnityEngine;
using Oxide.Game.Rust.Cui;
using System.Collections;
using Newtonsoft.Json.Linq;

namespace Oxide.Plugins
{
	[Info("Player Data", "WOLF#4002", "0.0.1")]
    class WData : RustPlugin
	{
		/*void OnNewSave()
        {
            timer.In(60, () => 
            {
                PrintWarning("Обнаружен вайп, очистка даты!");

                foreach (var check in PlayerData)
                {
                    check.Value.Points = 0;
                    check.Value.KDR = new Dictionary<string, int>()
                    {
                        ["Kill"] = 0,
                        ["Death"] = 0,
                        ["Time"] = 0
                    };
                    check.Value.Res = new Dictionary<string, int>()
                    {
                        ["wood"] = 0,
                        ["stones"] = 0,
                        ["metal.ore"] = 0,
                        ["sulfur.ore"] = 0,
                        ["hq.metal.ore"] = 0,
                        ["cloth"] = 0,
                        ["leather"] = 0,
                        ["fat.animal"] = 0,
                        ["cratecostume"] = 0
                    };
                }
                
            });
        }*/
		[PluginReference] Plugin ImageLibrary;
		private void Init()
        {
            foreach (var check in PlayerData)
			{
				SteamAvatarAdd($"{check}"); 
			}
			
        }
		void OnServerInitialized()
		{
			if (Interface.Oxide.DataFileSystem.ExistsDatafile($"{Name}/{Title}"))
                PlayerData = Oxide.Core.Interface.Oxide.DataFileSystem.ReadObject<Dictionary<ulong, PlayerInfo>>($"{Name}/{Title}");
			foreach (BasePlayer player in BasePlayer.activePlayerList)
            {
				OnPlayerConnected(player);
			    				
			}
			timer.Every(60f, PlayTime);
			foreach (var check in ResImage)
                ImageLibrary.Call("AddImage", $"https://rustplugins.top/api/rust/{check}.png", check);
			ImageLibrary.Call("AddImage", "https://rustplugins.top/api/image/menu/kit.png", "kitx");	
			ImageLibrary.Call("AddImage", "https://rustplugins.top/api/image/menu/Report.png", "report");
		}
		List<string> ResImage = new List<string>()
        {
            "wood",
            "stones",
            "metal.ore",
            "sulfur.ore",
            "hq.metal.ore",
            "cloth",
            "leather",
            "fat.animal",
            "cratecostume"
        };
		void OnPlayerConnected(BasePlayer player)
		{
			var IPa = ParseIp(player.net.connection.ipaddress);
			SteamAvatarAdd(player.UserIDString);
			if (!PlayerData.ContainsKey(player.userID))
			{
				PlayerInfo NewUser = new PlayerInfo()
                {
                    DisplayName = player.displayName,
					SteamID = player.userID,
                    IP = new List<string>(), 
					Rates = Settings.Rates,
                };
				PlayerData.Add(player.userID, NewUser);
				Oxide.Core.Interface.Oxide.DataFileSystem.WriteObject($"{Name}/{Title}", PlayerData);
				 
				UI(player);
			} 
			var User = PlayerData[player.userID];
			if (!User.IP.Contains(IPa))
                    User.IP.Add(IPa); 
            Oxide.Core.Interface.Oxide.DataFileSystem.WriteObject($"{Name}/{Title}", PlayerData);				
		}
		void OnServerSave()
        {
            Oxide.Core.Interface.Oxide.DataFileSystem.WriteObject($"{Name}/{Title}", PlayerData);
			
        }
		void SteamAvatarAdd(string userid)
        {
            string url = $"http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=" + Settings.SteamAPIKey + "&steamids=" + userid;
            webrequest.Enqueue(url, null, (code, response) =>
            {
                if (code == 200)
                {
                    string Avatar = (string)JObject.Parse(response)["response"]?["players"]?[0]?["avatarfull"];
                    ImageLibrary.Call("AddImage", Avatar, userid);
					
                }
            }, this);
        }
		private static string ParseIp(string input)
        {
            if (input.Contains(":"))
                return input.Split(':')[0];

            return input;
        }
		
		private Dictionary<ulong, PlayerInfo> PlayerData = new Dictionary<ulong, PlayerInfo>();

        private class PlayerInfo
        {
			[JsonProperty("Name")]
            public string DisplayName;
			[JsonProperty("SteamID")]
            public ulong SteamID;
            [JsonProperty("IP")]
            public List<string> IP;
			[JsonProperty("Game Points")]
            public float Points;
			[JsonProperty("Rates")]
            public float Rates;
			[JsonProperty("Gold")]
            public float Gold;
			[JsonProperty("Silver")]
            public float Silver;
			public Dictionary<string, int> KDR = new Dictionary<string, int>()
            {
                ["Kill"] = 0,
                ["Death"] = 0,
                ["Time"] = 0
            };
            public Dictionary<string, int> Res = new Dictionary<string, int>()
            {
                ["wood"] = 0,
                ["stones"] = 0,
                ["metal.ore"] = 0,
                ["sulfur.ore"] = 0,
                ["hq.metal.ore"] = 0,
                ["cloth"] = 0,
                ["leather"] = 0,
                ["fat.animal"] = 0,
                ["cratecostume"] = 0
            };
            
        }
		
		void PlayTime()
        {
            foreach (var check in BasePlayer.activePlayerList)
			{
                PlayerData[check.userID].KDR["Time"] += 1;
				PlayerData[check.userID].Points += Settings.kdr.Time;
				PlayerData[check.userID].Silver += 0.001f;
			}
			OnServerSave();
        }
		
		
		
		
		[ChatCommand("test")]
		void AdminCommands(BasePlayer player, string command, string[] args)
		{
			ADDGold(player, 1.224f);
			ADDRate(player, 58.8f);
		}
		void ADDGold(BasePlayer player, float amount)
		{
			var data = PlayerData[player.userID];
            data.Gold = (data.Gold += amount);
            OnServerSave();			
		}
		void TAKEGold(BasePlayer player, float amount)
		{
			var data = PlayerData[player.userID];
			data.Gold = (data.Gold -= amount);
            OnServerSave();
		}
		double FINDGold(BasePlayer player)
		{
			var data = PlayerData[player.userID];
			return data.Gold; 
		}
		
		
		void ADDSilver(BasePlayer player, float amount)
		{
			var data = PlayerData[player.userID];
			data.Silver = (data.Silver += amount);
            OnServerSave();
		}
		void TAKESilver(BasePlayer player, float amount)
		{
			var data = PlayerData[player.userID];
			data.Silver = (data.Silver -= amount);
			OnServerSave();
		}
		double FINDSilver(BasePlayer player)
		{
			var data = PlayerData[player.userID];
			return data.Silver; 
		}
		
		
		void ADDPoint(BasePlayer player, float amount)
		{
			var data = PlayerData[player.userID];
			data.Points = (data.Points += amount);
			OnServerSave();
		}
		void TAKEPoint(BasePlayer player, float amount)
		{
			var data = PlayerData[player.userID];
			data.Points = (data.Points -= amount);
			OnServerSave();
		}
		double FINDPoint(BasePlayer player)
		{
			var data = PlayerData[player.userID];
			return data.Points; 
		}
		
		
		void ADDRate(BasePlayer player, float amount)
		{
			var data = PlayerData[player.userID];
			data.Rates = (data.Rates += amount);
			OnServerSave();
		}
		void TAKERate(BasePlayer player, float amount)
		{
			var data = PlayerData[player.userID];
			data.Rates = (data.Rates -= amount);
			OnServerSave();
		}
		double FINDRate(BasePlayer player)
		{
			var data = PlayerData[player.userID];
			return data.Rates; 
		}
		
		
		
		
		
		
		
		private class KDR
        {
			[JsonProperty("Points Kill++")]
            public int Kill;
			[JsonProperty("Points Death--")]
            public int Death;
			[JsonProperty("Points Game Time++")]
            public int Time;
			[JsonProperty("Points Kill Bradley++")]
			public int Bradley;
			[JsonProperty("Points Kill Helicopter++")]
			public int Helicopter;
        }
		private class RES
        {
			[JsonProperty("Points Farm++")]
            public int Farm;
			
        }
		private class Configuration  
        {
			public bool Wipe;
			public float Rates;
			[JsonProperty(PropertyName = "Steam API key (get one here https://steamcommunity.com/dev/apikey)")]
            public string SteamAPIKey { get; set; }
			[JsonProperty("K.D.T Points")]
            public KDR kdr = new KDR();
			[JsonProperty("Points Farm")]
            public RES res = new RES();
			
			
			public static Configuration Generate() 
            {
               return new Configuration
                {
					Wipe = true,
					Rates = 2.0f,
					SteamAPIKey = "",
					kdr = new KDR 
                    {
                        Kill = 5,
						Death= 20,
						Time = 1,
						Bradley = 150,
						Helicopter = 200,
                    },
					res = new RES  
                    {
                        Farm = 1,
					},
                };
            }
        }
		private static Configuration Settings;
		
		protected override void LoadConfig() 
        {
            base.LoadConfig();
            try
            {
                Settings = Config.ReadObject<Configuration>();
            }
            catch
            {
                PrintWarning($"Error reading config, creating one new config!");
                LoadDefaultConfig();
            }

            SaveConfig();
        }

        protected override void LoadDefaultConfig() => Settings = Configuration.Generate();
        protected override void SaveConfig()        => Config.WriteObject(Settings);
		
		
		
		
		
		
		
		
		
		void OnDispenserGather(ResourceDispenser dispenser, BasePlayer player, Item item)
        {
			var data = PlayerData[player.userID];
			
            if (dispenser == null || player == null || item == null) return;
            if (PlayerData[player.userID].Res.ContainsKey(item.info.shortname))
            {
                PlayerData[player.userID].Res[item.info.shortname] += (int)item.amount;
                return;
            }
        }

        void OnDispenserBonus(ResourceDispenser dispenser, BasePlayer player, Item item)
        {
			var data = PlayerData[player.userID];
            if (dispenser == null || player == null || item == null) return;
            if (PlayerData[player.userID].Res.ContainsKey(item.info.shortname))
            {
                PlayerData[player.userID].Res[item.info.shortname] += (int)item.amount;
                PlayerData[player.userID].Points += Settings.res.Farm;
                return;
            }
        }

        void OnCollectiblePickup(CollectibleEntity collectible, BasePlayer player)
        {
			var data = PlayerData[player.userID];
			 if (player == null)
                return;
            foreach (ItemAmount item in collectible.itemList)
			{
				if (PlayerData[player.userID].Res.ContainsKey(item.itemDef.shortname))
                {
                    PlayerData[player.userID].Res[item.itemDef.shortname] += (int)item.amount;
					PlayerData[player.userID].Points += Settings.res.Farm;
                    return;
                }
			}
			
        }

        void OnPlayerDeath(BasePlayer player, HitInfo info)
        {
            if (info == null || player == null || player.IsNpc || info.InitiatorPlayer == null || info.InitiatorPlayer.IsNpc) return;
            
            if (info.InitiatorPlayer != null)
            {
                var killer = info.InitiatorPlayer;

                if (killer != player) 
                { 
                    if (PlayerData.ContainsKey(killer.userID))
                    {
                        PlayerData[killer.userID].KDR["Kill"]++;
                        PlayerData[killer.userID].Points += Settings.kdr.Kill;
                    }
                }
                if (PlayerData.ContainsKey(player.userID))
                {
                    PlayerData[player.userID].KDR["Death"]++;
                    PlayerData[player.userID].Points -= Settings.kdr.Death;
                }
            }
        }

        public ulong lastDamageName;
        void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info)
        {
            if (entity is BradleyAPC && info.Initiator is BasePlayer)
                lastDamageName = info.Initiator.ToPlayer().userID;
            if (entity is BaseHelicopter && info.Initiator is BasePlayer)
                lastDamageName = info.Initiator.ToPlayer().userID;
        }

        void OnEntityDeath(BaseCombatEntity entity, HitInfo info)
        {
            if (entity == null || info == null) return;
            BasePlayer player = null;

            if (info.InitiatorPlayer != null) 
                player = info.InitiatorPlayer;

            if (player == null) return;
            
            if (entity is BradleyAPC)
            { 
                player = BasePlayer.FindByID(lastDamageName);
                PlayerData[player.userID].Points += Settings.kdr.Bradley;
            }

            if (entity is BaseHelicopter)
            { 
                player = BasePlayer.FindByID(lastDamageName);
                PlayerData[player.userID].Points += Settings.kdr.Helicopter;
            }

            if (entity.ShortPrefabName.Contains("barrel"))
            {
                PlayerData[player.userID].Res["cratecostume"]++;
                PlayerData[player.userID].Points += Settings.res.Farm;
            }
			
        }
		private static Dictionary<BasePlayer, List<UInt64>> LootersListCarte = new Dictionary<BasePlayer, List<UInt64>>();
		void OnLootEntity(BasePlayer player, BaseEntity entity)
		{
			 if (entity == null || player == null || entity.OwnerID.IsSteamId() || entity.net == null)
                return;
            if (!LootersListCarte.ContainsKey(player))
                LootersListCarte.Add(player, new List<UInt64> { });
            UInt64 netId = entity.net.ID.Value;
            if (LootersListCarte[player].Contains(netId))
                return;
            PlayerData[player.userID].Res["cratecostume"]++;
            PlayerData[player.userID].Points += Settings.res.Farm;
			
		}
		
		
		
		
		
		
		
		
		
		
		
		
		
		[ConsoleCommand("stats")]
        void ConsoleSkip(ConsoleSystem.Arg args)
        {
            var player = args.Player();

            if (player != null && args.HasArgs(1))
            {
                if (args.Args[0] == "profile")
                {
                    ProfileUI(player, ulong.Parse(args.Args[1]), int.Parse(args.Args[2]));
                }
                if (args.Args[0] == "back")
                {
                    StatsUI(player);
                }
                if (args.Args[0] == "skip")
                {
                    StatsUI(player, int.Parse(args.Args[1]));
                }
                /*if (args.Args[0] == "take")
                {
                    if (DB[player.userID].Balance == 0)
                    {
                        SendReply(player, "Вы бомж!");
                        return;
                    }
                    if (string.IsNullOrEmpty(config.Secret)) APIChangeUserBalance(player.userID, DB[player.userID].Balance);
                    else ApiChangeGameStoresBalance(player.userID, DB[player.userID].Balance);

                    SendReply(player, $"Вы успешно вывели {DB[player.userID].Balance} рублей, на игровой магазин!");
                    DB[player.userID].Balance -= DB[player.userID].Balance;
                    CuiHelper.DestroyUi(player, "MainStats");
                }*/
            }
        }
		
		[ChatCommand("top")]
        private void CmdStats(BasePlayer player, string command, string[] args)
		{
			StatsUI(player);
		}
		void StatsUI(BasePlayer player, int page = 0)
		{
			CuiHelper.DestroyUi(player, "Main");
            var container = new CuiElementContainer();

            container.Add(new CuiPanel
            {
                CursorEnabled = true,
                RectTransform = { AnchorMin = "0 0", AnchorMax = "1 1", OffsetMax = "0 0" },
                Image = { Color = "0 0 0 0" }
            }, "WOLF", "Main");
			container.Add(new CuiPanel
            {
                RectTransform = { AnchorMin = "0 0.23", AnchorMax = $"1 1", OffsetMax = "0 0" },
                Image = { Color = "1 1 1 0" }
            }, "Main", "Top");
			
			container.Add(new CuiElement 
            {
                
                Parent = "Top",
                Components =
                {
                    new CuiTextComponent {Text = $"          #               имя игрока                                                                                                         очки", Align = TextAnchor.MiddleLeft, FontSize = 15},
                    new CuiRectTransformComponent { AnchorMin = $"0.003 0.94", AnchorMax = $"1 1" },
                    new CuiOutlineComponent { Color = "0 0 0 1", Distance = "1 1" }
                }
            });
			container.Add(new CuiButton
            {
                RectTransform = { AnchorMin = $"0.523 0.02", AnchorMax = $"0.593 0.11", OffsetMax = "0 0" },
                Button = { Color = "0 0 0 0", Command = PlayerData.Count() > (page + 1) * 12 ? $"stats skip {page + 1}" : "" },
                Text = { Text = $">", Color = PlayerData.Count() > (page + 1) * 12 ? "1 1 1 1" : "1 1 1 0.5", Align = TextAnchor.MiddleCenter, FontSize = 12, Font = "robotocondensed-regular.ttf" }
            }, "Top");
			container.Add(new CuiButton
            {
                RectTransform = { AnchorMin = $"0.446 0.02", AnchorMax = $"0.516 0.11", OffsetMax = "0 0" },
                Button = { Color = "1 1 1 0", Command = "" },
                Text = { Text = $"{page + 1}", Color = "1 1 1 1", Align = TextAnchor.MiddleCenter, FontSize = 12, Font = "robotocondensed-regular.ttf" }
            }, "Top");

            container.Add(new CuiButton
            {
                RectTransform = { AnchorMin = $"0.37 0.02", AnchorMax = $"0.44 0.11", OffsetMax = "0 0" },
                Button = { Color = "0 0 0 0", Command = page >= 1 ? $"stats skip {page - 1}" : "" },
                Text = { Text = $"<", Color = page >= 1 ? "1 1 1 1" : "1 1 1 0.5", Align = TextAnchor.MiddleCenter, FontSize = 12, Font = "robotocondensed-regular.ttf" }
            }, "Top");
			
			 float width = 0.98f, height = 0.063f, startxBox = 0.01f, startyBox = 0.95f - height, xmin = startxBox, ymin = startyBox, z = 0;
			 var items = from item in PlayerData orderby item.Value.Points descending select item;
			 foreach (var check in items.Skip(page * 12).Take(12))
			 {
				  z++;
                container.Add(new CuiPanel
                {
                    RectTransform = { AnchorMin = $"{xmin} {ymin}", AnchorMax = $"{xmin + width} {ymin + height * 1}", OffsetMin = "2 1", OffsetMax = "-2 -1" },
                    Image = { Color = "0 0 0 0.2" }
                }, "Top", "PlayerTop");
				
				container.Add(new CuiElement 
                {
                    Parent = "PlayerTop",
                    Components =
                    {
                        new CuiTextComponent {Text = $"{z + page * 12}", Color = "1 1 1 0.8", Align = TextAnchor.MiddleCenter, FontSize = 14, Font = "robotocondensed-regular.ttf"},
                        new CuiRectTransformComponent { AnchorMin = $"0 0", AnchorMax = $"0.08 1" },
                        new CuiOutlineComponent { Color = "0 0 0 1", Distance = "1 1" }
                    }
                });
				container.Add(new CuiElement 
                {
                    Parent = "PlayerTop",
                    Components =
                    {
                        new CuiTextComponent {Text = $"{check.Value.DisplayName}", Color = "1 1 1 0.8", Align = TextAnchor.MiddleLeft, FontSize = 14, Font = "robotocondensed-regular.ttf"},
                        new CuiRectTransformComponent { AnchorMin = $"0.115 0", AnchorMax = $"0.4 1" },
                        new CuiOutlineComponent { Color = "0 0 0 1", Distance = "1 1" }
                    }
                });
				container.Add(new CuiElement 
                {
                    Parent = "PlayerTop",
                    Components =
                    {
                        new CuiTextComponent {Text = $"{check.Value.Points}", Color = "1 1 1 0.8", Align = TextAnchor.MiddleCenter, FontSize = 14, Font = "robotocondensed-regular.ttf"},
                        new CuiRectTransformComponent { AnchorMin = $"0.63 0", AnchorMax = $"0.75 1" },
                        new CuiOutlineComponent { Color = "0 0 0 1", Distance = "1 1" }
                    }
                });
				//container.Add(new CuiElement 
               // {
               //     Parent = "PlayerTop",
                //    Components =
                //    {
               //         new CuiTextComponent {Text = "fbgdf"/*$"{config.Bonus.ElementAt(x)}"*/, Color = "1 1 1 0.8", Align = TextAnchor.MiddleCenter, FontSize = 14, Font = "robotocondensed-regular.ttf"},
                //        new CuiRectTransformComponent { AnchorMin = $"0.46 0", AnchorMax = $"0.75 1" },
                //        new CuiOutlineComponent { Color = "0 0 0 1", Distance = "1 1" }
                //    }
                //});
				
				container.Add(new CuiElement 
                {
                    Parent = "PlayerTop",
                    Components =
                    {
                        new CuiTextComponent {Text = "ПРОФИЛЬ", Color = "1 1 1 0.8", Align = TextAnchor.MiddleCenter, FontSize = 14, Font = "robotocondensed-regular.ttf"},
                        new CuiRectTransformComponent { AnchorMin = $"0.805 0", AnchorMax = $"1 1" },
                        new CuiOutlineComponent { Color = "0 0 0 1", Distance = "1 1" }
                    }
                });
				container.Add(new CuiButton
                {
                    RectTransform = { AnchorMin = $"0.805 0", AnchorMax = $"1 1", OffsetMax = "0 0" },
                    Button = { Color = "1 1 1 0", Command = $"stats profile {check.Key} {z + page * 10}" },
                    Text = { Text = $"", Color = "1 1 1 1", Align = TextAnchor.MiddleCenter, FontSize = 12, Font = "robotocondensed-regular.ttf" }
                }, "PlayerTop");
				xmin += width;
                if (xmin + width >= 1)
                {
                    xmin = startxBox;
                    ymin -= height;
                }
			 }
			CuiHelper.AddUi(player, container);
		}
		
		void ProfileUI(BasePlayer player, ulong SteamID, int z)
		{
		    CuiHelper.DestroyUi(player, "Main");
            var container = new CuiElementContainer();

            container.Add(new CuiPanel
            {
                CursorEnabled = true,
                RectTransform = { AnchorMin = "0 0", AnchorMax = "1 1", OffsetMax = "0 0" },
                Image = { Color = "0 0 0 0" }
            }, "WOLF", "Main");
		    var target = PlayerData[SteamID];
			
			container.Add(new CuiElement 
            {
                
                Parent = "Main",
                Components =
                {
                    new CuiTextComponent {Text = $"<b><size=25>{target.DisplayName.ToUpper()}</size></b>\nЗдесь вы можете посмотреть подробно статискику об игроке!", Align = TextAnchor.MiddleCenter, FontSize = 12},
                    new CuiRectTransformComponent { AnchorMin = "0.01 0.8", AnchorMax = $"0.99 0.99" },
                    new CuiOutlineComponent { Color = "0 0 0 1", Distance = "1 1" }
                }
            });
			container.Add(new CuiButton
            {
                RectTransform = { AnchorMin = $"0.682 0.02", AnchorMax = $"0.83 0.11", OffsetMax = "0 0" },
                Button = { Color = "1 1 1 0.1", Command = "stats back" },
                Text = { Text = $"НАЗАД", Color = "1 1 1 1", Align = TextAnchor.MiddleCenter, FontSize = 12, Font = "robotocondensed-regular.ttf" }
            }, "Main");
			container.Add(new CuiPanel
            {
                RectTransform = { AnchorMin = $"0.015 0.51", AnchorMax = $"0.17 0.777", OffsetMax = "0 0" },
                Image = { Color = "1 1 1 0.1" }
            }, "Main", "Avatar");
			container.Add(new CuiElement
            {
                Parent = "Avatar",
                Components =
                {
                    new CuiRawImageComponent { Png = (string) ImageLibrary.Call("GetImage", SteamID.ToString()) },
                    new CuiRectTransformComponent { AnchorMin = "0 0", AnchorMax = "1 1" }
                }
            });
			container.Add(new CuiElement 
            {
                
                Parent = "Main",
                Components =
                {
                    new CuiTextComponent {Text = $"Место в топе: {z}", Align = TextAnchor.MiddleLeft, FontSize = 15},
                    new CuiRectTransformComponent { AnchorMin = $"0.22 0.7", AnchorMax = $"0.5 0.777" },
                    new CuiOutlineComponent { Color = "0 0 0 1", Distance = "1 1" }
                }
            });
			
			float width1 = 0.494f, height1 = 0.0939f, startxBox1 = 0.01f, startyBox1 = 0.5f - height1, xmin1 = startxBox1, ymin1 = startyBox1;
            foreach (var check in target.KDR)
			{
				container.Add(new CuiPanel
                {
                    RectTransform = { AnchorMin = $"{xmin1} {ymin1}", AnchorMax = $"{xmin1 + width1} {ymin1 + height1 * 1}", OffsetMin = "2 2", OffsetMax = "-2 -2" },
                    Image = { Color = "1 1 1 0.1" }
                }, "Main", "Count");
				container.Add(new CuiElement 
                {
                
                Parent = "Count",
                Components =
                {
                    new CuiTextComponent {Text = $"{check.Key.Replace("Kill", "УБИЙСТВ").Replace("Death", "СМЕРТЕЙ").Replace("Time", "АКТИВНОСТЬ")}", Align = TextAnchor.MiddleLeft, FontSize = 15},
                    new CuiRectTransformComponent { AnchorMin = $"0.03 0", AnchorMax = $"1 1" },
                    new CuiOutlineComponent { Color = "0 0 0 1", Distance = "1 1" }
                }
                });
				container.Add(new CuiElement 
                {
                
                Parent = "Count",
                Components =
                {
                    new CuiTextComponent {Text = $"{check.Value}", Align = TextAnchor.MiddleRight, FontSize = 15},
                    new CuiRectTransformComponent { AnchorMin = $"0 0", AnchorMax = $"0.97 1" },
                    new CuiOutlineComponent { Color = "0 0 0 1", Distance = "1 1" }
                }
                });
				xmin1 += width1;
                if (xmin1 + width1 >= 0)
                {
                    xmin1 = startxBox1;
                    ymin1 -= height1;
                }
			}
             container.Add(new CuiPanel
            {
                RectTransform = { AnchorMin = $"0.014 0.133", AnchorMax = $"0.5 0.213", OffsetMax = "0 0" },
                Image = { Color = "1 1 1 0.1" }
            }, "Main", "KD");

            

            var kd = target.KDR["Death"] == 0 ? target.KDR["Kill"] : (float)Math.Round(((float)target.KDR["Kill"]) / target.KDR["Death"], 1);
           
			
			container.Add(new CuiElement 
                {
                
                Parent = "KD",
                Components =
                {
                    new CuiTextComponent {Text = $"К/Д СТАТУС", Align = TextAnchor.MiddleLeft, FontSize = 15},
                    new CuiRectTransformComponent { AnchorMin = $"0.03 0", AnchorMax = $"1 1", OffsetMax = "0 0" },
                    new CuiOutlineComponent { Color = "0 0 0 1", Distance = "1 1" }
                }
                });
				container.Add(new CuiElement 
                {
                
                Parent = "KD",
                Components =
                {
                    new CuiTextComponent {Text = $"{kd}", Align = TextAnchor.MiddleRight, FontSize = 15},
                    new CuiRectTransformComponent { AnchorMin = $"0 0", AnchorMax = $"0.97 1" },
                    new CuiOutlineComponent { Color = "0 0 0 1", Distance = "1 1" }
                }
                });
			float width = 0.1f, height = 0.18f, startxBox = 0.523f, startyBox = 0.785f - height, xmin = startxBox, ymin = startyBox;
            foreach (var check in target.Res)
			{
				container.Add(new CuiPanel
                {
                    RectTransform = { AnchorMin = $"{xmin} {ymin}", AnchorMax = $"{xmin + width} {ymin + height * 1}", OffsetMin = "2 2", OffsetMax = "-2 -2" },
                    Image = { Color = "1 1 1 0.1" }
                }, "Main", "Images");
				container.Add(new CuiElement
                {
                    Parent = "Images",
                    Components =
                    {
                        new CuiRawImageComponent { Png = (string) ImageLibrary.Call("GetImage", check.Key) },
                        new CuiRectTransformComponent { AnchorMin = "0 0", AnchorMax = "1 1", OffsetMin = "5 5", OffsetMax = "-5 -5" }
                    }
                });
				container.Add(new CuiElement 
                {
                
                Parent = "Images",
                Components =
                {
                    new CuiTextComponent {Text = $"{check.Value}", Align = TextAnchor.LowerRight, FontSize = 15},
                    new CuiRectTransformComponent { AnchorMin = $"0 0", AnchorMax = $"0.97 1" },
                    new CuiOutlineComponent { Color = "0 0 0 1", Distance = "1 1" }
                }
                });
				
				
				 xmin += width;
                if (xmin + width >= 1)
                {
                    xmin = startxBox;
                    ymin -= height;
                }
			}
				
				
				
				
		    CuiHelper.AddUi(player, container);	
		}
		[ChatCommand("kit")]
        private void CmdChatStore(BasePlayer player, string command, string[] args)
		{
			UI(player);
		}
		
		private static string Ki = "UI_Kit";
		void UI(BasePlayer player, int page = 0)
		{
			CuiElementContainer container = new CuiElementContainer();
			CuiHelper.DestroyUi(player, Ki);
			container.Add(new CuiPanel
            {
                CursorEnabled = true,
                RectTransform = { AnchorMin = "0 0", AnchorMax = "1 1", OffsetMax = "0 0" },
                Image = { Color = "0 0 0 0" }
            }, "WOLF", Ki); 
			float width = 0.150f, height = 0.400f, startxBox = 0.123f, startyBox = 0.897f - height, xmin = startxBox, ymin = startyBox;
			var items = from item in PlayerData orderby item.Value.Points descending select item;
			foreach (var check in items.Skip(page * 10).Take(10))
			{
				container.Add(new CuiElement
                {
                    Parent = Ki,
					Name = "Images",
                    Components =
                    {
                        new CuiRawImageComponent { Png = (string) ImageLibrary.Call("GetImage", "kitx") },
                        new CuiRectTransformComponent { AnchorMin = $"{xmin} {ymin}", AnchorMax = $"{xmin + width} {ymin + height * 1}" }
                    }
                });
				
				xmin += width;
                if (xmin + width >= 1)
                {
                    xmin = startxBox;
                    ymin -= height;
                }
			}
			
			CuiHelper.AddUi(player, container);
			
		}
		/*[ChatCommand("report")]
        private void CmdChatStjore(BasePlayer player, string command, string[] args)
		{
			UIR(player);
		}
		[ConsoleCommand("report")]
        void ConsoleSkidp(ConsoleSystem.Arg args)
		{
			var player = args.Player();
			if (player != null && args.HasArgs(1))
			{
				if (args.Args[0] == "back")
                {
                    UIR(player);
                }
                if (args.Args[0] == "skip")
                {
                    UIR(player, int.Parse(args.Args[1]));
                }
				if (args.Args[0] == "profile")
                {
                    //Rep(player, ulong.Parse(args.Args[1]), int.Parse(args.Args[2]));
                }
			}
		}
		public string GetImage(string shortname, ulong skin = 0) => (string)ImageLibrary?.Call("GetImage", shortname, skin);
		private static string RE = "UI_re";
		void UIR(BasePlayer player, int page = 0)
		{
			CuiElementContainer container = new CuiElementContainer();
			CuiHelper.DestroyUi(player, RE);
			container.Add(new CuiPanel
            {
                CursorEnabled = true,
                RectTransform = { AnchorMin = "0 0", AnchorMax = "1 1", OffsetMax = "0 0" },
                Image = { Color = "0 0 0 0" }
            }, "WOLF", RE); 
			 container.Add(new CuiButton
            {
                RectTransform = { AnchorMin = $"0.523 0.02", AnchorMax = $"0.593 0.11", OffsetMax = "0 0" },
                Button = { Color = "0 0 0 0", Command = PlayerData.Count() > (page + 1) * 32 ? $"report skip {page + 1}" : "chat.say /jjj" },
                Text = { Text = $">", Color = PlayerData.Count() > (page + 1) * 32 ? "1 1 1 1" : "1 1 1 0.5", Align = TextAnchor.MiddleCenter, FontSize = 12, Font = "robotocondensed-regular.ttf" }
            }, RE);
			container.Add(new CuiButton
            {
                RectTransform = { AnchorMin = $"0.37 0.02", AnchorMax = $"0.44 0.11", OffsetMax = "0 0" },
                Button = { Color = "0 0 0 0", Command = page >= 1 ? $"report skip {page - 1}" : "chat.say /jjj" },
                Text = { Text = $"<", Color = page >= 1 ? "1 1 1 1" : "1 1 1 0.5", Align = TextAnchor.MiddleCenter, FontSize = 12, Font = "robotocondensed-regular.ttf" }
            }, RE);
			float width = 0.200f, height = 0.100f, startxBox = 0.100f, startyBox = 0.900f - height, xmin = startxBox, ymin = startyBox;
			var items = PlayerData;
			foreach (var check in items.Skip(page * 32).Take(32))
			{
				container.Add(new CuiElement
                {
                    Parent = RE,
					Name = "Imagesr",
                    Components =
                    {
                        new CuiRawImageComponent { Png = (string) ImageLibrary.Call("GetImage", "report") },
                        new CuiRectTransformComponent { AnchorMin = $"{xmin} {ymin}", AnchorMax = $"{xmin + width * 0.9f} {ymin + height * 0.9f}" }
                    }
                });
				
				string ImageAvatar = GetImage(check.Value.SteamID.ToString(), 0);
				 
                container.Add(new CuiElement
                {
                    Parent = $"Imagesr",
                    Components =
                    { 
                        new CuiRawImageComponent { Png = ImageAvatar },
                        new CuiRectTransformComponent{ AnchorMin = "0.02 0.05", AnchorMax = $"0.3 0.95"},
                    }
                });
				container.Add(new CuiElement 
                {
                    Parent = "Imagesr",
                    Components =
                    {
                        new CuiTextComponent {Text = $"{check.Value.DisplayName}\n{check.Value.SteamID}", Color = "0.72 0.83 0.71 1.00", Align = TextAnchor.MiddleLeft, FontSize = 11, Font = "robotocondensed-regular.ttf"},
                        new CuiRectTransformComponent { AnchorMin = $"0.3 0", AnchorMax = $"0.88 1" },
                        new CuiOutlineComponent { Color = "0.90 0.66 0.64 0.5", Distance = "0.1 0.1" }
                    }
                });
				
				xmin += width;
                if (xmin + width >= 1)
                {
                    xmin = startxBox;
                    ymin -= height;
                }
			}
			
			CuiHelper.AddUi(player, container);
		}*/
	}
}

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