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

FREE Batia : 1.0.0 1.0.0

Нет прав для скачивания
C#:
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Oxide.Core;
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using Rust;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using UnityEngine;
namespace Oxide.Plugins {
    [Info("Batia", "https://discord.gg/dNGbxafuJn", "1.0.0")]
    internal class Batia : RustPlugin {
        [PluginReference]
        Plugin ImageLibrary, BroadcastSystem;
        void Loaded() {
            ins = this;
        }
        void OnServerInitialized() {
            if (ImageLibrary) {
                var images = config.bottleSetting.CustomItemsShop.Where(p => !string.IsNullOrEmpty(p.ImageURL));
                foreach (var check in images) ImageLibrary.Call("AddImage", check.ImageURL, check.ImageURL);
                foreach (var check in config.artefactsSettings.ItemsAdded) {
                    ImageLibrary.Call("AddImage", check.ImageURL, check.ImageURL);
                }
                ImageLibrary.Call("AddImage", "https://gspics.org/images/2022/01/14/0QKR0I.png", "https://gspics.org/images/2022/06/04/0nWJCJ.png");
                ImageLibrary.Call("AddImage", "https://gspics.org/images/2022/06/04/0nWcGe.png", "https://gspics.org/images/2022/06/04/0nWcGe.png");
                ImageLibrary.Call("AddImage", "https://gspics.org/images/2022/06/04/0nWsOm.png", "https://gspics.org/images/2022/06/04/0nWsOm.png");
                ImageLibrary.Call("AddImage", "https://gspics.org/images/2022/01/16/0QsHPj.png", "https://gspics.org/images/2022/01/16/0QsHPj.png");
            }
            if (config.gameStoresSettings == null) {
                config.gameStoresSettings = new GameStoresSettings() {
                    Secret = "", ShopID = ""
                }
                ;
                SaveConfig();
            }
            foreach (var player in BasePlayer.activePlayerList) OnPlayerConnected(player);
        }
        public string External = "UI_Batia_External";
        public string Internal = "UI_Batia_Internal";
        void DrawNPCUI(BasePlayer player) {
            CuiElementContainer container = new CuiElementContainer();
            CuiHelper.DestroyUi(player, External);
            CuiHelper.DestroyUi(player, Internal);
            container.Add(new CuiPanel {
                CursorEnabled = true, RectTransform = {
                    AnchorMin = "0 0", AnchorMax = "1 1", OffsetMax = "0 0"
                }
                , Image = {
                    Color = "0.235 0.227 0.180 0"
                }
            }
            , "SubContent_UI", External);
            container.Add(new CuiPanel {
                RectTransform = {
                    AnchorMin = "0 0", AnchorMax = "1 1", OffsetMax = "0 0"
                }
                , Image = {
                    Color = "0 0 0 0.2"
                }
            }
            , External);
            container.Add(new CuiPanel {
                RectTransform = {
                    AnchorMin = "0 0", AnchorMax = "1 1", OffsetMax = "0 0"
                }
                , Image = {
                    Color = "0 0 0 0"
                }
            }
            , External);
            CuiHelper.AddUi(player, container);
            InitializeLayers(player);
            if (com != null && com.EndExpeditions.ContainsKey(player.userID)) CreateInfoPlayer(player, true);
        }
        void CreateInfoPlayer(BasePlayer player, bool opened) {
            if (opened) {
                player.Command("UI_Batia givepackage");
            }
            else {
                player.Command("UI_Batia givepackage");
            }
        }
        string GetMoodTranslate(FatherComponent.Mood mood) {
            switch (mood) {
                case FatherComponent.Mood.Neutral : return "СРЕДНЕЕ";
                case FatherComponent.Mood.Kind : return "УЛУЧШЕННОЕ";
                case FatherComponent.Mood.Evil : return "ПЕРЕБОИ ПОСТАВОК";
            }
            return "НЕЙТРАЛЬНАЯ";
        }
        string GetMoodInfoRmation(FatherComponent.Mood mood) {
            switch (mood) {
                case FatherComponent.Mood.Neutral : return "От поставок в кузницу зависит курс обмена предметов. Курс обмена предметов в кузнице стандартные. Чем лучше снабжение, тем больше предметов вам предложат.";
                case FatherComponent.Mood.Kind : return "От поставок в кузницу зависит курс обмена предметов. Курс обмена предметов в кузнице увеличены.  Чем лучше снабжение, тем больше предметов вам предложат.";
                case FatherComponent.Mood.Evil : return "Перебои с поставками. Курс обмена снижен. Лучше ожидайте более высокие поставки в кузницу.";
            }
            return "От поставок в кузницу зависит курс обмена предметов. Курс обмена предметов в кузнице стандартные. Чем лучше снабжение, тем больше предметов вам предложат.";
        }
        string InitialLayer = "UI_Batia_InitialLayer";
        private void InitializeLayers(BasePlayer player, string SelectMenu = "") {
            CuiElementContainer container = new CuiElementContainer();
            container.Add(new CuiPanel() {
                RectTransform = {
                    AnchorMin = "0.15 0", AnchorMax = "1 1", OffsetMin = "0 0"
                }
                , Image = {
                    Color = "0 0 0 0"
                }
            }
            , External, InitialLayer);
            container.Add(new CuiPanel() {
                RectTransform = {
                    AnchorMin = "0.7 0", AnchorMax = "0.9 1", OffsetMin = "0 0", OffsetMax = "0 0"
                }
                , Image = {
                    Color = "0.24 0.45 0.90 0", Material = ""
                }
            }
            , InitialLayer, InitialLayer + ".C");
            container.Add(new CuiPanel() {
                RectTransform = {
                    AnchorMin = "0.01 0", AnchorMax = "0.65 0.75", OffsetMin = "0 0", OffsetMax = "0 0"
                }
                , Image = {
                    Color = "0.24 0.45 0.90 0", Material = ""
                }
            }
            , InitialLayer, InitialLayer + ".R");
            CuiHelper.DestroyUi(player, InitialLayer);
            CuiHelper.AddUi(player, container);
            DrawMenuPoints(player);
        }
        void CreateInfoJson(BasePlayer player, int page) {
            CuiHelper.DestroyUi(player, InitialLayer + ".Expedition");
            CuiElementContainer container = new CuiElementContainer();
            container.Add(new CuiPanel() {
                RectTransform = {
                    AnchorMin = "-0.39 0", AnchorMax = "1 1"
                }
                , Image = {
                    Color = "0.24 0.45 0.90 0"
                }
            }
            , InitialLayer + ".R", InitialLayer + ".Expedition");
            container.Add(new CuiPanel() {
                RectTransform = {
                    AnchorMin = "0.1 0.01", AnchorMax = "0.9 0.5"
                }
                , Image = {
                    Color = "0.24 0.45 0.90 0"
                }
            }
            , InitialLayer + ".Expedition", InitialLayer + ".ItemsList");
            container.Add(new CuiElement {
                Parent = InitialLayer + ".ItemsList", Components = {
                    new CuiTextComponent {
                        Color = "0.929 0.882 0.847 1", Text = $"СПИСОК ПРЕДМЕТОВ И ОЧКИ ЗА НИХ:", Align = TextAnchor.UpperLeft , FontSize = 15
                    }
                    , new CuiRectTransformComponent {
                        AnchorMin = "0 1", AnchorMax = "1 1.1"
                    }
                }
            }
            );
            var pos = GetPositions(10, 5, 0.01f, 0.02f);
            int count = 0;
            var itemsList = config.expeditionSettings.ItemsAdded.OrderBy(p => p.Value.amount).Skip(page * 50).Take(50);
            foreach (var item in itemsList) {
                container.Add(new CuiPanel() {
                    RectTransform = {
                        AnchorMin = pos[count].AnchorMin, AnchorMax = pos[count].AnchorMax
                    }
                    , Image = {
                        Color = "0 0 0 0"
                    }
                }
                , InitialLayer + ".ItemsList", InitialLayer + item.Key);
                container.Add(new CuiElement {
                    Parent = InitialLayer + item.Key, Components = {
                        new CuiRawImageComponent {
                            Png = (string) ImageLibrary.Call("GetImage", item.Key), Color = "1 1 1 0.6"
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = "0.1 0.05", AnchorMax = "0.9 0.95"
                        }
                    }
                }
                );
                container.Add(new CuiElement {
                    Parent = InitialLayer + item.Key, Components = {
                        new CuiTextComponent {
                            Color = "0.929 0.882 0.847 1", Text = $"{item.Value.amount}", Align = TextAnchor.MiddleCenter , FontSize = 23, Font="robotocondensed-regular.ttf"
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = "0 0", AnchorMax = "1 1"
                        }
                    }
                }
                );
                container.Add(new CuiElement {
                    Parent = InitialLayer + item.Key, Components = {
                        new CuiTextComponent {
                            Color = "0.929 0.882 0.847 0.5", Text = $"MAX {item.Value.maxCount}", Align = TextAnchor.LowerCenter , FontSize = 12, Font="robotocondensed-regular.ttf"
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = "0 0.05", AnchorMax = "1 1"
                        }
                    }
                }
                );
                count++;
            }
            container.Add(new CuiElement {
                Parent = InitialLayer + ".Expedition", Components = {
                    new CuiTextComponent {
                        Color = "0.929 0.882 0.847 1", Text = $"Здесь вы можете увидеть список предметов которые вы можете обменять, и количество очков, которые они дают. Оператор может отправить 5 разных посылок , в зависимости от количества набранных очков. Длительность доставки посылок около <b>1</b> часа.\n\n<size=14><b>Виды посылок:</b>\n        Потрепанная сумка (<b>от 20 до 20 очков</b>).\n        Слегка порванная сумка (<b>от 20 до 40 очков</b>).\n        Обычная сумка (<b>от 40 до 60 очков</b>).\n        Отличный контейнер (<b>от 60 до 80 очков</b>).\n        Презент от Оператора (<b>от 80 до 100 очков</b>).\n\n*<size=12>Максимально количество очков - 100.</size></size>", Align = TextAnchor.UpperLeft , Font="robotocondensed-regular.ttf", FontSize = 16
                    }
                    , new CuiRectTransformComponent {
                        AnchorMin = "0.1 0", AnchorMax = "1 1"
                    }
                }
            }
            );
            container.Add(new CuiButton {
                Button = {
                    Color = "0 0 0 0" , Command = page > 0 ? $"UI_Batia expedition {page -1}" : ""
                }
                , Text = {
                    Text = "◀", FontSize = 55, Align = TextAnchor.LowerRight, Color = page > 0 ? "0.929 0.882 0.847 0.7" : "0.929 0.882 0.847 0.1"
                }
                , RectTransform = {
                    AnchorMin = $"0 0.2", AnchorMax = $"0.1 0.4"
                }
            }
            , InitialLayer + ".Expedition");
            container.Add(new CuiButton {
                Button = {
                    Color = "0 0 0 0", Command = page < 2 ? $"UI_Batia expedition {page +1}" : ""
                }
                , Text = {
                    Text = "▶", FontSize = 55, Align = TextAnchor.LowerLeft, Color = page < 2 ? "0.929 0.882 0.847 0.7" : "0.929 0.882 0.847 0.1"
                }
                , RectTransform = {
                    AnchorMin = $"0.9 0.2", AnchorMax = $"1 0.4"
                }
            }
            , InitialLayer + ".Expedition");
            container.Add(new CuiPanel() {
                RectTransform = {
                    AnchorMin = "0.5 0.6", AnchorMax = "0.89 0.85"
                }
                , Image = {
                    Color = "0.77 0.74 0.71 0"
                }
            }
            , InitialLayer + ".Expedition", InitialLayer + ".buttonAccept");
            container.Add(new CuiElement {
                Parent = InitialLayer + ".buttonAccept", Components = {
                    new CuiTextComponent {
                        Color = "0.929 0.882 0.847 1", Text = $"Нажми что бы передать предметы на обмен".ToUpper(), Align = TextAnchor.UpperCenter , Font="robotocondensed-regular.ttf", FontSize = 14
                    }
                    , new CuiRectTransformComponent {
                        AnchorMin = "0.1 0", AnchorMax = "0.9 0.95"
                    }
                }
            }
            );
            container.Add(new CuiButton {
                Button = {
                    Color = "0.41 0.47 0.26 1.00" , Command = $"UI_Batia startLoot", Material = "assets/content/ui/uibackgroundblur-ingamemenu.mat"
                }
                , Text = {
                    Text = "НАЧАТЬ", FontSize = 20, Align = TextAnchor.MiddleCenter, Color = "0.59 0.69 0.42 0.7"
                }
                , RectTransform = {
                    AnchorMin = $"0.15 0.2", AnchorMax = $"0.9 0.6"
                }
            }
            , InitialLayer + ".buttonAccept");
            CuiHelper.AddUi(player, container);
            //UIList.Add(container.ToJson());
        }
        void CreateInfo(BasePlayer player) {
            CuiElementContainer container = new CuiElementContainer();
            container.Add(new CuiPanel() {
                RectTransform = {
                    AnchorMin = "-0.39 0", AnchorMax = "1 1"
                }
                , Image = {
                    Color = "0.24 0.45 0.90 0"
                }
            }
            , InitialLayer + ".R", InitialLayer + ".Info");
            container.Add(new CuiElement {
                Parent = InitialLayer + ".Info", Components = {
                    new CuiTextComponent {
                        Color = "0.929 0.882 0.847 1", Text = $"Это комендант Волтбой, и она может облегчить вашу жизнь в этом мире, если вы конечно заслужите это.", Align = TextAnchor.UpperLeft , Font="robotocondensed-regular.ttf", FontSize = 16
                    }
                    , new CuiRectTransformComponent {
                        AnchorMin = "0.1 0", AnchorMax = "1 0.98"
                    }
                }
            }
            );
            container.Add(new CuiElement {
                Parent = InitialLayer + ".Info", Components = {
                    new CuiTextComponent {
                        Color = "0.929 0.882 0.847 1", Text = $"Волтбой имеет <b>настроение</b>, от которого будет зависеть напрямую количество и качество предметов которые Вы можете получить от него (настроение указанно в верхней части экрана)", Align = TextAnchor.UpperLeft , Font="robotocondensed-regular.ttf", FontSize = 14
                    }
                    , new CuiRectTransformComponent {
                        AnchorMin = "0.1 0", AnchorMax = "1 0.9"
                    }
                }
            }
            );
            container.Add(new CuiElement {
                Parent = InitialLayer + ".Info", Components = {
                    new CuiTextComponent {
                        Color = "0.929 0.882 0.847 1", Text = "<size=18><b>Вкладка 'ПОСЫЛКИ'</b></size> \nВолтбой может забрать ваши предметы, позвонить своим барахольщикам и дать что-то лучше, чем Вы предложили ей.\nКаждый предмет имеет определенное количество очков равноценное его редкости и сложности получения. (чем предмет легче получить, тем меньше очков он дает).\nМаксимальное внесенное количество предметов: <b>10 единиц</b>\nМаксимальное количество получаемых предметов: <b>от 4 до 6 единиц</b>\nТак что не надейтесь получить за свое копье какой-нибудь AK47 или LR300.\nКогда Волтбой закончит с Вашей посылкой, она пришлет ее вам в раздел инвентарь. Появиться соответствующее уведомление на экране.\nКоличество и качество предметов зависит напрямую от настроения коменданта.\nВремя на каждую 'Посылку' рандомное.\nПопросить следующую посылку нельзя пока активна предыдущая.", Align = TextAnchor.UpperLeft , Font="robotocondensed-regular.ttf", FontSize = 14
                    }
                    , new CuiRectTransformComponent {
                        AnchorMin = "0.1 0", AnchorMax = "1 0.78"
                    }
                }
            }
            );
            container.Add(new CuiElement {
                Parent = InitialLayer + ".Info", Components = {
                    new CuiTextComponent {
                        Color = "0.929 0.882 0.847 1", Text = "<size=18><b>Вкладка 'Археотек'</b></size> \nВолтбой с удовольствием примет ваши крышки и обменяет их на что-то ценное.\nПредметы и цены в обменнике меняться рандомно раз в некоторое время.", Align = TextAnchor.UpperLeft , Font="robotocondensed-regular.ttf", FontSize = 14
                    }
                    , new CuiRectTransformComponent {
                        AnchorMin = "0.1 0", AnchorMax = "1 0.3"
                    }
                }
            }
            );
            CuiHelper.DestroyUi(player, InitialLayer + ".Info");
            CuiHelper.AddUi(player, container);
        }
        void ShowTOPArtefacts(BasePlayer player) {
            CuiElementContainer container = new CuiElementContainer();
            container.Add(new CuiPanel() {
                RectTransform = {
                    AnchorMin = "-0.39 0", AnchorMax = "1 1"
                }
                , Image = {
                    Color = "0.24 0.45 0.90 0"
                }
            }
            , InitialLayer + ".R", InitialLayer + ".Info");
            container.Add(new CuiElement {
                Parent = InitialLayer + ".Info", Components = {
                    new CuiTextComponent {
                        Color = "0.929 0.882 0.847 1", Text =$"Каждый  рестарт сервера, три игрока могут обменять шесть модификаций <b>3 уровня</b> на <b>300 рублей</b> в премиум магазине.\n<b>Виды НЮКА 'КОЛЫ':</b> 'ДИКАЯ', 'КВАНТОВАЯ', 'АПЕЛЬСИНОВАЯ', 'ВИНОГРАДНАЯ', 'ВИШНЕВАЯ', 'ВИКТОРИЯ'\n", Align = TextAnchor.UpperLeft , Font="robotocondensed-regular.ttf", FontSize = 16
                    }
                    , new CuiRectTransformComponent {
                        AnchorMin = "0.1 0", AnchorMax = "0.9 0.99"
                    }
                }
            }
            );
            container.Add(new CuiPanel() {
                RectTransform = {
                    AnchorMin = "0.05 0.32", AnchorMax = "1 0.74"
                }
                , Image = {
                    Color = "0.24 0.45 0.90 0"
                }
            }
            , InitialLayer + ".Info", InitialLayer + ".Artefacts.Players");
            var playerPos = GetPositions(3, 1, 0.05f, 0.08f);
            for (int i = 0; i < 3; i++) {
                container.Add(new CuiPanel() {
                    RectTransform = {
                        AnchorMin = playerPos[i].AnchorMin, AnchorMax = playerPos[i].AnchorMax
                    }
                    , Image = {
                        Color = "0 0 0 0"
                    }
                }
                , InitialLayer + ".Artefacts.Players", InitialLayer + ".Artefacts.Players" + i);
                if (ArtefactsList.Count > i) {
                    var playerID = ArtefactsList[i];
                    container.Add(new CuiElement {
                        Parent = InitialLayer + ".Artefacts.Players" + i, Components = {
                            new CuiRawImageComponent {
                                Png = (string) ImageLibrary?.Call("GetImage", playerID.ToString())
                            }
                            , new CuiRectTransformComponent {
                                AnchorMin = "0 0", AnchorMax = "1 1", OffsetMin = "10 10", OffsetMax = "-10 -10"
                            }
                        }
                    }
                    );
                    container.Add(new CuiPanel() {
                        RectTransform = {
                            AnchorMin = "0 0", AnchorMax = "1 1"
                        }
                        , Image = {
                            Color = "0.235 0.227 0.180 0"
                        }
                    }
                    , InitialLayer + ".Artefacts.Players" + i);
                    container.Add(new CuiElement {
                        Parent = InitialLayer + ".Artefacts.Players" + i, Components = {
                            new CuiTextComponent {
                                Color = "0.929 0.882 0.847 1", Text = permission.GetUserData(playerID.ToString()).LastSeenNickname.ToUpper(), Align = TextAnchor.MiddleCenter , Font="robotocondensed-regular.ttf", FontSize = 20
                            }
                            , new CuiRectTransformComponent {
                                AnchorMin = "0 0", AnchorMax = "1 1"
                            }
                        }
                    }
                    );
                }
                else {
                    container.Add(new CuiElement {
                        Parent = InitialLayer + ".Artefacts.Players" + i, Components = {
                            new CuiTextComponent {
                                Color = "0.929 0.882 0.847 1", Text = $"ПУСТО", Align = TextAnchor.MiddleCenter , Font="robotocondensed-regular.ttf", FontSize = 20
                            }
                            , new CuiRectTransformComponent {
                                AnchorMin = "0 0", AnchorMax = "1 1"
                            }
                        }
                    }
                    );
                }
            }
            container.Add(new CuiPanel() {
                RectTransform = {
                    AnchorMin = "0.05 0.1", AnchorMax = "1 0.25"
                }
                , Image = {
                    Color = "0.24 0.45 0.90 0"
                }
            }
            , InitialLayer + ".Info", InitialLayer + ".Artefacts.Invectory");
            container.Add(new CuiPanel() {
                RectTransform = {
                    AnchorMin = "0.05 0.12", AnchorMax = "0.75 1"
                }
                , Image = {
                    Color = "0.24 0.45 0.90 0"
                }
            }
            , InitialLayer + ".Artefacts.Invectory", InitialLayer + ".Artefacts.ItemList");
            if (ArtefactsList.Count < config.artefactsSettings.MaxCount && !ArtefactsList.Contains(player.userID)) {
                var invectoryPos = GetPositions(6, 1, 0.02f, 0.08f);
                int count = 0;
                List<ulong> IgnoreList = new List<ulong>();
                for (int i = 0; i < 6; i++) {
                    container.Add(new CuiPanel() {
                        RectTransform = {
                            AnchorMin = invectoryPos[i].AnchorMin, AnchorMax = invectoryPos[i].AnchorMax
                        }
                        , Image = {
                            Color = "0.815 0.776 0.741 0.15"
                        }
                    }
                    , InitialLayer + ".Artefacts.ItemList", InitialLayer + ".Artefacts.ItemList" + i);
                    var item = config.artefactsSettings.ItemsAdded[i];
                    foreach (var invItem in player.inventory.AllItems()) {
                        if (invItem.info.shortname == item.ShortName && invItem.skin == item.SkinID && !IgnoreList.Contains(item.SkinID)) {
                            container.Add(new CuiElement {
                                Parent = InitialLayer + ".Artefacts.ItemList" + count, Components = {
                                    new CuiRawImageComponent {
                                        Png = (string) ImageLibrary?.Call("GetImage", item.ImageURL)
                                    }
                                    , new CuiRectTransformComponent {
                                        AnchorMin = "0.05 0.05", AnchorMax = "0.95 0.95"
                                    }
                                }
                            }
                            );
                            IgnoreList.Add(item.SkinID);
                            count++;
                        }
                    }
                }
                if (count == 6) {
                    container.Add(new CuiButton {
                        Button = {
                            Color = "0.41 0.47 0.26 1.00", Command = $"UI_Batia takeArt", Material = "assets/content/ui/uibackgroundblur-ingamemenu.mat"
                        }
                        , Text = {
                            Text = "ОБМЕНЯТЬ", FontSize = 17, Align = TextAnchor.MiddleCenter, Color = "0.59 0.69 0.42 0.7"
                        }
                        , RectTransform = {
                            AnchorMin = "0.78 0.14", AnchorMax = "0.9 0.97"
                        }
                    }
                    , InitialLayer + ".Artefacts.Invectory");
                }
                else {
                    container.Add(new CuiButton {
                        RectTransform = {
                            AnchorMin = "0.78 0.14", AnchorMax = "0.9 0.97"
                        }
                        , Button = {
                            Command = "", Color = "0.815 0.776 0.741 0.15"
                        }
                        , Text = {
                            Text = "ОБМЕНЯТЬ", Align = TextAnchor.MiddleCenter, Font = "robotocondensed-bold.ttf", FontSize = 16, Color = "0.929 0.882 0.847 0.1"
                        }
                    }
                    , InitialLayer + ".Artefacts.Invectory");
                }
            }
            else if (ArtefactsList.Count >= config.artefactsSettings.MaxCount) {
                container.Add(new CuiElement {
                    Parent = InitialLayer + ".Artefacts.Invectory", Components = {
                        new CuiTextComponent {
                            Color = "0.929 0.882 0.847 1", Text = $"ОБМЕН ЗАКОНЧЕН, ЕСТЬ ТРИ ПОБЕДИТЕЛЯ", Align = TextAnchor.MiddleCenter , Font="robotocondensed-regular.ttf", FontSize = 25
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = "0 0", AnchorMax = "1 1"
                        }
                    }
                }
                );
            }
            else if (ArtefactsList.Contains(player.userID)) {
                container.Add(new CuiElement {
                    Parent = InitialLayer + ".Artefacts.Invectory", Components = {
                        new CuiTextComponent {
                            Color = "0.929 0.882 0.847 1", Text = $"ВЫ ПОЛУЧИЛИ УЖЕ СВОЙ ПРИЗ В ЭТОМ ВАЙПЕ", Align = TextAnchor.MiddleCenter , Font="robotocondensed-regular.ttf", FontSize = 25
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = "0 0", AnchorMax = "1 1"
                        }
                    }
                }
                );
            }
            CuiHelper.DestroyUi(player, InitialLayer + ".Info");
            CuiHelper.AddUi(player, container);
        }
        bool TakeItems(BasePlayer player) {
            List<ulong> IgnoreList = new List<ulong>();
            List<Item> currentList = new List<Item>();
            for (int i = 0; i < 6; i++) {
                var item = config.artefactsSettings.ItemsAdded[i];
                foreach (var invItem in player.inventory.AllItems()) {
                    if (invItem.info.shortname == item.ShortName && invItem.skin == item.SkinID && !IgnoreList.Contains(item.SkinID)) {
                        currentList.Add(invItem);
                        IgnoreList.Add(item.SkinID);
                    }
                }
            }
            bool result = false;
            if (currentList.Count == 6) {
                result = true;
                foreach (var item in currentList) item.UseItem(1);
            }
            return result;
        }
        void CreateBottleExchange(BasePlayer player, int page = 0) {
            CuiElementContainer container = new CuiElementContainer();
            double amount = (double)Economics.Call("Balance", player.userID);
            container.Add(new CuiPanel() {
                RectTransform = {
                    AnchorMin = "-0.3 0", AnchorMax = "1.3 1"
                }
                , Image = {
                    Color = "0 0 0 0"
                }
            }
            , InitialLayer + ".R", InitialLayer + ".Bottle");
            var itemList = config.bottleSetting.CustomItemsShop.Skip(page * 18);
            if (itemList.Count() > 18) {
                container.Add(new CuiButton {
                    Button = {
                        Command = $"UI_Gold page {page+1} ", Color = "0 0 0 0" ,
                    }
                    , Text = {
                        Text = $"▶", FontSize = 60, Align = TextAnchor.MiddleRight, Color = "0.929 0.882 0.847 0.7"
                    }
                    , RectTransform = {
                        AnchorMin = $"0.89 -0.15", AnchorMax = $"0.99 0"
                    }
                }
                , InitialLayer + ".Bottle");
            }
            int i = 0;
            var pos = GetPositions(3, 5, 0.01f, 0.02f, false);
            foreach (var item in itemList.Take(18)) {
                container.Add(new CuiPanel() {
                    RectTransform = {
                        AnchorMin = pos[i].AnchorMin, AnchorMax = pos[i].AnchorMax
                    }
                    , Image = {
                        Color = "0.815 0.776 0.741 0.05", Sprite = "assets/content/ui/ui.background.transparent.radial.psd", Material = ""
                    }
                }
                , InitialLayer + ".Bottle", InitialLayer + $".Shop.{i}");
                container.Add(new CuiPanel() {
                    RectTransform = {
                        AnchorMin = "0 0", AnchorMax = "0.36 1", OffsetMin = "5 5", OffsetMax = "-5 -5"
                    }
                    , Image = {
                        Color = "0.815 0.776 0.741 0.3", Sprite = "assets/content/ui/ui.background.transparent.radial.psd"
                    }
                }
                , InitialLayer + $".Shop.{i}");
                var image = !string.IsNullOrEmpty(item.ImageURL) ? item.ImageURL : item.defaultItem.ShortName + 128;
                container.Add(new CuiElement {
                    Parent = InitialLayer + $".Shop.{i}", Components = {
                        new CuiRawImageComponent {
                            Png = (string) ImageLibrary?.Call("GetImage", image)
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = "0 0.08", AnchorMax = "0.34 0.92", OffsetMin = "10 5", OffsetMax = "-10 -5"
                        }
                    }
                }
                );
                container.Add(new CuiLabel {
                    RectTransform = {
                        AnchorMin = "0.36 0.7", AnchorMax = "1 1"
                    }
                    , Text = {
                        Text = item.Title, Align = TextAnchor.MiddleCenter, Font = "robotocondensed-regular.ttf", FontSize = 15, Color = "0.929 0.882 0.847 1"
                    }
                }
                , InitialLayer + $".Shop.{i}");
                container.Add(new CuiLabel {
                    RectTransform = {
                        AnchorMin = "0.36 0.3", AnchorMax = "1 0.7"
                    }
                    , Text = {
                        Text = $"ПОКУПКА ЗА: {item.NeedGold} RP", Align = TextAnchor.MiddleCenter, Font = "robotocondensed-regular.ttf", FontSize = 12, Color = "0.929 0.882 0.847 0.7"
                    }
                }
                , InitialLayer + $".Shop.{i}");
                var color = amount >= item.NeedGold ? "0.815 0.776 0.741 0.2" : "0.815 0.776 0.741 0.05";
                var Tcolor = amount >= item.NeedGold ? "0.929 0.882 0.847 1" : "0.929 0.882 0.847 0.1";
                container.Add(new CuiButton {
                    Button = {
                        Color = color, Command = $"UI_Batia buy {i}", Material = ""
                    }
                    , Text = {
                        Text = "ОБМЕНЯТЬ", Color = Tcolor, Font = "robotocondensed-regular.ttf", FontSize = 14, Align = TextAnchor.MiddleCenter
                    }
                    , RectTransform = {
                        AnchorMin = $"0.35 0.05", AnchorMax = $"0.99 0.25"
                    }
                    ,
                }
                , InitialLayer + $".Shop.{i}");
                i++;
            }
            CuiHelper.DestroyUi(player, InitialLayer + ".Bottle");
            CuiHelper.AddUi(player, container);
        }
        ItemContainer.CanAcceptResult? CanAcceptItem(ItemContainer container, Item item, int pos) {
            var newItem = container.parent as Item;
            if (newItem == null) return null;
            if (newItem.info.shortname == "wrappedgift") return ItemContainer.CanAcceptResult.CannotAccept;
            return null;
        }
        public void DrawMenuPoints(BasePlayer player, MenuPoints choosed = null) {
            if (choosed == null) choosed = config.menuUISettings.PointsList.ElementAt(0);
            CuiHelper.DestroyUi(player, InitialLayer + ".Bottle");
            CuiHelper.DestroyUi(player, InitialLayer + ".Info");
            CuiHelper.DestroyUi(player, InitialLayer + ".Expedition");
            CuiElementContainer container = new CuiElementContainer();
            float marginTop = -220;
            float originalHeight = 40;
            float freeHeight = 20;
            float padding = 5;
            container.Add(new CuiPanel() {
                RectTransform = {
                    AnchorMin = "0 0", AnchorMax = "1 1"
                }
                , Image = {
                    Color = "0 0 0 0"
                }
            }
            , InitialLayer + ".R", InitialLayer + ".MenuInfo");
            container.Add(new CuiElement {
                Parent = InitialLayer + ".MenuInfo", Components = {
                    new CuiTextComponent {
                        Color = "0.929 0.882 0.847 0.7", Text = choosed.Title.ToUpper(), Align = TextAnchor.LowerCenter , FontSize = 20
                    }
                    , new CuiRectTransformComponent {
                        AnchorMin = "0 1", AnchorMax = "1 1.2"
                    }
                }
            }
            );
            foreach (var point in config.menuUISettings.PointsList) {
                CuiHelper.DestroyUi(player, InitialLayer + config.menuUISettings.PointsList.IndexOf(point));
                string color = point == choosed ? "0.929 0.882 0.847 1" : "0.929 0.882 0.847 0.2";
                float elementHeight = point.DisplayName.Length > 0 ? originalHeight : freeHeight;
                container.Add(new CuiButton {
                    RectTransform = {
                        AnchorMin = "0 1", AnchorMax = "0 1", OffsetMin = $"50 {marginTop - elementHeight}", OffsetMax = $"250 {marginTop}"
                    }
                    , Button = {
                        Command = point == choosed ? "" : $"UI_Batia menu {config.menuUISettings.PointsList.IndexOf(point)}", Color = "0 0 0 0"
                    }
                    , Text = {
                        Text = point.DisplayName, Align = TextAnchor.MiddleCenter, Font = "robotocondensed-bold.ttf", FontSize = 14, Color = color
                    }
                }
                , "SubMenu_UI", InitialLayer + config.menuUISettings.PointsList.IndexOf(point));
                container.Add(new CuiElement {
                    Parent = InitialLayer + config.menuUISettings.PointsList.IndexOf(point), Components = {
                        new CuiRawImageComponent {
                            Png = (string) ImageLibrary.Call("GetImage", "white"),
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = "0 0", AnchorMax = "1 1"
                        }
                        ,
                    }
                }
                );
                marginTop -= elementHeight + padding;
            }
            CuiHelper.DestroyUi(player, InitialLayer + ".MenuInfo");
            CuiHelper.AddUi(player, container);
            player.SendConsoleCommand(choosed.DrawMethod);
        }
        [ConsoleCommand("UI_Batia")]
        void cmdMenuBatia(ConsoleSystem.Arg args) {
            var player = args.Player();
            if (player == null) return;
            if (!args.HasArgs(1)) return;
            switch (args.Args[0]) {
                case "menu" : int chooseIndex = -1;
                if (!int.TryParse(args.Args[1], out chooseIndex)) return;
                var chooseElement = config.menuUISettings.PointsList.ElementAtOrDefault(chooseIndex);
                if (chooseElement == null) return;
                DrawMenuPoints(player, chooseElement);
                break;
                case "bottle" : CreateBottleExchange(player);
                break;
                case "info" : CreateInfo(player);
                break;
                case "artefacts" : ShowTOPArtefacts(player);
                break;
                case "takeArt" : if (ArtefactsList.Count >= config.artefactsSettings.MaxCount) return;
                if (ArtefactsList.Contains(player.userID)) return;
                if (string.IsNullOrEmpty(config.gameStoresSettings.Secret) || string.IsNullOrEmpty(config.gameStoresSettings.ShopID)) {
                    SendReply(player, $"<color=#EDE1D8>Ошибка пополнения, обратитесь к администратору</color>");
                    return;
                }
                if (TakeItems(player)) {
                    APIChangeUserBalance(player.userID, config.artefactsSettings.Summ, null);
                    SendReply(player, $"<size=12><color=#EDE1D8>Вы успешно обменяли Нюка Колу на {config.artefactsSettings.Summ} рублей баланса в премиум магазине.</color></size>");
                    ArtefactsList.Add(player.userID);
                    ShowTOPArtefacts(player);
                }
                else SendReply(player, $"<size=12><color=#EDE1D8>У вас не хватает Нюка Колы для обмена!</color></size>");
                break;
                case "givepackage" : if (!com.EndExpeditions.ContainsKey(player.userID)) {
                    Puts("123");
                    return;
                }
                var component = com.EndExpeditions[player.userID];
                if (component < 20) return;
                if (component >= 20 && component < 40) SendPackage(player, 20);
                if (component >= 40 && component < 60) SendPackage(player, 40);
                if (component >= 60 && component < 80) SendPackage(player, 60);
                if (component >= 80 && component < 90) SendPackage(player, 80);
                if (component >= 90) SendPackage(player, 100);
                break;
                case "expedition" : int page;
                if (!int.TryParse(args.Args[1], out page)) page = 0;
                CreateInfoJson(player, page);
                break;
                case "startLoot" : CuiHelper.DestroyUi(player, "Main_UI");
                ExpeditionExceptionBox box = ExpeditionExceptionBox.Spawn(player);
                box.StartLoot();
                break;
                case "sendLoot" : player.Command("chat.say /tech");
                var entityLoot = player.inventory.loot;
                if (entityLoot == null || entityLoot.entitySource.GetComponent<ExpeditionExceptionBox>() == null) return;
                if (entityLoot.entitySource.GetComponent<ExpeditionExceptionBox>().PoitsInvectoryCount() < 20) return;
                entityLoot.entitySource.GetComponent<ExpeditionExceptionBox>().Close();
                break;
                case "buy" : chooseIndex = -1;
                if (!int.TryParse(args.Args[1], out chooseIndex)) return;
                var buyItem = config.bottleSetting.CustomItemsShop.ElementAtOrDefault(chooseIndex);
                if (buyItem == null) return;
                if ((double)Economics.Call("Balance", player.userID) < buyItem.NeedGold) return;
                Economics.Call("SetBalance", player.UserIDString, (double) Economics.Call("Balance", player.UserIDString) - buyItem.NeedGold);
                BMenu.Call("UpdateBalance", player);
                if (buyItem.Command.Count > 0) {
                    foreach (var command in buyItem.Command) {
                        Server.Command(command.Replace("%STEAMID%", player.UserIDString));
                    }
                    SendReply(player, $"<size=12>Вы приобрели <color=#B1D6F1>{buyItem.Title}</color> за {buyItem.NeedGold} RP.</size>");
                }
                if (!string.IsNullOrEmpty(buyItem.defaultItem.ShortName)) {
                    var giveItem = ItemManager.CreateByName(buyItem.defaultItem.ShortName, buyItem.defaultItem.MinAmount, buyItem.defaultItem.SkinID);
                    player.GiveItem(giveItem, BaseEntity.GiveItemReason.Generic);
                    SendReply(player, $"<size=12>Вы приобрели <color=#B1D6F1>{buyItem.Title}</color> за {buyItem.NeedGold} RP.</size>");
                }
                DrawMenuPoints(player, config.menuUISettings.PointsList[0]);
                break;
                case "close" : if (com != null && com.OpenInterface.Contains(player)) com.OpenInterface.Remove(player);
                CuiHelper.DestroyUi(player, External);
                CuiHelper.DestroyUi(player, "UI_Batia_External" + ".Mood1" + ".panel");
                break;
            }
        }
        void APIChangeUserBalance(ulong steam, int balanceChange, Action<int> callback) {
            AddMoney(steam, (float)balanceChange, "Batia API", new Action<int>((result) => {
                if (result > 0) {
                    LogToFile("logWEB", $"({DateTime.Now.ToShortTimeString()}): Отправлен запрос пользователем {steam} на пополнение баланса в размере: {balanceChange}", this);
                    callback(result);
                    return;
                }
                LogToFile("logError", $"({DateTime.Now.ToShortTimeString()}): Баланс ИГРОКА {steam} не был изменен, ошибка: {result}", this);
                callback(0);
            }
            ));
        }
        public static Batia ins;
        private PluginConfig config;
        protected override void LoadDefaultConfig() {
            PrintWarning("!");
            config = PluginConfig.DefaultConfig();
        }
        protected override void LoadConfig() {
            base.LoadConfig();
            config = Config.ReadObject<PluginConfig>();
            if (config.PluginVersion < Version) UpdateConfigValues();
            Config.WriteObject(config, true);
        }
        private void UpdateConfigValues() {
            PluginConfig baseConfig = PluginConfig.DefaultConfig();
            if (config.PluginVersion < new VersionNumber(1, 0, 1)) {
                PrintWarning("Config update detected! Updating config values...");
                config.artefactsSettings.ItemsAdded = new List<ArtefactsItems>() {
                    new ArtefactsItems() {
                        ShortName = "blood", SkinID = 2248214689, ImageURL = "https://i.imgur.com/sBCgt6B.png"
                    }
                    , new ArtefactsItems() {
                        ShortName = "blood", SkinID = 2248217143, ImageURL = "https://i.imgur.com/zrqGMpn.png"
                    }
                    , new ArtefactsItems() {
                        ShortName = "blood", SkinID = 2248119385, ImageURL = "https://i.imgur.com/aqM4efr.png"
                    }
                    , new ArtefactsItems() {
                        ShortName = "blood", SkinID = 2248218154, ImageURL = "https://i.imgur.com/Fa1AFUe.png"
                    }
                    , new ArtefactsItems() {
                        ShortName = "blood", SkinID = 2248215784, ImageURL = "https://i.imgur.com/9s2QJLT.png"
                    }
                    , new ArtefactsItems() {
                        ShortName = "blood", SkinID = 2248216305, ImageURL = "https://i.imgur.com/46sJWQU.png"
                    }
                }
                ;
                PrintWarning("Config update completed!");
            }
            config.PluginVersion = Version;
        }
        protected override void SaveConfig() {
            Config.WriteObject(config);
        }
        public class MenuUISettings {
            [JsonProperty("Пункты меню")]
            public List<MenuPoints> PointsList = new List<MenuPoints>();
            [JsonProperty("Основная информация")]
            public string MainInformation = "Основная информация о бате:";
            [JsonProperty("Дополнительная информация")]
            public string AdditionalInformation = "Дополнительная информация";
        }
        public class MenuPoints {
            [JsonProperty("Название пункта меню в UI")]
            public string DisplayName;
            [JsonProperty("Выполняемая команда")]
            public string DrawMethod;
            [JsonProperty("Титл страницы")]
            public string Title;
        }
        public class GameStoresSettings {
            [JsonProperty("Gamestores ShopID")]
            public string ShopID = "";
            [JsonProperty("Gamestores SecretKey")]
            public string Secret = "";
        }
        private void AddMoney(ulong userId, float amount, string mess, Action<int> callback) {
            ExecuteApiRequest(new Dictionary<string, string>() {
                {
                    "action", "moneys"
                }
                , {
                    "type", "plus"
                }
                , {
                    "steam_id", userId.ToString()
                }
                , {
                    "amount", amount.ToString()
                }
                , {
                    "mess", mess
                }
            }
            , callback);
        }
        private void ExecuteApiRequest(Dictionary<string, string> args, Action<int> callback) {
            if (string.IsNullOrEmpty(config.gameStoresSettings.Secret) || string.IsNullOrEmpty(config.gameStoresSettings.ShopID)) {
                callback(0);
                return;
    
// ... [Code preview truncated due to length. Full source in attached file] ...

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