using Newtonsoft.Json; using Oxide.Core; using Oxide.Core.Plugins; using Oxide.Game.Rust.Cui; using UnityEngine; using System; using System.Collections.Generic; using System.Linq; namespace Oxide.Plugins { [Info("Stats", "Frizen", "1.0.0")] public class Stats : RustPlugin { #region References [PluginReference] private Plugin ImageLibrary; #endregion #region Vars private Dictionary DB = new Dictionary(); #endregion #region Config private static Configuration _config; public class Configuration { [JsonProperty(PropertyName = "KillPoint")] public int KillPoint; [JsonProperty(PropertyName = "DeathPoint")] public int DeathPoint; [JsonProperty(PropertyName = "FarmPoint")] public int FarmPoint; [JsonProperty(PropertyName = "BradleyPoint")] public int BradleyPoint; [JsonProperty(PropertyName = "HeliPoint")] public int HeliPoint; public static Configuration DefaultConfig() { return new Configuration { KillPoint = 10, DeathPoint = 10, FarmPoint = 8, BradleyPoint = 750, HeliPoint = 1500, }; } } protected override void LoadConfig() { base.LoadConfig(); try { _config = Config.ReadObject(); if (_config == null) LoadDefaultConfig(); SaveConfig(); } catch (Exception e) { Debug.LogException(e); PrintWarning("Creating new config file."); LoadDefaultConfig(); } } protected override void LoadDefaultConfig() => _config = Configuration.DefaultConfig(); protected override void SaveConfig() => Config.WriteObject(_config); #endregion #region Helpers public string GetImage(string shortname, ulong skin = 0) => (string)ImageLibrary?.Call("GetImage", shortname, skin); private static string HexToRustFormat(string hex) { Color color; ColorUtility.TryParseHtmlString(hex, out color); return string.Format("{0:F2} {1:F2} {2:F2} {3:F2}", color.r, color.g, color.b, color.a); } void SaveDataBase() { Oxide.Core.Interface.Oxide.DataFileSystem.WriteObject("Stats/PlayerList", DB); } private static Dictionary itemNamesByShortname; public static string GetItemName(string shortname) { string itemName; if (itemNamesByShortname == null) { itemNamesByShortname = new Dictionary(); var items = ItemManager.GetItemDefinitions(); foreach (ItemDefinition item in items) { itemNamesByShortname[item.shortname] = item.displayName.english; } } if (itemNamesByShortname.TryGetValue(shortname, out itemName)) { return itemName; } else { return null; } } Int32 GetTopScore(ulong userid) { Int32 Top = 1; var RaitingNumber = from item in DB orderby item.Value.Points descending select item; foreach (var Data in RaitingNumber) { if (Data.Key == userid) break; Top++; } return Top; } #endregion #region Sub Class public class PlayerDB { public string DisplayName; public int Points = 0; public Dictionary Settings = new Dictionary() { ["Kill"] = 0, ["Death"] = 0 }; public Dictionary Res = new Dictionary() { ["stones"] = 0, ["wood"] = 0, ["metal.ore"] = 0, ["sulfur.ore"] = 0, ["hq.metal.ore"] = 0, ["cloth"] = 0, ["leather"] = 0, ["fat.animal"] = 0, ["scrap"] = 0 }; } #endregion #region Hooks private void OnServerInitialized() { ImageLibrary.Call("AddImage", "https://i.imgur.com/v4Ix05O.png", "Viniette"); if (Interface.Oxide.DataFileSystem.ExistsDatafile("Stats/PlayerList")) DB = Oxide.Core.Interface.Oxide.DataFileSystem.ReadObject>("Stats/PlayerList"); foreach (var check in BasePlayer.activePlayerList) OnPlayerConnected(check); } void OnPlayerConnected(BasePlayer player) { if (!DB.ContainsKey(player.userID)) DB.Add(player.userID, new PlayerDB()); DB[player.userID].DisplayName = player.displayName; } void OnPlayerDisconnected(BasePlayer player) { SaveDataBase(); } private void Unload() { SaveDataBase(); } void OnDispenserGather(ResourceDispenser dispenser, BasePlayer player, Item item) { if (dispenser == null || player == null || item == null) return; if (DB[player.userID].Res.ContainsKey(item.info.shortname)) { DB[player.userID].Res[item.info.shortname] += item.amount; return; } } void OnDispenserBonus(ResourceDispenser dispenser, BasePlayer player, Item item) { if (dispenser == null || player == null || item == null) return; if (DB[player.userID].Res.ContainsKey(item.info.shortname)) { DB[player.userID].Res[item.info.shortname] += item.amount; DB[player.userID].Points += _config.FarmPoint; return; } } void OnCollectiblePickup(Item item, BasePlayer player) { if (item == null || player == null) return; if (DB[player.userID].Res.ContainsKey(item.info.shortname)) { DB[player.userID].Res[item.info.shortname] += item.amount; return; } } private void OnEntityDeath(LootContainer entity, HitInfo info) { if (entity == null) return; if (info == null) return; if (!entity.ShortPrefabName.Contains("barrel")) return; if (info.InitiatorPlayer == null) return; var player = info.InitiatorPlayer; var scrap = entity.inventory.FindItemByItemName("scrap"); if (scrap != null) { if (DB[player.userID].Res.ContainsKey(scrap.info.shortname)) { DB[player.userID].Res[scrap.info.shortname] += scrap.amount; } } } 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 (DB.ContainsKey(killer.userID)) { DB[killer.userID].Settings["Kill"]++; DB[killer.userID].Points += _config.KillPoint; } } if (DB.ContainsKey(player.userID)) { DB[player.userID].Settings["Death"]++; DB[player.userID].Points -= _config.DeathPoint; } } } 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); DB[player.userID].Points += _config.BradleyPoint; } if (entity is BaseHelicopter) { player = BasePlayer.FindByID(lastDamageName); DB[player.userID].Points += _config.HeliPoint; } } void OnNewSave() { timer.In(60, () => { PrintWarning("Обнаружен вайп, происходит очистка даты!"); foreach (var check in DB) { check.Value.Points = 0; check.Value.Settings = new Dictionary() { ["Kill"] = 0, ["Death"] = 0 }; check.Value.Res = new Dictionary() { ["wood"] = 0, ["stones"] = 0, ["metal.ore"] = 0, ["sulfur.ore"] = 0, ["hq.metal.ore"] = 0, ["cloth"] = 0, ["leather"] = 0, ["fat.animal"] = 0, ["scrap"] = 0 }; } SaveDataBase(); }); } #endregion #region Commands [ChatCommand("stats")] private void ChatStats(BasePlayer player, string command, string[] args) { MainUI(player); } [ConsoleCommand("showstats")] private void TargetHandler(ConsoleSystem.Arg args) { if (args.Args.Length < 1) return; var player = args.Player(); var target = Convert.ToUInt64(args.Args[0]); TargetStats(player, target); } [ConsoleCommand("skipp")] private void PageHandler(ConsoleSystem.Arg args) { if (args.Args.Length < 2) return; var player = args.Player(); var page = Convert.ToInt32(args.Args[0]); var active = args.Args[1]; LoadedPlayers(player, page, active); } #endregion #region UI private void TargetStats(BasePlayer player, ulong targetID, string active = "mystats") { var container = new CuiElementContainer(); bool IsOnline = false; var target = BasePlayer.Find(targetID.ToString()); if (target != null && target.IsConnected) { IsOnline = true; } CuiHelper.DestroyUi(player, $"MyStatsBTN"); CuiHelper.DestroyUi(player, $"TopBTN"); CuiHelper.DestroyUi(player, $"Panel-selfTop"); CuiHelper.DestroyUi(player, $"Panel-self"); CuiHelper.DestroyUi(player, $"BTNprev"); CuiHelper.DestroyUi(player, $"BTNnext"); for (int i = 0; i < 10; i++) { CuiHelper.DestroyUi(player, $"Panel{i}"); CuiHelper.DestroyUi(player, $"PanelM{i}"); } for (int i = 0; i < 6; i++) { CuiHelper.DestroyUi(player, $"BTN{i}"); } var db = DB[targetID]; container.Add(new CuiButton { RectTransform = { AnchorMin = "-7.636845E-08 0.9272198", AnchorMax= "0.4910071 1.000324" }, Button = { Color = active == "mystats" ? $"{HexToRustFormat("#B6B6B680")}" : $"{HexToRustFormat("#B6B6B640")}", Command = $"skipp 0 mystats", }, Text = { Text = $"{db.DisplayName} stats", Color = active == "mystats" ? $"{HexToRustFormat("#464646CE")}" : $"1 1 1 0.8", Align = TextAnchor.MiddleCenter, FontSize = 12, Font = "robotocondensed-bold.ttf" } }, "Stats", "MyStatsBTN"); container.Add(new CuiButton { RectTransform = { AnchorMin = "0.5089937 0.9272198", AnchorMax= "1.000001 1.000324" }, Button = { Color = active == "top" ? $"{HexToRustFormat("#B6B6B680")}" : $"{HexToRustFormat("#B6B6B640")}", Command = $"skipp 0 top", }, Text = { Text = "Players top", Color = active == "top" ? $"{HexToRustFormat("#464646CE")}" : $"1 1 1 0.8", Align = TextAnchor.MiddleCenter, FontSize = 12, Font = "robotocondensed-bold.ttf" } }, "Stats", "TopBTN"); container.Add(new CuiPanel { RectTransform = { AnchorMin = $"-1.024455E-07 0.7976711", AnchorMax = $"0.08992793 0.8707748" }, Image = { Color = $"{HexToRustFormat("#B6B6B640")}", } }, "Stats", $"Panel-selfTop"); container.Add(new CuiPanel { RectTransform = { AnchorMin = $"0.1043165 0.7976711", AnchorMax = $"1 0.8707748" }, Image = { Color = $"{HexToRustFormat("#B6B6B640")}", } }, "Stats", $"Panel-self"); container.Add(new CuiElement { Parent = $"Panel-selfTop", Components = { new CuiTextComponent{Color = $"{HexToRustFormat("#E8E2D9E5")}", Text = $"{GetTopScore(targetID)}", Align = TextAnchor.MiddleCenter, FontSize = 12, Font = "robotocondensed-bold.ttf"}, new CuiRectTransformComponent{AnchorMin = "0 0", AnchorMax = "1 1"} } }); container.Add(new CuiPanel { RectTransform = { AnchorMin = "0 0", AnchorMax = "1 1", OffsetMin = "0 0", OffsetMax = "0 -0.2" }, Image = { Color = IsOnline ? $"{HexToRustFormat("#767E45A3")}" : $"{HexToRustFormat("#7E45456D")}" , Sprite = "assets/content/ui/ui.background.transparent.linearltr.tga", FadeIn = 1f } }, $"Panel-self") ; container.Add(new CuiElement { Parent = $"Panel-self", Components = { new CuiRawImageComponent{Color = "1 1 1 1", Png = GetImage(targetID.ToString(), 0)}, new CuiRectTransformComponent{AnchorMin = "0.01004001 0.09955752", AnchorMax = "0.0903613 0.8960171"} } }); container.Add(new CuiElement { Parent = $"Panel-self", Components = { new CuiTextComponent{Color = $"{HexToRustFormat("#E8E2D9E5")}", Text = $"{db.DisplayName}", Align = TextAnchor.MiddleLeft, FontSize = 11, Font = "robotocondensed-bold.ttf"}, new CuiRectTransformComponent{AnchorMin = "0.1044177 0.3713536", AnchorMax = "0.5461848 0.955752"} } }); container.Add(new CuiElement { Parent = $"Panel-self", Components = { new CuiTextComponent{Color = $"1 1 1 0.8", Text = $"{targetID}", Align = TextAnchor.MiddleLeft, FontSize = 10, Font = "robotocondensed-regular.ttf"}, new CuiRectTransformComponent{AnchorMin = "0.1044177 0.01294668", AnchorMax = "0.4056225 0.5973451"} } }); double kd; if (db.Settings["Death"] == 0) { kd = db.Settings["Kill"]; } else { kd = Math.Round(Convert.ToDouble(db.Settings["Kill"] / db.Settings["Death"]), 2); } container.Add(new CuiElement { Parent = $"Panel-self", Components = { new CuiTextComponent{Color = $"{HexToRustFormat("#E8E2D9FF")}", Text = $"{kd}", Align = TextAnchor.MiddleCenter, FontSize = 11, Font = "robotocondensed-bold.ttf"}, new CuiRectTransformComponent{AnchorMin = "0.7168675 0.238938", AnchorMax = "0.7831326 0.8362826"} } }); container.Add(new CuiElement { Parent = $"Panel-self", Components = { new CuiTextComponent{Color = $"1 1 1 1", Text = $"{db.Points}", Align = TextAnchor.MiddleCenter, FontSize = 11, Font = "robotocondensed-bold.ttf"}, new CuiRectTransformComponent{AnchorMin = "0.8895574 0.238938", AnchorMax = "0.9779108 0.8362827"} } }); double anchormin1 = 0.7176128, anchormax1 = 0.7907165; int w = 0; foreach (var item in db.Res) { CuiHelper.DestroyUi(player, $"Panel{w}"); container.Add(new CuiPanel { RectTransform = { AnchorMin = $"0.001798302 {anchormin1}", AnchorMax = $"1 {anchormax1}" }, Image = { Color = w % 2 == 0 ? $"{HexToRustFormat("#B6B6B62E")}" : $"{HexToRustFormat("#B6B6B640")}", } }, "Stats", $"Panel{w}"); container.Add(new CuiElement { Parent = $"Panel{w}", Components = { new CuiRawImageComponent{Color = "1 1 1 1", Png = ImageLibrary.Call("GetImage", item.Key)}, new CuiRectTransformComponent{AnchorMin = "0.02865994 0.1722385", AnchorMax = "0.08271399 0.7695832"} } }); container.Add(new CuiElement { Parent = $"Panel{w}", Components = { new CuiTextComponent{Color = $"{HexToRustFormat("#E8E2D9FF")}", Text = $"{GetItemName(item.Key)}", Align = TextAnchor.MiddleCenter, FontSize = 11, Font = "robotocondensed-bold.ttf"}, new CuiRectTransformComponent{AnchorMin = "0.1079392 0.1722385", AnchorMax = "0.2466779 0.7695833"} } }); container.Add(new CuiElement { Parent = $"Panel{w}", Components = { new CuiTextComponent{Color = $"1 1 1 1", Text = $"x{item.Value}", Align = TextAnchor.MiddleCenter, FontSize = 11, Font = "robotocondensed-bold.ttf"}, new CuiRectTransformComponent{AnchorMin = "0.8895574 0.238938", AnchorMax = "0.9779108 0.8362827"} } }); anchormin1 -= 0.0800583; anchormax1 -= 0.0800583; w++; } CuiHelper.AddUi(player, container); } private void LoadedPlayers(BasePlayer player, int page = 0, string active = "mystats") { var container = new CuiElementContainer(); CuiHelper.DestroyUi(player, $"MyStatsBTN"); CuiHelper.DestroyUi(player, $"TopBTN"); CuiHelper.DestroyUi(player, $"Panel-selfTop"); CuiHelper.DestroyUi(player, $"Panel-self"); CuiHelper.DestroyUi(player, $"BTNprev"); CuiHelper.DestroyUi(player, $"BTNnext"); for (int i = 0; i < 10; i++) { CuiHelper.DestroyUi(player, $"Panel{i}"); CuiHelper.DestroyUi(player, $"PanelM{i}"); } for (int i = 0; i < 6; i++) { CuiHelper.DestroyUi(player, $"BTN{i}"); } container.Add(new CuiButton { RectTransform = { AnchorMin = "-7.636845E-08 0.9272198", AnchorMax= "0.4910071 1.000324" }, Button = { Color = active == "mystats" ? $"{HexToRustFormat("#B6B6B680")}" : $"{HexToRustFormat("#B6B6B640")}", Command = $"skipp {page} mystats", }, Text = { Text = "My stats", Color = active == "mystats" ? $"{HexToRustFormat("#464646CE")}" : $"1 1 1 0.8", Align = TextAnchor.MiddleCenter, FontSize = 12, Font = "robotocondensed-bold.ttf" } }, "Stats", "MyStatsBTN"); container.Add(new CuiButton { RectTransform = { AnchorMin = "0.5089937 0.9272198", AnchorMax= "1.000001 1.000324" }, Button = { Color = active == "top" ? $"{HexToRustFormat("#B6B6B680")}" : $"{HexToRustFormat("#B6B6B640")}", Command = $"skipp {page} top", }, Text = { Text = "Players top", Color = active == "top" ? $"{HexToRustFormat("#464646CE")}" : $"1 1 1 0.8", Align = TextAnchor.MiddleCenter, FontSize = 12, Font = "robotocondensed-bold.ttf" } }, "Stats", "TopBTN"); switch (active) { case "top": var items = from item in DB orderby item.Value.Points descending select item; int z = 0; double anchormin2 = 0.7976711, anchormax2 = 0.8707748; foreach (var item in items.Skip(page * 10).Take(10)) { container.Add(new CuiPanel { RectTransform = { AnchorMin = $"-1.024455E-07 {anchormin2}", AnchorMax = $"0.08992793 {anchormax2}" }, Image = { Color = z % 2 == 0 ? $"{HexToRustFormat("#B6B6B62E")}" : $"{HexToRustFormat("#B6B6B640")}", } }, "Stats", $"Panel{z}"); container.Add(new CuiButton { RectTransform = { AnchorMin = $"0.1043165 {anchormin2}", AnchorMax = $"1 {anchormax2}" }, Button = { Color = z % 2 == 0 ? $"{HexToRustFormat("#B6B6B62E")}" : $"{HexToRustFormat("#B6B6B640")}", Command = $"showstats {item.Key}", }, Text = { Text = "" } }, "Stats", $"PanelM{z}"); container.Add(new CuiElement { Parent = $"Panel{z}", Components = { new CuiTextComponent{Color = $"{HexToRustFormat("#E8E2D9E5")}", Text = $"{(z + 1) + page * 10}", Align = TextAnchor.MiddleCenter, FontSize = 12, Font = "robotocondensed-bold.ttf"}, new CuiRectTransformComponent{AnchorMin = "0 0", AnchorMax = "1 1"} } }); if (item.Key == player.userID) { container.Add(new CuiPanel { RectTransform = { AnchorMin = "0 0", AnchorMax = "1 1", OffsetMin = "0 0", OffsetMax = "0 -0.2" }, Image = { Color = $"{HexToRustFormat("#767E45A3")}", Sprite = "assets/content/ui/ui.background.transparent.linearltr.tga", FadeIn = 1f } }, $"PanelM{z}"); } container.Add(new CuiElement { Parent = $"PanelM{z}", Components = { new CuiRawImageComponent{Color = "1 1 1 1", Png = GetImage(item.Key.ToString(), 0)}, new CuiRectTransformComponent{AnchorMin = "0.01004001 0.09955752", AnchorMax = "0.0903613 0.8960171"} } }); container.Add(new CuiElement { Parent = $"PanelM{z}", Components = { new CuiTextComponent{Color = $"{HexToRustFormat("#E8E2D9E5")}", Text = $"{item.Value.DisplayName}", Align = TextAnchor.MiddleLeft, FontSize = 11, Font = "robotocondensed-bold.ttf"}, new CuiRectTransformComponent{AnchorMin = "0.1044177 0.3713536", AnchorMax = "0.5461848 0.955752"} } }); container.Add(new CuiElement { Parent = $"PanelM{z}", Components = { new CuiTextComponent{Color = $"1 1 1 0.8", Text = $"{item.Key}", Align = TextAnchor.MiddleLeft, FontSize = 10, Font = "robotocondensed-regular.ttf"}, new CuiRectTransformComponent{AnchorMin = "0.1044177 0.01294668", AnchorMax = "0.4056225 0.5973451"} } }); double kd2; if (item.Value.Settings["Death"] == 0) { kd2 = item.Value.Settings["Kill"]; } else { kd2 = Math.Round(Convert.ToDouble(item.Value.Settings["Kill"] / item.Value.Settings["Death"]), 2); } container.Add(new CuiElement { Parent = $"PanelM{z}", Components = { new CuiTextComponent{Color = $"{HexToRustFormat("#E8E2D9FF")}", Text = $"{kd2}", Align = TextAnchor.MiddleCenter, FontSize = 11, Font = "robotocondensed-bold.ttf"}, new CuiRectTransformComponent{AnchorMin = "0.7168675 0.238938", AnchorMax = "0.7831326 0.8362826"} } }); container.Add(new CuiElement { Parent = $"PanelM{z}", Components = { new CuiTextComponent{Color = $"1 1 1 1", Text = $"{item.Value.Points}", Align = TextAnchor.MiddleCenter, FontSize = 11, Font = "robotocondensed-bold.ttf"}, new CuiRectTransformComponent{AnchorMin = "0.8895574 0.238938", AnchorMax = "0.9779108 0.8362827"} } }); anchormin2 -= 0.0800583; anchormax2 -= 0.0800583; z++; } double xMin = -2.086163E-07, xMax = 0.08992782; const double MinDiff = 0.1043164 - (-2.086163E-07), MaxDiff = 0.1942447 - 0.08992782; if (items.Skip((5) * 10).Take(10).Count() > 0) { for (int i = 0; i < 6; i++) { var color = items.Skip((page + i) * 10).Take(10).Count() > 0 ? $"{HexToRustFormat("#B6B6B640")}" : $"{HexToRustFormat("#B6B6B634")}"; if (i == 0) { container.Add(new CuiButton { RectTransform = { AnchorMin = $"{xMin} -0.002911206", AnchorMax= $"{xMax} 0.06986897" }, Button = { Color = page + i == page ? $"{HexToRustFormat("#B6B6B680")}" : color, Command = page != 0 ? $"skipp {page - 1} top" : "", }, Text = { Text = $"{page + 1 + i}", Color = page + i == page ? $"{HexToRustFormat("#464646CE")}" : $"1 1 1 0.8", Align = TextAnchor.MiddleCenter, FontSize = 12, Font = "robotocondensed-bold.ttf" } }, "Stats", $"BTN{i}"); } else { container.Add(new CuiButton { RectTransform = { AnchorMin = $"{xMin} -0.002911206", AnchorMax= $"{xMax} 0.06986897" }, Button = { Color = page + i == page ? $"{HexToRustFormat("#B6B6B680")}" : color, Command = items.Skip((page + i) * 10).Take(10).Count() > 0 ? $"skipp {page + i} top" : "", }, Text = { Text = items.Skip((page + i) * 10).Take(10).Count() > 0 ? $"{page + 1 + i}" : "", Color = page + i == page ? $"{HexToRustFormat("#464646CE")}" : $"1 1 1 0.8", Align = TextAnchor.MiddleCenter, FontSize = 12, Font = "robotocondensed-bold.ttf" } }, "Stats", $"BTN{i}"); } xMin += MinDiff; xMax += MaxDiff; } } else { var color1 = items.Skip((0) * 10).Take(10).Count() > 0 ? $"{HexToRustFormat("#B6B6B640")}" : $"{HexToRustFormat("#B6B6B634")}"; for (int i = 0; i < 6; i++) { CuiHelper.DestroyUi(player, $"BTN{i}"); } container.Add(new CuiButton { RectTransform = { AnchorMin = $"-2.086163E-07 -0.002911206", AnchorMax= $"0.08992782 0.06986897" }, Button = { Color = page == 0 ? $"{HexToRustFormat("#B6B6B680")}" : color1, Command = items.Skip((0) * 10).Take(10).Count() > 0 ? $"skipp 0 top" : "", }, Text = { Text = items.Skip((0) * 10).Take(10).Count() > 0 ? "1" : "", Color = page == 0 ? $"{HexToRustFormat("#464646CE")}" : $"1 1 1 0.8", Align = TextAnchor.MiddleCenter, FontSize = 12, Font = "robotocondensed-bold.ttf" } }, "Stats", $"BTN{0}"); var color2 = items.Skip((1) * 10).Take(10).Count() > 0 ? $"{HexToRustFormat("#B6B6B640")}" : $"{HexToRustFormat("#B6B6B634")}"; container.Add(new CuiButton { RectTransform = { AnchorMin = $"0.1043164 -0.002911206", AnchorMax= $"0.1942447 0.06986897" }, Button = { Color = page == 1 ? $"{HexToRustFormat("#B6B6B680")}" : color2, Command = items.Skip((1) * 10).Take(10).Count() > 0 ? $"skipp 1 top" : "", }, Text = { Text = items.Skip((1) * 10).Take(10).Count() > 0 ? "2" : "", Color = page == 1 ? $"{HexToRustFormat("#464646CE")}" : $"1 1 1 0.8", Align = TextAnchor.MiddleCenter, FontSize = 12, Font = "robotocondensed-bold.ttf" } }, "Stats", $"BTN{1}"); var color3 = items.Skip((2) * 10).Take(10).Count() > 0 ? $"{HexToRustFormat("#B6B6B640")}" : $"{HexToRustFormat("#B6B6B634")}"; container.Add(new CuiButton { RectTransform = { AnchorMin = $"0.2086327 -0.002911206", AnchorMax= $"0.2985615 0.06986897" }, Button = { Color = page == 2 ? $"{HexToRustFormat("#B6B6B680")}" : color3, Command = items.Skip((2) * 10).Take(10).Count() > 0 ? $"skipp 2 top" : "", }, Text = { Text = items.Skip((2) * 10).Take(10).Count() > 0 ? "3" : "", Color = page == 2 ? $"{HexToRustFormat("#464646CE")}" : $"1 1 1 0.8", Align = TextAnchor.MiddleCenter, FontSize = 12, Font = "robotocondensed-bold.ttf" } }, "Stats", $"BTN{2}"); var color4 = items.Skip((3) * 10).Take(10).Count() > 0 ? $"{HexToRustFormat("#B6B6B640")}" : $"{HexToRustFormat("#B6B6B634")}"; container.Add(new CuiButton { RectTransform = { AnchorMin = $"0.3111508 -0.002911206", AnchorMax= $"0.40108 0.06986897" }, Button = { Color = page == 3 ? $"{HexToRustFormat("#B6B6B680")}" : color4, Command = items.Skip((3) * 10).Take(10).Count() > 0 ? $"skipp 3 top" : "", }, Text = { Text = items.Skip((3) * 10).Take(10).Count() > 0 ? "4" : "", Color = page == 3 ? $"{HexToRustFormat("#464646CE")}" : $"1 1 1 0.8", Align = TextAnchor.MiddleCenter, FontSize = 12, Font = "robotocondensed-bold.ttf" } }, "Stats", $"BTN{3}"); var color5 = items.Skip((4) * 10).Take(10).Count() > 0 ? $"{HexToRustFormat("#B6B6B640")}" : $"{HexToRustFormat("#B6B6B634")}"; container.Add(new CuiButton { RectTransform = { AnchorMin = $"0.4154679 -0.002911206", AnchorMax= $"0.5053971 0.06986897" }, Button = { Color = page == 4 ? $"{HexToRustFormat("#B6B6B680")}" : color5, Command = items.Skip((4) * 10).Take(10).Count() > 0 ? $"skipp 4 top" : "", }, Text = { Text = items.Skip((4) * 10).Take(10).Count() > 0 ? "5" : "", Color = page == 4 ? $"{HexToRustFormat("#464646CE")}" : $"1 1 1 0.8", Align = TextAnchor.MiddleCenter, FontSize = 12, Font = "robotocondensed-bold.ttf" } }, "Stats", $"BTN{4}"); var color6 = items.Skip((5) * 10).Take(10).Count() > 0 ? $"{HexToRustFormat("#B6B6B640")}" : $"{HexToRustFormat("#B6B6B634")}"; container.Add(new CuiButton { RectTransform = { AnchorMin = $"0.5197849 -0.002911206", AnchorMax= $"0.6097141 0.06986897" }, Button = { Color = page == 5 ? $"{HexToRustFormat("#B6B6B680")}" : color6, Command = items.Skip((5) * 10).Take(10).Count() > 0 ? $"skipp 5 top" : "", }, Text = { Text = items.Skip((5) * 10).Take(10).Count() > 0 ? "6" : "", Color = page == 5 ? $"{HexToRustFormat("#464646CE")}" : $"1 1 1 0.8", Align = TextAnchor.MiddleCenter, FontSize = 12, Font = "robotocondensed-bold.ttf" } }, "Stats", $"BTN{5}"); } container.Add(new CuiButton { RectTransform = { AnchorMin = $"0.6241004 -0.002911206", AnchorMax= $"0.8057582 0.06986897" }, Button = { Color = $"{HexToRustFormat("#B6B6B640")}", Command = page != 0 ? $"skipp {page - 1} top" : "", }, Text = { Text = "<", Color = page != 0 ? $"1 1 1 1" : $"1 1 1 0.5", Align = TextAnchor.MiddleCenter, FontSize = 16, Font = "robotocondensed-bold.ttf" } }, "Stats", $"BTNprev"); container.Add(new CuiButton { RectTransform = { AnchorMin = $"0.8165474 -0.002911206", AnchorMax= $"0.9982052 0.06986897" }, Button = { Color = $"{HexToRustFormat("#B6B6B640")}", Command = items.Skip((page + 1) * 10).Take(10).Count() > 0 ? $"skipp {page + 1} top" : "", }, Text = { Text = ">", Color = items.Skip((page + 1) * 10).Take(10).Count() > 0 ? $"1 1 1 1" : $"1 1 1 0.5", Align = TextAnchor.MiddleCenter, FontSize = 16, Font = "robotocondensed-bold.ttf" } }, "Stats", $"BTNnext"); break; case "mystats": CuiHelper.DestroyUi(player, $"Panel-selfTop"); CuiHelper.DestroyUi(player, $"Panel-self"); var db = DB[player.userID]; container.Add(new CuiPanel { RectTransform = { AnchorMin = $"-1.024455E-07 0.7976711", AnchorMax = $"0.08992793 0.8707748" }, Image = { Color = $"{HexToRustFormat("#B6B6B640")}", } }, "Stats", $"Panel-selfTop"); container.Add(new CuiPanel { RectTransform = { AnchorMin = $"0.1043165 0.7976711", AnchorMax = $"1 0.8707748" }, Image = { Color = $"{HexToRustFormat("#B6B6B640")}", } }, "Stats", $"Panel-self"); container.Add(new CuiElement { Parent = $"Panel-selfTop", Components = { new CuiTextComponent{Color = $"{HexToRustFormat("#E8E2D9E5")}", Text = $"{GetTopScore(player.userID)}", Align = TextAnchor.MiddleCenter, FontSize = 12, Font = "robotocondensed-bold.ttf"}, new CuiRectTransformComponent{AnchorMin = "0 0", AnchorMax = "1 1"} } }); container.Add(new CuiPanel { RectTransform = { AnchorMin = "0 0", AnchorMax = "1 1", OffsetMin = "0 0", OffsetMax = "0 -0.2" }, Image = { Color = $"{HexToRustFormat("#767E45A3")}", Sprite = "assets/content/ui/ui.background.transparent.linearltr.tga", FadeIn = 1f } }, $"Panel-self"); container.Add(new CuiElement { Parent = $"Panel-self", Components = { new CuiRawImageComponent{Color = "1 1 1 1", Png = GetImage(player.UserIDString, 0)}, new CuiRectTransformComponent{AnchorMin = "0.01004001 0.09955752", AnchorMax = "0.0903613 0.8960171"} } }); container.Add(new CuiElement { Parent = $"Panel-self", Components = { new CuiTextComponent{Color = $"{HexToRustFormat("#E8E2D9E5")}", Text = $"{db.DisplayName}", Align = TextAnchor.MiddleLeft, FontSize = 11, Font = "robotocondensed-bold.ttf"}, new CuiRectTransformComponent{AnchorMin = "0.1044177 0.3713536", AnchorMax = "0.5461848 0.955752"} } }); container.Add(new CuiElement { Parent = $"Panel-self", Components = { new CuiTextComponent{Color = $"1 1 1 0.8", Text = $"{player.userID}", Align = TextAnchor.MiddleLeft, FontSize = 10, Font = "robotocondensed-regular.ttf"}, new CuiRectTransformComponent{AnchorMin = "0.1044177 0.01294668", AnchorMax = "0.4056225 0.5973451"} } }); double kd; if (db.Settings["Death"] == 0) { kd = db.Settings["Kill"]; } else { kd = Math.Round(Convert.ToDouble(db.Settings["Kill"] / db.Settings["Death"]), 2); } container.Add(new CuiElement { Parent = $"Panel-self", Components = { new CuiTextComponent{Color = $"{HexToRustFormat("#E8E2D9FF")}", Text = $"{kd}", Align = TextAnchor.MiddleCenter, FontSize = 11, Font = "robotocondensed-bold.ttf"}, new CuiRectTransformComponent{AnchorMin = "0.7168675 0.238938", AnchorMax = "0.7831326 0.8362826"} } }); container.Add(new CuiElement { Parent = $"Panel-self", Components = { new CuiTextComponent{Color = $"1 1 1 1", Text = $"{db.Points}", Align = TextAnchor.MiddleCenter, FontSize = 11, Font = "robotocondensed-bold.ttf"}, new CuiRectTransformComponent{AnchorMin = "0.8895574 0.238938", AnchorMax = "0.9779108 0.8362827"} } }); double anchormin1 = 0.7176128, anchormax1 = 0.7907165; int w = 0; foreach (var item in db.Res) { CuiHelper.DestroyUi(player, $"Panel{w}"); container.Add(new CuiPanel { RectTransform = { AnchorMin = $"0.001798302 {anchormin1}", AnchorMax = $"1 {anchormax1}" }, Image = { Color = w % 2 == 0 ? $"{HexToRustFormat("#B6B6B62E")}" : $"{HexToRustFormat("#B6B6B640")}", } }, "Stats", $"Panel{w}"); container.Add(new CuiElement { Parent = $"Panel{w}", Components = { new CuiRawImageComponent{Color = "1 1 1 1", Png = ImageLibrary.Call("GetImage", item.Key)}, new CuiRectTransformComponent{AnchorMin = "0.02865994 0.1722385", AnchorMax = "0.08271399 0.7695832"} } }); container.Add(new CuiElement { Parent = $"Panel{w}", Components = { new CuiTextComponent{Color = $"{HexToRustFormat("#E8E2D9FF")}", Text = $"{GetItemName(item.Key)}", Align = TextAnchor.MiddleCenter, FontSize = 11, Font = "robotocondensed-bold.ttf"}, new CuiRectTransformComponent{AnchorMin = "0.1079392 0.1722385", AnchorMax = "0.2466779 0.7695833"} } }); container.Add(new CuiElement { Parent = $"Panel{w}", Components = { new CuiTextComponent{Color = $"1 1 1 1", Text = $"x{item.Value}", Align = TextAnchor.MiddleCenter, FontSize = 11, Font = "robotocondensed-bold.ttf"}, new CuiRectTransformComponent{AnchorMin = "0.8895574 0.238938", AnchorMax = "0.9779108 0.8362827", OffsetMin = "-5 0", OffsetMax = "0 0"} } }); anchormin1 -= 0.0800583; anchormax1 -= 0.0800583; w++; } break; } CuiHelper.AddUi(player, container); } private void MainUI(BasePlayer player) { var container = new CuiElementContainer(); CuiHelper.DestroyUi(player, "MainLayer"); container.Add(new CuiPanel { CursorEnabled = true, RectTransform = { AnchorMin = "0 0", AnchorMax = "1 1", OffsetMin = "0 0", OffsetMax = "0 0" }, Image = { Color = "0 0 0 0.5", Material = "assets/content/ui/uibackgroundblur-ingamemenu.mat" } }, "Overlay", "MainLayer"); container.Add(new CuiElement { Parent = "MainLayer", Name = "BG", Components = { new CuiRawImageComponent{Color = "1 1 1 1", Png = ImageLibrary.Call("GetImage", "Viniette")}, new CuiRectTransformComponent { AnchorMin = "0 0", AnchorMax = "1 1" } } }); container.Add(new CuiButton { RectTransform = { AnchorMin = "0 0", AnchorMax= "1 1" }, Text = { Text = "", }, Button = { Color = "0 0 0 0", Close = "MainLayer", } }, "BG"); container.Add(new CuiPanel { RectTransform = { AnchorMin = "0.3552084 0.1814815", AnchorMax = "0.6447917 0.8175926" }, Image = { Color = "0 0 0 0" } }, "BG", "Stats"); container.Add(new CuiPanel { RectTransform = { AnchorMin = "-1.452863E-07 0.8777293", AnchorMax = "1 0.915575" }, Image = { Color = $"{HexToRustFormat("#B6B6B640")}", } }, "Stats", "Title"); container.Add(new CuiElement { Parent = "Title", Components = { new CuiTextComponent{Color = $"{HexToRustFormat("#E8E2D9E5")}", Text = "#", Align = TextAnchor.MiddleLeft, FontSize = 12, Font = "robotocondensed-bold.ttf"}, new CuiRectTransformComponent{AnchorMin = "0.02505634 -0.06125348", AnchorMax = "0.07550681 1.076922"} } }); container.Add(new CuiElement { Parent = "Title", Components = { new CuiTextComponent{Color = $"{HexToRustFormat("#E8E2D9E5")}", Text = "Игрок", Align = TextAnchor.MiddleLeft, FontSize = 12, Font = "robotocondensed-bold.ttf"}, new CuiRectTransformComponent{AnchorMin = "0.1115429 -0.06125348", AnchorMax = "0.201633 1.076922"} } }); container.Add(new CuiElement { Parent = "Title", Components = { new CuiTextComponent{Color = $"{HexToRustFormat("#E8E2D9E5")}", Text = "K/D", Align = TextAnchor.MiddleLeft, FontSize = 12, Font = "robotocondensed-bold.ttf"}, new CuiRectTransformComponent{AnchorMin = "0.7511791 -0.06125348", AnchorMax = "0.8412685 1.076922"} } }); container.Add(new CuiElement { Parent = "Title", Components = { new CuiTextComponent{Color = $"{HexToRustFormat("#E8E2D9E5")}", Text = "Очки", Align = TextAnchor.MiddleLeft, FontSize = 12, Font = "robotocondensed-bold.ttf"}, new CuiRectTransformComponent{AnchorMin = "0.9079347 -0.06125348", AnchorMax = "0.9980241 1.076922"} } }); CuiHelper.AddUi(player, container); LoadedPlayers(player, 0, "mystats"); } #endregion } }