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

FREE TPSkinMenu : 5.0.0 5.0.0

Нет прав для скачивания
C#:
// Все права принадлежат дискорд сообществу https://discord.gg/VgNHPpNrz6
using System;
using Newtonsoft.Json;
using UnityEngine;
using System.Linq;
using Oxide.Game.Rust.Cui;
using Oxide.Core;
using System.Collections.Generic;
using System.Collections;
using Oxide.Core.Plugins;
namespace Oxide.Plugins {
    [Info("TPSkinMenu", "Sempai#3239", "5.0.0")]
    class TPSkinMenu : RustPlugin {
        private void SetSkinTransport(BasePlayer player, BaseVehicle vehicle, string shortname) {
            ulong skin = StoredData[player.userID].Skins[shortname];
            if(skin == vehicle.skinID || skin == 0) return;
            if(errorskins.ContainsKey(skin)) shortname = errorskins[skin];
            if(errorshortnames.ContainsKey(shortname)) shortname = errorshortnames[shortname];
            BaseVehicle transport = GameManager.server.CreateEntity($"assets/content/vehicles/snowmobiles/{shortname}.prefab", vehicle.transform.position, vehicle.transform.rotation) as BaseVehicle;
            transport.health = vehicle.health;
            transport.skinID = skin;
            vehicle.Kill();
            transport.Spawn();
            Effect.server.Run("assets/prefabs/deployable/repair bench/effects/skinchange_spraypaint.prefab", transport.transform.localPosition);
        }
        protected override void LoadConfig() {
            base.LoadConfig();
            try {
                config = Config.ReadObject<SkinConfig>();
            }
            catch {
                PrintWarning("Ошибка чтения конфигурации! Создание дефолтной конфигурации!");
                LoadDefaultConfig();
            }
            SaveConfig();
        }
        private void SaveData(BasePlayer player) {
            ulong userID = player.userID;
            if(StoredData.ContainsKey(userID)) Interface.Oxide.DataFileSystem.WriteObject($"XDataSystem/XSkinMenu/UserSettings/{userID}", StoredData[userID]);
        }
        private void OnPlayerDisconnected(BasePlayer player) {
            if(StoredData.ContainsKey(player.userID)) {
                SaveData(player);
                StoredData.Remove(player.userID);
            }
            if(Cooldowns.ContainsKey(player)) Cooldowns.Remove(player);
        }
        [ConsoleCommand("skin_c")]
        private void ccmdCategoryS(ConsoleSystem.Arg args) {
            BasePlayer player = args.Player();
            if(!permission.UserHasPermission(player.UserIDString, "xskinmenu.use")) {
                SendReply(player, lang.GetMessage("NOPERM", this, player.UserIDString));
                return;
            }
            if(Cooldowns.ContainsKey(player)) if(Cooldowns[player].Subtract(DateTime.Now).TotalSeconds >= 0) return;
            Effect x = new Effect("assets/bundled/prefabs/fx/notice/loot.drag.grab.fx.prefab", player, 0, new Vector3(), new Vector3());
            Effect z = new Effect("assets/bundled/prefabs/fx/weapons/survey_charge/survey_charge_stick.prefab", player, 0, new Vector3(), new Vector3());
            switch(args.Args[0]) {
                case "category" : {
                    CategoryGUI(player, int.Parse(args.Args[2]));
                    ItemGUI(player, args.Args[1]);
                    EffectNetwork.Send(x, player.Connection);
                    Cooldowns[player] = DateTime.Now.AddSeconds(0.5f);
                    break;
                }
                case "skin" : {
                    SkinGUI(player, args.Args[1]);
                    EffectNetwork.Send(x, player.Connection);
                    CuiHelper.DestroyUi(player, ".ItemGUI");
                    Cooldowns[player] = DateTime.Now.AddSeconds(0.5f);
                    break;
                }
                case "setskin" : {
                    string item = args.Args[1];
                    ulong skin = ulong.Parse(args.Args[2]);
                    if(!permission.UserHasPermission(player.UserIDString, "xskinmenu.skinchange") || !StoredData[player.userID].Skins.ContainsKey(item)) return;
                    Effect y = new Effect("assets/prefabs/deployable/repair bench/effects/skinchange_spraypaint.prefab", player, 0, new Vector3(), new Vector3());
                    StoredData[player.userID].Skins[item] = skin;
                    if(!permission.UserHasPermission(player.UserIDString, "xskinmenu.inventory")) SendReply(player, lang.GetMessage("NOPERM", this, player.UserIDString));
                    else {
                        if(StoredData[player.userID].ChangeSI) SetSkinItem(player, item, skin);
                        if(config.GUI.SkinUP) SkinGUI(player, item, int.Parse(args.Args[3]));
                    }
                    EffectNetwork.Send(y, player.Connection);
                    Cooldowns[player] = DateTime.Now.AddSeconds(1.5f);
                    // Здесь не трогать!!! =)
                    break;
                }
                case "clear" : {
                    if(!permission.UserHasPermission(player.UserIDString, "xskinmenu.skinchange")) return;
                    string item = args.Args[1];
                    StoredData[player.userID].Skins[item] = 0;
                    CuiHelper.DestroyUi(player, $".I + {args.Args[2]}");
                    if(StoredData[player.userID].ChangeSCL) SetSkinItem(player, item, 0);
                    if(config.GUI.MainSkin) ItemGUI(player, args.Args[3], int.Parse(args.Args[4]));
                    EffectNetwork.Send(z, player.Connection);
                    Cooldowns[player] = DateTime.Now.AddSeconds(0.5f);
                    break;
                }
                case "clearall" : {
                    if(!permission.UserHasPermission(player.UserIDString, "xskinmenu.skinchange")) return;
                    StoredData[player.userID].Skins.Clear();
                    foreach(var skin in StoredDataSkins) StoredData[player.userID].Skins.Add(skin.Key, 0);
                    GUI(player);
                    EffectNetwork.Send(z, player.Connection);
                    Cooldowns[player] = DateTime.Now.AddSeconds(2.5f);
                    break;
                }
            }
        }
        [ConsoleCommand("skinimage_reload")]
        private void ccmdReloadIMG(ConsoleSystem.Arg args) {
            if(args.Player() == null || args.Player().IsAdmin) {
                if(config.API.GameIMG) {
                    PrintError("COMMAND_OFF");
                    return;
                }
                if(_coroutine == null) _coroutine = ServerMgr.Instance.StartCoroutine(ReloadImage());
                else PrintWarning("Загрузка/перезагрузка изображений продолжается.Подождите!");
            }
        }
        private void CategoryGUI(BasePlayer player, int page = 0) {
            CuiHelper.DestroyUi(player, ".SkinBUTTON");
            CuiElementContainer container = new CuiElementContainer();
            container.Add(new CuiPanel {
                RectTransform = {
                    AnchorMin = "0.25 0.65", AnchorMax = "0.75 0.73", OffsetMax = "0 0"
                }
                , Image = {
                    Color = "0 0 0 0"
                }
            }
            , ".SGUI", ".SkinBUTTON");
            int x = 0, count = config.Category.Count;
            foreach(var category in config.Category) {
                string color = page == x ? config.GUI.ActiveColor : config.GUI.InactiveColor;
                double offset = -(50 * count--) + -(2.5 * count--);
                var amin = x == 0 ? "0.027 0.33" : x == 1 ? "0.162 0.33" : x == 2 ? "0.354 0.33" : x == 3 ? "0.506 0.33" : x == 4 ? "0.645 0.33" : "0.825 0.33";
                var amax = x == 0 ? "0.146 0.75" : x == 1 ? "0.34 0.75" : x == 2 ? "0.491 0.75" : x == 3 ? "0.63 0.75" : x == 4 ? "0.813 0.75" : "0.98 0.75";
                container.Add(new CuiButton {
                    RectTransform = {
                        AnchorMin = $"{amin}", AnchorMax = $"{amax}", OffsetMax = "0 0"
                    }
                    , Button = {
                        Color = "0 0 0 0", Command = $"skin_c category {category.Key} {x}"
                    }
                    , Text = {
                        Text = $"       {lang.GetMessage(category.Key, this, player.UserIDString)}", Align = TextAnchor.MiddleCenter, Font = "robotocondensed-regular.ttf", FontSize = 11, Color = "0.7507126 0.7507126 0.7507126 1"
                    }
                }
                , ".SkinBUTTON", ".BUTTON");
                container.Add(new CuiPanel {
                    RectTransform = {
                        AnchorMin = "0.06 0", AnchorMax = "0.92 0", OffsetMax = "0 1.5"
                    }
                    , Image = {
                        Color = color, Material = "assets/icons/greyout.mat"
                    }
                }
                , ".BUTTON");
                x++;
            }
            CuiHelper.AddUi(player, container);
        }
        [ConsoleCommand("xskin")]
        private void ccmdAdmin(ConsoleSystem.Arg args) {
            if(args.Player() == null || args.Player().IsAdmin) {
                string item = args.Args[1];
                if(!StoredDataSkins.ContainsKey(item)) {
                    PrintWarning($"Не найдено предмета <{item}> в списке!");
                    return;
                }
                switch(args.Args[0]) {
                    case "add" : {
                        ulong skinID = ulong.Parse(args.Args[2]);
                        if(StoredDataSkins[item].Contains(skinID)) PrintWarning($"Скин <{skinID}> уже есть в списке скинов предмета <{item}>!");
                        else {
                            StoredDataSkins[item].Add(skinID);
                            PrintWarning($"Скин <{skinID}> успешно добавлен в список скинов предмета <{item}>!");
                            if(!config.API.GameIMG) {
                                if(config.API.APIOption) ImageLibrary.Call("AddImage", $"http://api.skyplugins.ru/api/getskin/{skinID}/{150}", $"{skinID}" + 152);
                                else ImageLibrary.Call("AddImage", $"https://api.skyplugins.ru/api/getskin/v1/08102261/{skinID}/150", $"{skinID}" + 152);
                            }
                        }
                        break;
                    }
                    case "remove" : {
                        ulong skinID = ulong.Parse(args.Args[2]);
                        if(StoredDataSkins[item].Contains(skinID)) {
                            StoredDataSkins[item].Remove(skinID);
                            PrintWarning($"Скин <{skinID}> успешно удален из списка скинов предмета <{item}>!");
                        }
                        else PrintWarning($"Скин <{skinID}> не найден в списке скинов предмета <{item}>!");
                        break;
                    }
                    case "remove_ui" : {
                        ulong skinID = ulong.Parse(args.Args[2]);
                        if(StoredDataSkins[item].Contains(skinID)) {
                            BasePlayer player = args.Player();
                            if(player != null) {
                                StoredDataSkins[item].Remove(skinID);
                                if(config.GUI.DelSkinUP) SkinGUI(player, item, int.Parse(args.Args[3]));
                                EffectNetwork.Send(new Effect("assets/bundled/prefabs/fx/weapons/survey_charge/survey_charge_stick.prefab", player, 0, new Vector3(), new Vector3()), player.Connection);
                                PrintWarning($"Скин <{skinID}> успешно удален из списка скинов предмета <{item}>!");
                            }
                        }
                        else PrintWarning($"Скин <{skinID}> не найден в списке скинов предмета <{item}>!");
                        break;
                    }
                    case "list" : {
                        if(StoredDataSkins[item].Count == 0) {
                            PrintWarning($"Список скинов предмета <{item}> пуст!");
                            return;
                        }
                        string skinslist = $"Список скинов предмета <{item}>:\n";
                        foreach(ulong skinID in StoredDataSkins[item]) skinslist += $"\n{skinID}";
                        PrintWarning(skinslist);
                        break;
                    }
                    case "clearlist" : {
                        if(StoredDataSkins[item].Count == 0) {
                            PrintWarning($"Список скинов предмета <{item}> уже пуст!");
                            return;
                        }
                        else {
                            StoredDataSkins[item].Clear();
                            PrintWarning($"Список скинов предмета <{item}> успешно очищен!");
                        }
                        break;
                    }
                }
                Interface.Oxide.DataFileSystem.WriteObject("XDataSystem/XSkinMenu/Skins", StoredDataSkins);
            }
        }
        private void OnServerInitialized() {
            /*PrintWarning("\n-----------------------------\n" +
			"     Author - Sempai\n" +
			"     VK - vk.com/rustnastroika\n" + 
			"     Discord - Sempai#3239\n" +
			"     Config - v.7126\n" + 
			"-----------------------------"); */
            if(Interface.Oxide.DataFileSystem.ExistsDatafile("XDataSystem/XSkinMenu/Friends")) StoredDataFriends = Interface.Oxide.DataFileSystem.ReadObject<Dictionary<ulong, bool>>("XDataSystem/XSkinMenu/Friends");
            if(Interface.Oxide.DataFileSystem.ExistsDatafile("XDataSystem/XSkinMenu/Skins")) StoredDataSkins = Interface.Oxide.DataFileSystem.ReadObject<Dictionary<string, List<ulong>>>("XDataSystem/XSkinMenu/Skins");
            if(!config.API.GameIMG && _coroutine == null && ImageLibrary) _coroutine = ServerMgr.Instance.StartCoroutine(LoadImage());
            foreach(var items in config.Category) foreach(var item in items.Value) {
                string key = item.Key;
                _items.Add(key, item.Value);
                _itemsId.Add(key, ItemManager.FindItemDefinition(key).itemid);
            }
            foreach(var item in ItemManager.GetItemDefinitions()) {
                var prefab = item.GetComponent<ItemModDeployable>()?.entityPrefab?.resourcePath;
                if(string.IsNullOrEmpty(prefab)) continue;
                var shortPrefabName = Utility.GetFileNameWithoutExtension(prefab);
                if(!string.IsNullOrEmpty(shortPrefabName) && !_shortnamesEntity.ContainsKey(shortPrefabName)) _shortnamesEntity.Add(shortPrefabName, item.shortname);
            }
            GenerateItems();
            BasePlayer.activePlayerList.ToList().ForEach(OnPlayerConnected);
            timer.Every(180, () => BasePlayer.activePlayerList.ToList().ForEach(SaveData));
            timer.Every(200, () => Interface.Oxide.DataFileSystem.WriteObject("XDataSystem/XSkinMenu/Friends", StoredDataFriends));
            InitializeLang();
            permission.RegisterPermission("xskinmenu.use", this);
            permission.RegisterPermission("xskinmenu.setting", this);
            permission.RegisterPermission("xskinmenu.craft", this);
            permission.RegisterPermission("xskinmenu.entity", this);
            permission.RegisterPermission("xskinmenu.inventory", this);
            permission.RegisterPermission("xskinmenu.give", this);
            permission.RegisterPermission("xskinmenu.skinchange", this);
            if(!config.API.GameIMG && !ImageLibrary) timer.Once(2, () => {
                PrintError("У вас не установлен плагин - ImageLibrary!");
                Interface.Oxide.UnloadPlugin(Name);
            }
            );
            ImageLibrary.Call("AddImage", "https://imgur.com/HZAn2Et.png", "HZAn2Et");
            ImageLibrary.Call("AddImage", "https://imgur.com/76unpVI.png", "76unpVI");
            ImageLibrary.Call("AddImage", "https://imgur.com/QJ1ZV1G.png", "QJ1ZV1G");
        }
        private readonly Dictionary<string, string> _shortnamesEntity = new Dictionary<string, string>();
        private void SetSkinItem(BasePlayer player, string item, ulong skin) {
            foreach(var i in player.inventory.FindItemsByItemID(ItemManager.FindItemDefinition(item).itemid)) {
                if(i.skin == skin || config.Setting.Blacklist.Contains(i.skin)) continue;
                if(errorskins.ContainsKey(skin)) {
                    i.UseItem();
                    Item newitem = ItemManager.CreateByName(errorskins[skin]);
                    newitem.condition = i.condition;
                    newitem.maxCondition = i.maxCondition;
                    if(i.contents != null) foreach(var module in i.contents.itemList) {
                        Item content = ItemManager.CreateByName(module.info.shortname, module.amount);
                        content.condition = module.condition;
                        content.maxCondition = module.maxCondition;
                        content.MoveToContainer(newitem.contents);
                    }
                    player.GiveItem(newitem);
                }
                else {
                    i.skin = skin;
                    i.MarkDirty();
                    BaseEntity entity = i.GetHeldEntity();
                    if(entity != null) {
                        entity.skinID = skin;
                        entity.SendNetworkUpdate();
                    }
                }
            }
        }
        private IEnumerator ReloadImage() {
            int x = 0, y = 0, xx = 0, yy = 0;
            PrintWarning("Началась перезагрузка изображений категорий!");
            foreach(var category in config.Category) {
                foreach(var item in category.Value) {
                    ImageLibrary.Call("AddImage", $"http://api.skyplugins.ru/api/getimage/{item.Key}/{150}", item.Key + 150);
                    y++;
                    yield return CoroutineEx.waitForSeconds(0.3f);
                }
                x++;
                if(config.Setting.LogReloadIMG) PrintWarning($"[ Перезагружена категория {x} из {config.Category.Count} ] - [ Перезагружено изображений категории {y} из {category.Value.Count} ]");
                y = 0;
            }
            PrintWarning("Началась перезагрузка изображений скинов!");
            foreach(var item in StoredDataSkins) {
                foreach(var skin in item.Value) {
                    if(config.API.APIOption) ImageLibrary.Call("AddImage", $"http://api.skyplugins.ru/api/getskin/{skin}/{150}", $"{skin}" + 152);
                    else ImageLibrary.Call("AddImage", $"https://api.skyplugins.ru/api/getskin/v1/08102261/{skin}/150", $"{skin}" + 152);
                    yy++;
                    yield return CoroutineEx.waitForSeconds(0.3f);
                }
                xx++;
                if(config.Setting.LogReloadIMG) PrintWarning($"[ Перезагружен предмет {item.Key} | {xx} из {StoredDataSkins.Count} ] - [ Перезагружено изображений скинов {yy} из {item.Value.Count} ]");
                yy = 0;
            }
            PrintWarning("\n-----------------------------\n" + "     Перезагрузка всех изображений завершена.\n" + "-----------------------------");
            _coroutine = null;
            yield return 0;
        }
        private void SkinGUI(BasePlayer player, string item, int Page = 0) {
            CuiHelper.DestroyUi(player, ".SkinGUI");
            CuiElementContainer container = new CuiElementContainer();
            container.Add(new CuiPanel {
                RectTransform = {
                    AnchorMin = "0.26 0.23", AnchorMax = "0.744 0.67", OffsetMax = "0 0"
                }
                , Image = {
                    Color = "0 0 0 0"
                }
            }
            , ".SGUI", ".SkinGUI");
            ulong s = StoredData[player.userID].Skins[item];
            int itemid = _itemsId[item];
            float width = 0.108f, height = 0.21f, startxBox = 0.02f, startyBox = 0.963f - height, xmin = startxBox, ymin = startyBox;
            foreach(var skin in StoredDataSkins[item].Skip(Page * 32).Take(32)) {
                container.Add(new CuiPanel {
                    RectTransform = {
                        AnchorMin = xmin + " " + ymin, AnchorMax = (xmin + width) + " " + (ymin + height * 1), OffsetMax = "0 0"
                    }
                    , Image = {
                        Color = "0 0 0 0", Material = "assets/icons/greyout.mat"
                    }
                }
                , ".SkinGUI", ".Skin");
                container.Add(new CuiPanel {
                    RectTransform = {
                        AnchorMin = "0.1 0", AnchorMax = "0.9 0.02", OffsetMax = "0 0"
                    }
                    , Image = {
                        Color = s == skin ? config.GUI.ActiveBlockColor : "0 0 0 0"
                    }
                }
                , ".Skin");
                if(config.API.GameIMG) container.Add(new CuiElement {
                    Parent = ".Skin", Components = {
                        new CuiImageComponent {
                            ItemId = itemid, SkinId = skin
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = "0 0", AnchorMax = "1 1", OffsetMin = "12 12", OffsetMax = "-12 -12"
                        }
                    }
                }
                );
                else container.Add(new CuiElement {
                    Parent = ".Skin", Components = {
                        new CuiRawImageComponent {
                            Png = (string) ImageLibrary.Call("GetImage", $"{skin}152")
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = "0 0", AnchorMax = "1 1", OffsetMin = "12 12", OffsetMax = "-12 -12"
                        }
                    }
                }
                );
                container.Add(new CuiButton {
                    RectTransform = {
                        AnchorMin = "0 0", AnchorMax = "1 1", OffsetMax = "0 0"
                    }
                    , Button = {
                        Color = "0 0 0 0", Command = $"skin_c setskin {item} {skin} {Page}"
                    }
                    , Text = {
                        Text = ""
                    }
                }
                , ".Skin");
                if(config.Setting.DeleteButton && player.IsAdmin) container.Add(new CuiButton {
                    RectTransform = {
                        AnchorMin = "1 0", AnchorMax = "1 0", OffsetMin = "-20 5", OffsetMax = "-5 20"
                    }
                    , Button = {
                        Color = "1 1 1 0.7507126", Sprite = "assets/icons/clear.png", Command = $"xskin remove_ui {item} {skin} {Page}"
                    }
                    , Text = {
                        Text = ""
                    }
                }
                , ".Skin");
                xmin += width + 0.0135f;
                if (xmin + width >= 1) {
                    xmin = startxBox;
                    ymin -= height + 0.03f;
                }
            }
            bool back = Page != 0;
            bool next = StoredDataSkins[item].Count > ((Page + 1) * 32);
            container.Add(new CuiButton {
                RectTransform = {
                    AnchorMin = "-0.075 0.355", AnchorMax = "-0.01 0.635", OffsetMax = "0 0"
                }
                , Button = {
                    Color = "0 0 0 0", Command = back ? $"page.xskinmenu skin back {item} {Page}" : ""
                }
                , Text = {
                    Text = ""
                }
            }
            , ".SkinGUI");
            container.Add(new CuiButton {
                RectTransform = {
                    AnchorMin = "1.005 0.355", AnchorMax = "1.075 0.635", OffsetMax = "0 0"
                }
                , Button = {
                    Color = "0 0 0 0", Command = next ? $"page.xskinmenu skin next {item} {Page}" : ""
                }
                , Text = {
                    Text = ""
                }
            }
            , ".SkinGUI");
            CuiHelper.AddUi(player, container);
        }
        private void OnPlayerConnected(BasePlayer player) {
            if(player.IsReceivingSnapshot) {
                NextTick(() => OnPlayerConnected(player));
                return;
            }
            LoadData(player);
        }
        private void ItemGUI(BasePlayer player, string category, int Page = 0) {
            CuiHelper.DestroyUi(player, ".SettingGUI");
            CuiHelper.DestroyUi(player, ".SkinGUI");
            CuiHelper.DestroyUi(player, ".ItemGUI");
            CuiElementContainer container = new CuiElementContainer();
            container.Add(new CuiPanel {
                RectTransform = {
                    AnchorMin = "0.26 0.23", AnchorMax = "0.744 0.67", OffsetMax = "0 0"
                }
                , Image = {
                    Color = "0 0 0 0"
                }
            }
            , ".SGUI", ".ItemGUI");
            var player_data = StoredData[player.userID].Skins;
            int z = 0;
            float width = 0.108f, height = 0.21f, startxBox = 0.02f, startyBox = 0.963f - height, xmin = startxBox, ymin = startyBox;
            foreach(var item in config.Category[category].Skip(Page * 32).Take(32)) {
                string key = item.Key;
                bool c = player_data.ContainsKey(key);
                ulong skinID = c ? player_data[key] : 0;
                bool s = skinID != 0;
                int itemid = _itemsId[key];
                container.Add(new CuiPanel {
                    RectTransform = {
                        AnchorMin = xmin + " " + ymin, AnchorMax = (xmin + width) + " " + (ymin + height * 1), OffsetMax = "0 0"
                    }
                    , Image = {
                        Color = "0 0 0 0"
                    }
                }
                , ".ItemGUI", ".Item");
                if(config.API.GameIMG) container.Add(new CuiElement {
                    Parent = ".Item", Components = {
                        new CuiImageComponent {
                            ItemId = itemid, SkinId = config.GUI.MainSkin ? skinID : 0
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = "0 0", AnchorMax = "1 1", OffsetMin = "12 12", OffsetMax = "-12 -12"
                        }
                    }
                }
                );
                else container.Add(new CuiElement {
                    Parent = ".Item", Components = {
                        new CuiRawImageComponent {
                            Png = (string) ImageLibrary.Call("GetImage", config.GUI.MainSkin && c && s ? $"{skinID}152" : key + 150)
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = "0 0", AnchorMax = "1 1", OffsetMin = "12 12", OffsetMax = "-12 -12"
                        }
                    }
                }
                );
                if(StoredDataSkins.ContainsKey(key) && StoredDataSkins[key].Count != 0 && c) {
                    container.Add(new CuiButton {
                        RectTransform = {
                            AnchorMin = "0 0", AnchorMax = "1 1", OffsetMax = "0 0"
                        }
                        , Button = {
                            Color = "0 0 0 0", Command = $"skin_c skin {key}"
                        }
                        , Text = {
                            Text = ""
                        }
                    }
                    , ".Item");
                    if(s) container.Add(new CuiButton {
                        RectTransform = {
                            AnchorMin = "1 0", AnchorMax = "1 0", OffsetMin = "-20 5", OffsetMax = "-5 20"
                        }
                        , Button = {
                            Color = "1 1 1 0.75", Sprite = "assets/icons/clear.png", Command = $"skin_c clear {key} {z} {category} {Page}"
                        }
                        , Text = {
                            Text = ""
                        }
                    }
                    , ".Item", $".I + {z}");
                }
                z++;
                xmin += width + 0.0135f;
                if (xmin + width >= 1) {
                    xmin = startxBox;
                    ymin -= height + 0.03f;
                }
            }
            bool back = Page != 0;
            bool next = config.Category[category].Count > ((Page + 1) * 32);
            container.Add(new CuiButton {
                RectTransform = {
                    AnchorMin = "-0.075 0.355", AnchorMax = "-0.01 0.635", OffsetMax = "0 0"
                }
                , Button = {
                    Color = "0 0 0 0", Command = back ? $"page.xskinmenu item back {category} {Page}" : ""
                }
                , Text = {
                    Text = ""
                }
            }
            , ".ItemGUI");
            container.Add(new CuiButton {
                RectTransform = {
                    AnchorMin = "1.005 0.355", AnchorMax = "1.075 0.635", OffsetMax = "0 0"
                }
                , Button = {
                    Color = "0 0 0 0", Command = next ? $"page.xskinmenu item next {category} {Page}" : ""
                }
                , Text = {
                    Text = ""
                }
            }
            , ".ItemGUI");
            if(config.Setting.ButtonClear) {
                container.Add(new CuiPanel {
                    RectTransform = {
                        AnchorMin = "0.51 -0.1", AnchorMax = "0.84 -0.02", OffsetMax = "0 0"
                    }
                    , Image = {
                        Color = "0 0 0 0"
                    }
                }
                , ".ItemGUI", "Image");
                container.Add(new CuiElement {
                    Parent = "Image", Components = {
                        new CuiRawImageComponent {
                            Png = (string) ImageLibrary.Call("GetImage", "76unpVI")
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = "0 0", AnchorMax = "1 1", OffsetMax = "0 0"
                        }
                    }
                }
                );
                container.Add(new CuiButton {
                    RectTransform = {
                        AnchorMin = "0 0", AnchorMax = "1 1", OffsetMax = "0 0"
                    }
                    , Button = {
                        Color = "0 0 0 0", Command = "skin_c clearall"
                    }
                    , Text = {
                        Text = $"      {lang.GetMessage("CLEARALL", this, player.UserIDString)}", Align = TextAnchor.MiddleCenter, FontSize = 11, Font = "robotocondensed-regular.ttf", Color = "1 1 1 1"
                    }
                }
                , "Image");
            }
            CuiHelper.AddUi(player, container);
        }
        [ConsoleCommand("page.xskinmenu")]
        private void ccmdPage(ConsoleSystem.Arg args) {
            BasePlayer player = args.Player();
            Effect x = new Effect("assets/bundled/prefabs/fx/notice/loot.drag.grab.fx.prefab", player, 0, new Vector3(), new Vector3());
            string item = args.Args[2];
            int Page = int.Parse(args.Args[3]);
            switch (args.Args[0]) {
                case "item" : {
                    switch(args.Args[1]) {
                        case "next" : {
                            ItemGUI(player, item, Page + 1);
                            break;
                        }
                        case "back" : {
                            ItemGUI(player, item, Page - 1);
                            break;
                        }
                    }
                    break;
                }
                case "skin" : {
                    switch(args.Args[1]) {
                        case "next" : {
                            SkinGUI(player, item, Page + 1);
                            break;
                        }
                        case "back" : {
                            SkinGUI(player, item, Page - 1);
                            break;
                        }
                    }
                    break;
                }
            }
            EffectNetwork.Send(x, player.Connection);
        }
        private IEnumerator LoadImage() {
            int x = 0, y = 0, xx = 0, yy = 0;
            PrintWarning("Началась загрузка изображений категорий!");
            foreach(var category in config.Category) {
                foreach(var item in category.Value) {
                    if(config.API.HasImage || !ImageLibrary.Call<bool>("HasImage", item.Key + 150)) {
                        ImageLibrary.Call("AddImage", $"http://api.skyplugins.ru/api/getimage/{item.Key}/{150}", item.Key + 150);
                        y++;
                        yield return CoroutineEx.waitForSeconds(0.3f);
                    }
                    else yield return CoroutineEx.waitForSeconds(0.03f);
                }
                x++;
                if(config.Setting.LogLoadIMG) PrintWarning($"[ Загружена категория {x} из {config.Category.Count} ] - [ Загружено изображений категории {y} из {category.Value.Count} ]");
                y = 0;
            }
            PrintWarning("Началась загрузка изображений скинов!");
            foreach(var item in StoredDataSkins) {
                foreach(var skin in item.Value) {
                    if(config.API.HasImage || !ImageLibrary.Call<bool>("HasImage", $"{skin}" + 152)) {
                        if(config.API.APIOption) ImageLibrary.Call("AddImage", $"http://api.skyplugins.ru/api/getskin/{skin}/{150}", $"{skin}" + 152);
                        else ImageLibrary.Call("AddImage", $"https://api.skyplugins.ru/api/getskin/v1/08102261/{skin}/150", $"{skin}" + 152);
                        yy++;
                        yield return CoroutineEx.waitForSeconds(0.3f);
                    }
                    else yield return CoroutineEx.waitForSeconds(0.03f);
                }
                xx++;
                if(config.Setting.LogLoadIMG) PrintWarning($"[ Загружен предмет {item.Key} | {xx} из {StoredDataSkins.Count} ] - [ Загружено изображений скинов {yy} из {item.Value.Count} ]");
                yy = 0;
            }
            PrintWarning("\n-----------------------------\n" + "     Загрузка всех изображений завершена.\n" + "     Изображения которые не были загружены, это означает что они уже есть в дате ImageLibrary.\n" + "     А если они сломаные, то вам нужно их перезагрузить командой skinimage_reload или очистить дату ImageLibrary.\n" + "-----------------------------");
            _coroutine = null;
            yield return 0;
        }
        public Dictionary<string, string> errorshortnames = new Dictionary<string, string> {
            ["snowmobiletomaha"]
            = "tomahasnowmobile"
        }
        ;
        private void OnNewSave() {
            timer.Once(20, () => {
                PrintError("--------------------------------------------\n" + "Внимание! Обнаружен вайп! Все изображения принудительно будут перезагружены! Не выключайте сервер и не перезагружайте плагин!\n" + "Внимание! Обнаружен вайп! Все изображения принудительно будут перезагружены! Не выключайте сервер и не перезагружайте плагин!\n" + "Внимание! Обнаружен вайп! Все изображения принудительно будут перезагружены! Не выключайте сервер и не перезагружайте плагин!\n" + "--------------------------------------------");
                if(_coroutine != null) {
                    ServerMgr.Instance.StopCoroutine(_coroutine);
                    _coroutine = null;
                }
                NextTick(() => {
                    if(_coroutine == null) _coroutine = ServerMgr.Instance.StartCoroutine(ReloadImage());
                }
                );
            }
            );
        }
        private void SettingGUI(BasePlayer player) {
            CuiHelper.DestroyUi(player, ".SettingGUI");
            CuiElementContainer container = new CuiElementContainer();
            container.Add(new CuiPanel {
                RectTransform = {
                    AnchorMin = "0.273 0.32", AnchorMax = "0.73 0.57", OffsetMax = "0 0"
                }
                , Image = {
                    Color = "0 0 0 0"
                }
            }
            , ".SGUI", ".SettingGUI");
            container.Add(new CuiElement {
                Name = ".Settings", Parent = ".SettingGUI", Components = {
                    new CuiRawImageComponent {
                        Png = (string) ImageLibrary.Call("GetImage", "QJ1ZV1G")
                    }
                    , new CuiRectTransformComponent {
                        AnchorMin = "0 0", AnchorMax = "1 1", OffsetMax = "0 0"
                    }
                    ,
                }
            }
            );
            container.Add(new CuiLabel {
                RectTransform = {
                    AnchorMin = "0.05 0.755", AnchorMax = "0.3 0.9", OffsetMax = "0 0"
                }
                , Text = {
                    Text = "Настройки скинов", Align = TextAnchor.MiddleLeft, Font = "robotocondensed-regular.ttf", FontSize = 12, Color = "0.7507126 0.7507126 0.7507126 0.4"
                }
            }
            , ".Settings");
            container.Add(new CuiButton {
                RectTransform = {
                    AnchorMin = "0.93 0.77", AnchorMax = "0.965 0.88", OffsetMax = "0 0"
                }
                , Button = {
                    Color = "0 0 0 0", Close = ".SettingGUI"
                }
                , Text = {
                    Text = ""
                }
            }
            , ".Settings");
            var player_data = StoredData[player.userID];
            Dictionary<string, bool> setting = new Dictionary<string, bool> {
                ["inventory"]
                = player_data.ChangeSI, ["entity"] = player_data.ChangeSE, ["craft"] = player_data.ChangeSC, ["clear"] = player_data.ChangeSCL, ["give"] = player_data.ChangeSG, ["friends"] = StoredDataFriends[player.userID]
            }
            ;
            float width = 0.478f, height = 0.2f, startxBox = 0.038f, startyBox = 0.725f - height, xmin = startxBox, ymin = startyBox;
            int z = 0;
            foreach(var s in setting) {
                var w = z == 1 ? width - 0.04f : z == 3 ? width - 0.04f : z == 5 ? width - 0.04f : width + 0.0059f;
                container.Add(new CuiPanel {
                    RectTransform = {
                        AnchorMin = xmin + " " + ymin, AnchorMax = (xmin + w) + " " + (ymin + height * 1), OffsetMin = "4 4", OffsetMax = "-4 -4"
                    }
                    , Image = {
                        Color = "0 0 0 0"
                    }
                }
                , ".Settings", ".SM");
                container.Add(new CuiButton {
                    RectTransform = {
                        AnchorMin = "0.03 0.3", AnchorMax = "0.08 0.7", OffsetMax = "0 0"
                    }
                    , Button = {
                        Color = "0.7507126 0.7507126 0.7507126 1", Sprite = s.Value ? config.MenuS.TButtonIcon : config.MenuS.FButtonIcon
                    }
                    , Text = {
                        Text = ""
                    }
                }
                , ".SM");
                container.Add(new CuiLabel {
                    RectTransform = {
                        AnchorMin = "0.1 0", AnchorMax = "1 1", OffsetMax = "0 0"
                    }
                    , Text = {
                        Text = lang.GetMessage(s.Key, this, player.UserIDString), Align = TextAnchor.MiddleLeft, Font = "robotocondensed-regular.ttf", FontSize = 10, Color = "0.7507126 0.7507126 0.7507126 1"
                    }
                }
                , ".SM");
                container.Add(new CuiButton {
                    RectTransform = {
                        AnchorMin = "0 0", AnchorMax = "1 1", OffsetMax = "0 0"
                    }
                    , Button = {
                        Color = "0 0 0 0", Command = $"skin_s {s.Key}"
                    }
                    , Text = {
                        Text = ""
                    }
                }
                , ".SM");
                z++;
                xmin += w;
                if (xmin + width >= 1) {
                    xmin = startxBox;
                    ymin -= height + 0.002f;
                }
            }
            CuiHelper.AddUi(player, container);
        }
        private void Unload() {
            foreach(BasePlayer player in BasePlayer.activePlayerList) {
                SaveData(player);
                CuiHelper.DestroyUi(player, ".GUIS");
            }
            if(_coroutine != null) ServerMgr.Instance.StopCoroutine(_coroutine);
            Interface.Oxide.DataFileSystem.WriteObject("XDataSystem/XSkinMenu/Friends", StoredDataFriends);
        }
        public Dictionary<ulong, string> errorskins = new Dictionary<ulong, string> {
            [10180]
            = "hazmatsuit.spacesuit", [10201] = "hazmatsuit.nomadsuit", [10207] = "hazmatsuit.arcticsuit", [13070] = "rifle.ak.ice", [13068] = "snowmobiletomaha", [10189] = "door.hinged.industrial.a", [13050] = "skullspikes.candles", [13051] = "skullspikes.pumpkin", [13052] = "skull.trophy.jar", [13053] = "skull.trophy.jar2", [13054] = "skull.trophy.table", [13056] = "sled.xmas", [13057] = "discofloor.largetiles", [10198] = "factorydoor", [10211] = "hazmatsuit.lumberjack", [10212] = "metal.facemask.hockey", [10213] = "torch.torch.skull", [10214] = "mace.baseballbat", [13075] = "concretehatchet", [13074] = "concretepickaxe", [13073] = "lumberjack.hatchet", [13072] = "lumberjack.pickaxe", [10215] = "chair.icethrone", [10217] = "metal.facemask.icemask", [10216] = "metal.plate.torso.icevest",  //[] = "sofa.pattern"
        }
        ;
        [PluginReference]
        private Plugin ImageLibrary;
        private void OnItemAddedToContainer(ItemContainer container, Item item) {
            if(item == null) return;
            if(container?.playerOwner != null) {
                BasePlayer player = container.playerOwner;
                if(player == null || player.IsNpc || !player.userID.IsSteamId() || player.IsSleeping()) return;
                if(config.Setting.ReskinConfig && !_items.ContainsKey(item.info.shortname)) return;
                if(!permission.UserHasPermission(player.UserIDString, "xskinmenu.give") || !StoredData.ContainsKey(player.userID) || !StoredData[player.userID].Skins.ContainsKey(item.info.shortname)) return;
                if(StoredData[player.userID].ChangeSG) SetSkinCraftGive(player, item);
            }
        }
        private void OnPlayerRespawned(BasePlayer player) {
            if(config.Setting.ReskinRespawn) timer.Once(2, () => {
                if(StoredData.ContainsKey(player.userID)) {
                    var items = player?.inventory?.AllItems();
                    if(items != null) foreach(Item item in items) if(StoredData[player.userID].Skins.ContainsKey(item.info.shortname)) SetSkinCraftGive(player, item);
                }
            }
            );
        }
        private void InitializeLang() {
            lang.RegisterMessages(new Dictionary<string, string> {
                ["ERRORSKIN"]
                = "THE SKIN YOU CHOSE CAN BE CHANGED ONLY IN THE INVENTORY OR WHEN CRAFTING!", ["CLEARALL"] = "RESET ALL SELECTED SKINS", ["NOPERM"] = "No permissions!", ["weapon"] = "WEAPON", ["construction"] = "CONSTRUCTION", ["item"] = "ITEM", ["attire"] = "ATTIRE", ["tool"] = "TOOL", ["transport"] = "TRANSPORT", ["inventory"] = "CHANGE SKIN IN INVENTORY", ["entity"] = "CHANGE SKIN ON OBJECTS", ["craft"] = "CHANGE SKIN WHEN CRAFTING", ["clear"] = "CHANGE SKIN WHEN DELETING", ["give"] = "SKIN CHANGE WHEN DROP IN INVENTORY", ["friends"] = "ALLOW FRIENDS TO CHANGE YOUR SKINS"
            }
            , this);
            lang.RegisterMessages(new Dictionary<string, string> {
                ["ERRORSKIN"]
                = "ВЫБРАННЫЙ ВАМИ СКИН МОЖНО ИЗМЕНИТЬ ТОЛЬКО В ИНВЕНТАРЕ ИЛИ ПРИ КРАФТЕ!", ["CLEARALL"] = "СБРОСИТЬ ВСЕ ВЫБРАННЫЕ СКИНЫ", ["NOPERM"] = "Недостаточно прав!", ["weapon"] = "ОРУЖИЕ", ["construction"] = "СТРОИТЕЛЬСТВО", ["item"] = "ПРЕДМЕТЫ", ["attire"] = "ОДЕЖДА", ["tool"] = "ИНСТРУМЕНТЫ", ["transport"] = "ТРАНСПОРТ", ["inventory"] = "ПОМЕНЯТЬ СКИН В ИНВЕНТАРЕ", ["entity"] = "ПОМЕНЯТЬ СКИН НА ПРЕДМЕТАХ", ["craft"] = "ПОМЕНЯТЬ СКИН ПРИ КРАФТЕ", ["clear"] = "ПОМЕНЯТЬ СКИН ПРИ УДАЛЕНИИ", ["give"] = "ПОМЕНЯТЬ СКИН ПРИ ПОПАДАНИИ В ИНВЕНТАРЬ", ["friends"] = "РАЗРЕШИТЬ ДРУЗЬЯМ ИЗМЕНЯТЬ ВАШИ СКИНЫ"
            }
            , this, "ru");
            lang.RegisterMessages(new Dictionary<string, string> {
                ["ERRORSKIN"]
                = "ВИБРАНИЙ ВАМИ СКІН МОЖНА ЗМІНИТИ ТІЛЬКИ В ІНВЕНТАРІ АБО ПРИ КРАФТІ!", ["CLEARALL"] = "СКИНУТИ ВСІ ОБРАНІ СКІНИ", ["NOPERM"] = "Недостатньо прав!", ["weapon"] = "ЗБРОЯ", ["construction"] = "БУДІВНИЦТВО", ["item"] = "ПРЕДМЕТИ", ["attire"] = "ОДЯГ", ["tool"] = "ІНСТРУМЕНТИ", ["transport"] = "ТРАНСПОРТ", ["inventory"] = "ЗМІНИТИ СКІН В ІНВЕНТАРІ", ["entity"] = "ЗМІНИТИ СКІН НА ПРЕДМЕТАХ", ["craft"] = "ЗМІНИТИ СКІН ПРИ КРАФТІ", ["clear"] = "ЗМІНИТИ СКІН ПРИ ВИДАЛЕННІ", ["give"] = "ЗМІНИТИ СКІН ПРИ ПОТРАПЛЯННІ В ІНВЕНТАР", ["friends"] = "ДОЗВОЛИТИ ДРУЗЯМ ЗМІНЮВАТИ ВАШІ СКІНИ"
            }
            , this, "uk");
            lang.RegisterMessages(new Dictionary<string, string> {
                ["ERRORSKIN"]
                = "¡LA SKIN QUE ELIGIÓ SE PUEDE CAMBIAR SOLO EN EL INVENTARIO O AL CREAR!", ["CLEARALL"] = "RESTABLECER TODAS LAS SKINS SELECCIONADAS", ["NOPERM"] = "¡No tienes permisos!", ["weapon"] = "ARMAS", ["construction"] = "CONSTRUCCIÓN", ["item"] = "ITEMS", ["attire"] = "ATUENDOS", ["tool"] = "HERRAMIENTAS", ["transport"] = "TRANSPORTES", ["inventory"] = "CAMBIO DE SKIN EN INVENTARIO", ["entity"] = "CAMBIAR LA SKIN DE LOS OBJETOS", ["craft"] = "CAMBIA DE SKIN AL CREAR", ["clear"] = "CAMBIAR LA SKIN AL ELIMINAR", ["give"] = "CAMBIO DE SKIN AL CAER EN EL INVENTARIO", ["friends"] = "PERMITE QUE AMIGOS CAMBIEN TUS SKINS"
            }
            , this, "es-ES");
        }
        private Dictionary<ulong, bool> StoredDataFriends = new Dictionary<ulong, bool>();
        [ChatCommand("skinentity")]
        private void cmdSetSkinEntity(BasePlayer player) {
            if(!permission.UserHasPermission(player.UserIDString, "xskinmenu.entity")) {
                SendReply(player, lang.GetMessage("NOPERM", this, player.UserIDString));
                return;
            }
            if(StoredData[player.userID].ChangeSE) {
                RaycastHit rhit;
                if(!Physics.Raycast(player.eyes.HeadRay(), out rhit, 3f, LayerMask.GetMask("Deployed", "Construction", "Prevent Building"))) return;
                var entity = rhit.GetEntity();
    
// ... [Code preview truncated due to length. Full source in attached file] ...

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