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

FREE LSkins : 1.6.72 1.6.72

Нет прав для скачивания
C#:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing.Drawing2D;
using System.Globalization;
using System.Linq;
using Facepunch.Extend;
using Newtonsoft.Json;
using Oxide.Core;
using Oxide.Core.Libraries;
using Oxide.Core.Libraries.Covalence;
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;
using Global = Rust.Global;

///Скачано с дискорд сервера Rust Edit [PRO+]
///discord.gg/9vyTXsJyKR

namespace Oxide.Plugins
{
    [Info("LSkins", "discord.gg/9vyTXsJyKR", "1.6.72")]
    public class LSkins : RustPlugin
    {
        #region Cfg

        private const bool En = true;
        class DataPlayer
        {
            [JsonProperty(En ? "List of favorite skins" : "Список избранных скинов")]
            public Dictionary<string, Dictionary<ulong, ItemData.SkinInfo>> _izvSkins =
                new Dictionary<string, Dictionary<ulong, ItemData.SkinInfo>>();
            [JsonProperty(En ? "List of default skins supplied" : "Список поставленных скинов по дефолту")]
            public Dictionary<string, DefaultSkins> _defaultSkins =
                new Dictionary<string, DefaultSkins>();
        }

        class DefaultSkins
        {
            [JsonProperty(En ? "SkinID" : "СкинАйди")]
            public ulong skinId;
            [JsonProperty(En ? "Information about the skin" : "Информация о скине")]
            public ItemData.SkinInfo SkinInfo;
        }
        private Dictionary<ulong, DataPlayer> playerData = new Dictionary<ulong, DataPlayer>();
        private static ConfigData cfg { get; set; }
        private static readonly Dictionary<string, int> ItemIds = new Dictionary<string, int>();

        private int GetItemId(string shortname)
        {
            int id;
            if (ItemIds.TryGetValue(shortname, out id))
                return id;
            var def = ItemManager.FindItemDefinition(shortname);
            if (!def)
                return ItemIds[shortname] = int.MinValue;
            return ItemIds[shortname] = def.itemid;
        }

        private class ConfigData
        {
            internal class MarketSystem
            {
                [JsonProperty(En ? "Enabled(true = yes)" : "Включить?(true = да)")]
                public bool IsEnabled = false;
                [JsonProperty(En ? "How to pay?(Scrap, ServerRewards, Economics)" : "Чем платить?(Scrap, ServerRewards, Economics)")]
                public string WhoMarket = "Scrap";
                [JsonProperty(En ? "The price for opening the interface (If 0, then free)" : "Цена за открытие интерфейса(Если 0, то бесплатно)")]
                public int costOpen = 10;
                [JsonProperty(En ? "Price per change of one skin (If 0, then free)" : "Цена за смену одного скина(Если 0, то бесплатно)")]
                public int costChange = 10;
            }
            internal class InterfaceSetting
            {
                [JsonProperty(En ? "Background color of favorite skins" : "Цвет фона фаворитных скинов")]
                public string favcolor = "#535150";
                [JsonProperty(En ? "Background color of the main panel" : "Цвет фона основной панели")]
                public string mainColor = "#535151";
                [JsonProperty(En ? "The color of the forward arrow" : "Цвет стрелочки вперед")]
                public string pageup = "#5c80ba";
                [JsonProperty(En ? "The color of the back arrow" : "Цвет стрелочки назад")]
                public string pagedown = "#5c80ba";
            }
            [JsonProperty(En ? "Add a skin to the cfg automatically?(true = yes)" : "Добавить в кфг автоматически скин?(true = да)")]
            public bool IsApproved = false;
            [JsonProperty(En ? "Add a hazmats to the cfg automatically?(true = yes)" : "Добавить в кфг автоматически хазматы?(true = да)")]
            public bool IsHazmat = false;
            [JsonProperty(En ? "Rights to use the skins system" : "Права для использование системы скинов.")]
            public string canuse = "lskins.use";
            [JsonProperty(En ? "List of available commands" : "Список доступных команд")]
            public List<string> Commands = new List<string>();
            [JsonProperty(En ? "List of available commands for skins entity" : "Список доступных команд для изменения скина ентити")]
            public List<string> EntCommands = new List<string>();
            [JsonProperty(En ? "Install the skin automatically on items where there is already a skin?(true = yes)" : "Устанавилвать скин автоматически на предметы где уже есть скин?(true = да)")]
            public bool SkinAuto = false;
            [JsonProperty(En ? "Rights to use default skins" : "Права для использование скинов по дефолту")]
            public string canusedefault = "lskins.usedefault";
            [JsonProperty(En ? "Setting up payment for opening" : "Настройка оплаты за открытие")]
            public MarketSystem Market = new MarketSystem();
            [JsonProperty(En ? "Setting interface" : "Настройка интерфейса")]
            public InterfaceSetting Interface = new InterfaceSetting();
            [JsonProperty(En ? "Items with these skins cannot be exchanged." : "Предметы с этими скинами нельзя будет поменять.")]
            public List<ulong> blackList = new List<ulong>();
            [JsonProperty(En ? "Rights to use unique skins" : "Права для использование уникальных скинов")]
            public Dictionary<string, List<ulong>> useSkins = new Dictionary<string, List<ulong>>();
            public static ConfigData GetNewConf()
            {
                var newConfig = new ConfigData
                {
                    Commands = new List<string>()
                    {
                        "skins",
                        "skin",
                        "s"
                    },
                    EntCommands = new List<string>()
                    {
                        "se"
                    },
                    useSkins = new Dictionary<string, List<ulong>>()
                    {
                        ["lskins.prem"] = new List<ulong>()
                        {
                            2668297561,
                            2649480126,
                            2599664731,
                        }
                    },
                    blackList = new List<ulong>()
                    {
                        12341234,
                    }
                };
                return newConfig;
            }
        }

        class ItemData
        {
            public class SkinInfo
            {
                [JsonProperty(En ? "Enabled skin?(true = yes)" : "Включить скин?(true = да)")]
                public bool IsEnabled = true;
                [JsonProperty(En ? "Is this skin from the developers of rust or take it in a workshop?" : "Этот скин есть от разработчиков раста или принять в воркшопе??(true = да)")]
                public bool IsApproved = true;
                [JsonProperty(En ? "Name skin" : "Название скина")]
                public string MarketName = "Warhead LR300";
                [JsonProperty(En ? "Have url" : "Имеет ли ссылку")]
                public bool HaveUrl = false;

            }
            public Dictionary<ulong, SkinInfo> _skinInfos = new Dictionary<ulong, SkinInfo>();
        }
        protected override void LoadDefaultConfig()
        {
            cfg = ConfigData.GetNewConf();
        }

        protected override void SaveConfig()
        {
            Config.WriteObject(cfg);
        }

        protected override void LoadConfig()
        {
            base.LoadConfig();
            try
            {
                cfg = Config.ReadObject<ConfigData>();
            }
            catch
            {
                LoadDefaultConfig();
            }

            NextTick(SaveConfig);
        }

        #endregion

        #region Interface
        private static string Layer = "UiLSkins";
        private static string Hud = "Hud";
        private static string Overlay = "Overlay";
        private static string regular = "robotocondensed-regular.ttf";
        private static string blur = "assets/content/ui/uibackgroundblur.mat";
        private static string Sharp = "assets/content/ui/ui.background.tile.psd";
        private static string radial = "assets/content/ui/ui.background.transparent.radial.psd";


        private void LoadIzbranoeUI(BasePlayer player, string weapon, uint itemId, int page, bool isentity = false)
        {
            DataPlayer weapons;
            if (!playerData.TryGetValue(player.userID, out weapons)) return;
            CuiHelper.DestroyUi(player, Layer + "-Izbranoe");
            var cont = new CuiElementContainer();
            cont.Add(new CuiPanel()
            {
                Image =
                {
                    Color = "0 0 0 0"
                },
                RectTransform =
                {
                    AnchorMin = "0.5 0",
                    AnchorMax = "0.5 0",
                    OffsetMin = $"{201} {111}",
                    OffsetMax = $"{571} {231}"
                }
            }, "Overlay", Layer + "-Izbranoe");

            if (!weapons._izvSkins.ContainsKey(weapon)) return;
            var tSkinsList = weapons._izvSkins[weapon];
            foreach (var keyValuePair in cfg.useSkins.Where(keyValuePair => !permission.UserHasPermission(player.UserIDString, keyValuePair.Key)))
            {
                keyValuePair.Value.ForEach(p =>
                {
                    if (tSkinsList.ContainsKey(p))
                    {
                        tSkinsList.Remove(p);
                    }
                });
            }
            for (int i = 0; i < 12; i++)
            {
                if (tSkinsList.Count - 1 >= i)
                {
                    cont.Add(new CuiElement()
                    {
                        Parent = Layer + "-Izbranoe",
                        Components =
                        {
                            new CuiImageComponent()
                            {
                                ItemId =  GetItemId(weapon.Contains("hazmatsuit") ? _hazmats[tSkinsList.ToList()[i].Key] : weapon),
                                SkinId = tSkinsList.ToList()[i].Key
                            },
                            //new CuiRawImageComponent()
                           // {
                          //      Png = GetImage($"LSKINLOAD({Version})"+ weapon +"_" + )
                            //},
                            new CuiRectTransformComponent()
                            {
                                AnchorMin =
                                    $"0 0.5",
                                AnchorMax =
                                    $"0 0.5",
                                OffsetMin =
                                    $"{2 + i * 62 - Math.Floor((double) i / 6) * 6 * 62} {5 - Math.Floor((double) i / 6) * 62}",
                                OffsetMax =
                                    $"{52 + i * 62 - Math.Floor((double) i / 6) * 6 * 62} {55 - Math.Floor((double) i / 6) * 62}"
                            }
                        }
                    });
                    var type = isentity ? "setskinent" : "setskin";
                    cont.Add(new CuiButton()
                    {
                        Button = {
                            Color = "1 1 1 0",
                            Command = $"uiskinmenu {type} {itemId} {tSkinsList.ToList()[i].Key}"

                        },
                        Text =
                        {
                            Text = ""
                        },
                        RectTransform =
                        {
                            AnchorMin =
                                $"0 0.5",
                            AnchorMax =
                                $"0 0.5",
                            OffsetMin =
                                $"{2 + i * 62 - Math.Floor((double) i / 6) * 6 * 62} {5- Math.Floor((double) i / 6) * 62}",
                            OffsetMax =
                                $"{52 + i * 62 - Math.Floor((double) i / 6) * 6 * 62} {55 - Math.Floor((double) i / 6) * 62}"
                        }
                    }, Layer + "-Izbranoe", Layer + "-Izbranoe" + i);
                    cont.Add(new CuiButton()
                    {
                        RectTransform =
                        {
                            AnchorMin = "0 1",
                            AnchorMax = "0 1",
                            OffsetMin = $"{-5} {-10}",
                            OffsetMax = $"{10} {5}"
                        },
                        Button =
                        {
                            Command = $"uiskinmenu setizbranoe {weapon} {tSkinsList.ToList()[i].Key} {page} {itemId}",
                            Color = HexToRustFormat("#dead39"),
                            Sprite = "assets/icons/favourite_servers.png",
                        },
                        Text = { Text = "" }
                    }, Layer + "-Izbranoe" + i);
                    if (permission.UserHasPermission(player.UserIDString, cfg.canusedefault))
                    {
                        if (playerData.TryGetValue(player.userID, out weapons) && weapons._defaultSkins.ContainsKey(weapon) && weapons._defaultSkins[weapon].skinId == tSkinsList.ToList()[i].Key)
                        {
                            cont.Add(new CuiButton()
                            {
                                RectTransform =
                                {
                                    AnchorMin = "1 0",
                                    AnchorMax = "1 0",
                                    OffsetMin = $"{-10} {0}",
                                    OffsetMax = $"{0} {10}"
                                },
                                Button =
                                {
                                    Command = $"uiskinmenu setdefault {weapon} {tSkinsList.ToList()[i].Key} {page} {itemId}",
                                    Color = HexToRustFormat("#369f47"),
                                    Sprite = "assets/icons/power.png",
                                },
                                Text = { Text = "" }
                            }, Layer + "-Izbranoe" + i);
                        }
                        else
                        {
                            cont.Add(new CuiButton()
                            {
                                RectTransform =
                                {
                                    AnchorMin = "1 0",
                                    AnchorMax = "1 0",
                                    OffsetMin = $"{-10} {0}",
                                    OffsetMax = $"{0} {10}"
                                },
                                Button =
                                {
                                    Command = $"uiskinmenu setdefault {weapon} {tSkinsList.ToList()[i].Key} {page} {itemId}",
                                    Color = HexToRustFormat("#fb4f3b"),
                                    Sprite = "assets/icons/power.png",
                                },
                                Text = { Text = "" }
                            }, Layer + "-Izbranoe" + i);
                        }
                    }
                }
            }
            CuiHelper.AddUi(player, cont);
        }
        private void LoadWearUI(BasePlayer player)
        {
            CuiHelper.DestroyUi(player, Layer + "-Wear");
            var cont = new CuiElementContainer();
            cont.Add(new CuiPanel()
            {
                Image =
                {
                    Color = "0 0 0 0"
                },
                RectTransform =
                {
                    AnchorMin = "0.5 0",
                    AnchorMax = "0.5 0",
                    OffsetMin = $"{-588} {115}",
                    OffsetMax = $"{-215} {169}"
                }
            }, "Overlay", Layer + "-Wear");

            for (int i = 0; i < player.inventory.containerWear.capacity; i++)
            {
                var item = player.inventory.containerWear.GetSlot(i);
                if (item == null)
                {
                    cont.Add(new CuiElement()
                    {
                        Parent = Layer + "-Wear",
                        Components =
                        {
                            new CuiRawImageComponent()
                            {
                                Png = GetImage($"LSKINGRID({Version})"),
                                Color = "1 1 1 0.05"
                            },
                            new CuiRectTransformComponent()
                            {
                                AnchorMin =
                                    $"0 0",
                                AnchorMax =
                                    $"0 0",
                                OffsetMin = $"{0 + i * 54 - Math.Floor((double) i / 7) * 7 * 54} {0}",
                                OffsetMax = $"{50 + i * 54 - Math.Floor((double) i / 7) * 7 * 54} {50}"
                            }
                        }
                    });
                    continue;
                }
                var onblacklist = cfg.blackList.Contains(item.skin);
                var shortname = item.info.shortname.Contains("hazmatsuit") ? "hazmatsuit" : item.info.shortname;
                var skinsExsist = Interface.Oxide.DataFileSystem.ExistsDatafile($"LSkins/Skins/{shortname}");
                if (!onblacklist && skinsExsist)
                {
                    cont.Add(new CuiButton()
                    {
                        Button = {
                            Color = "0.65 0.65 0.65 0",
                            Command = $"uiskinmenu weaponSelect {item.info.shortname} {item.uid}"
                        },
                        Text =
                        {
                            Text = ""
                        },
                        RectTransform =
                        {
                            AnchorMin =
                                $"0 0",
                            AnchorMax =
                                $"0 0",
                            OffsetMin = $"{0 + i * 54 - Math.Floor((double) i / 7) * 7 * 54} {0}",
                            OffsetMax = $"{50 + i * 54 - Math.Floor((double) i / 7) * 7 * 54} {50}"
                        }
                    }, Layer + "-Wear");
                }
                else
                {
                    cont.Add(new CuiElement()
                    {
                        Parent = Layer + "-Wear",
                        Components =
                        {
                            new CuiRawImageComponent()
                            {
                                Png = GetImage($"LSKINGRID({Version})"),
                                Color = "1 1 1 0.05"
                            },
                            new CuiRectTransformComponent()
                            {
                                AnchorMin =
                                    $"0 0",
                                AnchorMax =
                                    $"0 0",
                                OffsetMin = $"{0 + i * 54 - Math.Floor((double) i / 7) * 7 * 54} {0}",
                                OffsetMax = $"{50 + i * 54 - Math.Floor((double) i / 7) * 7 * 54} {50}"
                            }
                        }
                    });
                }
            }
            CuiHelper.AddUi(player, cont);
        }
        private void LoadMainUI(BasePlayer player)
        {

            CuiHelper.DestroyUi(player, Layer + "-Main");
            var cont = new CuiElementContainer();
            cont.Add(new CuiPanel()
            {
                Image =
                {
                    Color = "0 0 0 0"
                },
                RectTransform =
                {
                    AnchorMin = $"{0.5} {0}",
                    AnchorMax = $"{0.5} {0}",
                    OffsetMin = $"{-200 } {85}",
                    OffsetMax = $"{180} {337}"
                }
            }, "Overlay", Layer + "-Main");
            for (int i = 0; i < player.inventory.containerMain.capacity; i++)
            {
                var item = player.inventory.containerMain.GetSlot(i);
                if (item == null)
                {
                    cont.Add(new CuiElement()
                    {
                        Parent = Layer + "-Main",
                        Components =
                        {
                            new CuiRawImageComponent()
                            {
                                Png = GetImage($"LSKINGRID({Version})"),
                                Color = "1 1 1 0.05"
                            },
                            new CuiRectTransformComponent()
                            {
                                AnchorMin =
                                    $"0 1",
                                AnchorMax =
                                    $"0 1",
                                OffsetMin =
                                    $"{0 + i * 64 - Math.Floor((double) i / 6) * 6 * 64} {-60 - Math.Floor((double) i / 6) * 63.5}",
                                OffsetMax =
                                    $"{60 + i * 64 - Math.Floor((double) i / 6) * 6 * 64} {0 - Math.Floor((double) i / 6) * 63.5}"
                            }
                        }
                    });
                    continue;
                }
                var onblacklist = cfg.blackList.Contains(item.skin);
                var shortname = item.info.shortname.Contains("hazmatsuit") ? "hazmatsuit" : item.info.shortname;
                var skinsExsist = Interface.Oxide.DataFileSystem.ExistsDatafile($"LSkins/Skins/{shortname}");
                if (!onblacklist && skinsExsist)
                {
                    cont.Add(new CuiButton()
                    {
                        Button = {
                            Color = "0.65 0.65 0.65 0",
                            Command = $"uiskinmenu weaponSelect {item.info.shortname} {item.uid}"

                        },
                        Text =
                        {
                            Text = ""
                        },
                        RectTransform =
                        {
                            AnchorMin =
                                $"0 1",
                            AnchorMax =
                                $"0 1",
                            OffsetMin =
                                $"{0 + i * 64- Math.Floor((double) i / 6) * 6 * 64} {-60 - Math.Floor((double) i / 6) * 63}",
                            OffsetMax =
                                $"{60 + i * 64 - Math.Floor((double) i / 6) * 6 * 64} {0 - Math.Floor((double) i / 6) * 63}"
                        }
                    }, Layer + "-Main");
                }
                else
                {
                    cont.Add(new CuiElement()
                    {
                        Parent = Layer + "-Main",
                        Components =
                        {
                            new CuiRawImageComponent()
                            {
                                Png = GetImage($"LSKINGRID({Version})"),
                                Color = "1 1 1 0.05"
                            },
                            new CuiRectTransformComponent()
                            {
                                AnchorMin =
                                    $"0 1",
                                AnchorMax =
                                    $"0 1",
                                OffsetMin =
                                    $"{0 + i * 64 - Math.Floor((double) i / 6) * 6 * 64} {-60 - Math.Floor((double) i / 6) * 63}",
                                OffsetMax =
                                    $"{60 + i * 64 - Math.Floor((double) i / 6) * 6 * 64} {0 - Math.Floor((double) i / 6) * 63.5}"
                            }
                        }
                    });
                }
            }
            CuiHelper.AddUi(player, cont);
        }
        private void LoadBeltUI(BasePlayer player)
        {
            CuiHelper.DestroyUi(player, Layer + "-Belt");
            var cont = new CuiElementContainer();
            cont.Add(new CuiPanel()
            {
                Image =
                {
                    Color = "0 0 0 0"
                },
                RectTransform =
                {
                    AnchorMin = "0.5 0",
                    AnchorMax = "0.5 0",
                    OffsetMin = $"{-200} {17}",
                    OffsetMax = $"{180} {79}"
                }
            }, "Overlay", Layer + "-Belt");
            for (int i = 0; i < 6; i++)
            {
                var item = player.inventory.containerBelt.GetSlot(i);
                if (item == null)
                {
                    cont.Add(new CuiElement()
                    {
                        Parent = Layer + "-Belt",
                        Components =
                        {
                            new CuiRawImageComponent()
                            {
                                Png = GetImage($"LSKINGRID({Version})"),
                                Color = "1 1 1 0.05"
                            },
                            new CuiRectTransformComponent()
                            {
                                AnchorMin =
                                    $"0 0",
                                AnchorMax =
                                    $"0 0",
                                OffsetMin = $"{0 + i * 64- Math.Floor((double) i / 6) * 6 * 64} {0}",
                                OffsetMax = $"{60 + i * 64 - Math.Floor((double) i / 6) * 6 * 64} {60}"
                            }
                        }
                    });
                    continue;
                }
                var onblacklist = cfg.blackList.Contains(item.skin);
                var shortname = item.info.shortname.Contains("hazmatsuit") ? "hazmatsuit" : item.info.shortname;
                var skinsExsist = Interface.Oxide.DataFileSystem.ExistsDatafile($"LSkins/Skins/{shortname}");
                if (!onblacklist && skinsExsist)
                {
                    cont.Add(new CuiButton()
                    {
                        Button =
                        {
                            Color = "0.65 0.65 0.65 0",
                            Command = $"uiskinmenu weaponSelect {item.info.shortname} {item.uid}"
                        },
                        Text =
                        {
                            Text = ""
                        },
                        RectTransform =
                        {
                            AnchorMin =
                                $"0 0",
                            AnchorMax =
                                $"0 0",
                            OffsetMin = $"{0 + i * 64 - Math.Floor((double) i / 6) * 6 * 64} {0}",
                            OffsetMax = $"{60+ i * 64 - Math.Floor((double) i / 6) * 6 * 64} {60}"
                        }
                    }, Layer + "-Belt");
                }
                else
                {
                    cont.Add(new CuiElement()
                    {
                        Parent = Layer + "-Belt",
                        Components =
                        {
                            new CuiRawImageComponent()
                            {
                                Png = GetImage($"LSKINGRID({Version})"),
                                Color = "1 1 1 0.05"
                            },
                            new CuiRectTransformComponent()
                            {
                                AnchorMin =
                                    $"0 0",
                                AnchorMax =
                                    $"0 0",
                                OffsetMin = $"{0 + i * 64 - Math.Floor((double) i / 6) * 6 * 64} {0}",
                                OffsetMax = $"{60 + i * 64 - Math.Floor((double) i / 6) * 6 * 64} {60}"
                            }
                        }
                    });
                }
            }
            CuiHelper.AddUi(player, cont);
        }
        [ConsoleCommand("uiskinmenu")]
        void ConsoleCommand(ConsoleSystem.Arg arg)
        {
            var player = arg.Player();
            if (player == null) return;
            Effect Sound1 = new Effect("assets/bundled/prefabs/fx/notice/loot.drag.grab.fx.prefab", player, 0, new Vector3(), new Vector3());
            string weapon;
            ulong skinId;
            int page;
            int itemId;
            DataPlayer weapons;
            string uid;
            switch (arg.Args[0])
            {
                case "page":
                    EffectNetwork.Send(Sound1, player.Connection);
                    LoadSkinsUI(player, arg.Args[1], arg.Args[2].ToInt(), uint.Parse(arg.Args[3]), bool.Parse(arg.Args[4]));
                    LoadIzbranoeUI(player, arg.Args[1], uint.Parse(arg.Args[3]), arg.Args[2].ToInt(), bool.Parse(arg.Args[4]));
                    break;
                case "weaponSelect":
                    EffectNetwork.Send(Sound1, player.Connection);
                    LoadSkinsUI(player, arg.Args[1], 1, uint.Parse(arg.Args[2]));
                    LoadIzbranoeUI(player, arg.Args[1], uint.Parse(arg.Args[2]), 1);
                    break;
                case "setizbranoe":
                    EffectNetwork.Send(Sound1, player.Connection);
                    if (!playerData.TryGetValue(player.userID, out weapons)) return;
                    weapon = arg.Args[1];
                    skinId = ulong.Parse(arg.Args[2]);
                    page = arg.Args[3].ToInt();
                    itemId = arg.Args[4].ToInt();
                    if (weapons._izvSkins.ContainsKey(weapon) && weapons._izvSkins[weapon].ContainsKey(skinId))
                    {
                        weapons._izvSkins[weapon].Remove(skinId);
                    }
                    else if (weapons._izvSkins.ContainsKey(weapon))
                    {
                        weapons._izvSkins[weapon].Add(skinId, _loadData[weapon][skinId]);
                    }
                    else
                    {
                        weapons._izvSkins.Add(weapon, new Dictionary<ulong, ItemData.SkinInfo>()
                        {
                            [skinId] = _loadData[weapon][skinId]
                        });
                    }
                    LoadSkinsUI(player, weapon, page, (uint)itemId);
                    LoadIzbranoeUI(player, weapon, (uint)itemId, page);
                    break;
                case "setdefault":
                    EffectNetwork.Send(Sound1, player.Connection);
                    if (!playerData.TryGetValue(player.userID, out weapons)) return;
                    weapon = arg.Args[1];
                    skinId = ulong.Parse(arg.Args[2]);
                    page = arg.Args[3].ToInt();
                    itemId = arg.Args[4].ToInt();
                    if (weapons._defaultSkins.ContainsKey(weapon) && weapons._defaultSkins[weapon].skinId == skinId)
                    {
                        weapons._defaultSkins.Remove(weapon);
                    }
                    else if (weapons._defaultSkins.ContainsKey(weapon))
                    {
                        weapons._defaultSkins[weapon].skinId = skinId;
                        weapons._defaultSkins[weapon].SkinInfo = _loadData[weapon][skinId];
                    }
                    else
                    {
                        weapons._defaultSkins.Add(weapon, new DefaultSkins()
                        {
                            skinId = skinId,
                            SkinInfo = _loadData[weapon][skinId]
                        });
                    }
                    LoadSkinsUI(player, weapon, page, (uint)itemId);
                    LoadIzbranoeUI(player, weapon, (uint)itemId, page);
                    break;
                case "setskin":
                    EffectNetwork.Send(Sound1, player.Connection);
                    if (cfg.Market.IsEnabled && !permission.UserHasPermission(player.UserIDString, cfg.canuse))
                    {
                        if (ChangeSkin(player) == false)
                        {
                            return;
                        }
                    }
                    uid = arg.Args[1];
                    var item = player.inventory.FindItemUID(uint.Parse(uid));
                    if (item.info.shortname.Contains("hazmatsuit"))
                    {
                        var pos = item.position;
                        var container = item.GetRootContainer();
                        var uids = item.uid;
                        item.DoRemove();
                        item = ItemManager.CreateByName($"{_hazmats[ulong.Parse(arg.Args[2])]}");
                        item.uid = uids;
                        item.MoveToContainer(container, pos);
                        item.MarkDirty();
                        player.SendNetworkUpdate();
                        return;
                    }
                    item.skin = ulong.Parse(arg.Args[2]);
                    var hend = item.GetHeldEntity();
                    if (hend != null)
                    {
                        hend.skinID = ulong.Parse(arg.Args[2]);
                        hend.SendNetworkUpdate();
                    }
                    item.MarkDirty();
                    player.SendNetworkUpdate();
                    break;
                case "setskinent":
                    EffectNetwork.Send(Sound1, player.Connection);
                    if (cfg.Market.IsEnabled && !permission.UserHasPermission(player.UserIDString, cfg.canuse))
                    {
                        if (ChangeSkin(player) == false)
                        {
                            return;
                        }
                    }
                    uint entid = uint.Parse(arg.Args[1]);
                    var ent = BaseEntity.serverEntities.Find(entid) as BaseEntity;
                    ent.skinID = ulong.Parse(arg.Args[2]);
                    ent.SendNetworkUpdate();
                    break;
                case "close":
                    EffectNetwork.Send(Sound1, player.Connection);
                    player.EndLooting();
                    break;
            }
        }
        private void LoadSkinsUI(BasePlayer player, string weapon, int page, uint itemId, bool isentity = false)
        {
            DataPlayer weapons;
            if (weapon.Contains("hazmatsuit"))
                weapon = "hazmatsuit";
            var skinsList = _loadData.ContainsKey(weapon);
            if (!skinsList) return;
            if (!playerData.TryGetValue(player.userID, out weapons)) return;
            CuiHelper.DestroyUi(player, Layer + "-Search");
            var cont = new CuiElementContainer();
            cont.Add(new CuiPanel()
            {
                Image =
                {
                    ImageType = UnityEngine.UI.Image.Type.Filled,
                    Png = "assets/standard assets/effects/imageeffects/textures/noise.png",
                    Sprite = Sharp,
                    Color = HexToRustFormat("#5351512C"),
                    Material = "assets/icons/greyout.mat"
                },
                RectTransform =
                {
                    AnchorMin = "0.5 0.5",
                    AnchorMax = "0.5 0.5",
                    OffsetMin = $"{-400} {-185}",
                    OffsetMax = $"{-35} {115}"
                }
            }, Layer, Layer + "-Search");
            cont.Add(new CuiPanel()
            {
                Image =
                {
                    ImageType = UnityEngine.UI.Image.Type.Filled,
                    Png = "assets/standard assets/effects/imageeffects/textures/noise.png",
                    Sprite = Sharp,
                    Color = HexToRustFormat("#5351512C"),
                    Material = "assets/icons/greyout.mat"
                },
                RectTransform =
                {
                    AnchorMin = "1 0.5",
                    AnchorMax = "1 0.5",
                    OffsetMin = $"{4} {-150}",
                    OffsetMax = $"{42} {150}"
                }
            }, Layer + "-Search", Layer + "-Page");
            if (0 < _loadData[weapon].Count - 12 * page)
            {
                cont.Add(new CuiButton()
                {
                    RectTransform =
                    {
                        AnchorMin = "0.5 0.5",
                        AnchorMax = "0.5 0.5",
                        OffsetMin = $"{-10} {5}",
                        OffsetMax = $"{10} {143}"
                    },
                    Button =
                    {
                        Command = $"uiskinmenu page {weapon} {page + 1} {itemId} {isentity}",
                        Color = HexToRustFormat($"{cfg.Interface.pageup}c3")
                    },
                    Text =
                    {
                        Text = "»", Align = TextAnchor.MiddleCenter,
                        FontSize = (int) (20 )
                    }
                }, Layer + "-Page");
            }
            else
            {
                cont.Add(new CuiButton()
                {
                    RectTransform =
                    {
                        AnchorMin = "0.5 0.5",
                        AnchorMax = "0.5 0.5",
                        OffsetMin = $"{-10} {5}",
                        OffsetMax = $"{10} {143}"
                    },
                    Button =
                    {
                        Command = $"",
                        Color = HexToRustFormat($"{cfg.Interface.pageup}c3")
                    },
                    Text =
                    {
                        Text = "»", Align = TextAnchor.MiddleCenter,
                        FontSize = (int) (20 ),
                        Color = "0.65 0.65 0.65 0.65"
                    }
                }, Layer + "-Page");
            }
            if (page > 1)
            {
                cont.Add(new CuiButton()
                {
                    RectTransform =
                    {
                        AnchorMin = "0.5 0.5",
                        AnchorMax = "0.5 0.5",
                        OffsetMin = $"{-10} {-137}",
                        OffsetMax = $"{10} {-5}"
                    },
                    Button =
                    {
                        Command = $"uiskinmenu page {weapon} {page - 1} {itemId} {isentity}",
                        Color = HexToRustFormat(cfg.Interface.pagedown)
                    },
                    Text =
                    {
                        Text = "«", Align = TextAnchor.MiddleCenter, FontSize = (int) (20 )
                    }
                }, Layer + "-Page");
            }
            else
            {
                cont.Add(new CuiButton()
                {
                    RectTransform =
                    {
                        AnchorMin = "0.5 0.5",
                        AnchorMax = "0.5 0.5",
                        OffsetMin = $"{-10} {-137}",
                        OffsetMax = $"{10} {-5}"
                    },
                    Button =
                    {
                        Command = $"",
                        Color = HexToRustFormat($"{cfg.Interface.pagedown}c3")
                    },
                    Text =
                    {
                        Text = "«", Align = TextAnchor.MiddleCenter, FontSize = (int) (20 ),
                        Color = "0.65 0.65 0.65 0.65"
                    }
                }, Layer + "-Page");
            }

            var tSkinsList = new Dictionary<ulong, ItemData.SkinInfo>();

            tSkinsList = _loadData[weapon].ToDictionary(keyValuePair => keyValuePair.Key, keyValuePair => keyValuePair.Value);

            if (cfg.useSkins.Count >= 1)
                foreach (var keyValuePair in cfg.useSkins.Where(keyValuePair =>
                    !permission.UserHasPermission(player.UserIDString, keyValuePair.Key)))
                {
                    keyValuePair.Value.ForEach(p =>
                    {
                        if (tSkinsList.ContainsKey(p))
                        {
                            tSkinsList.Remove(p);
                        }
                    });
                }
            foreach (var skinItem in tSkinsList.Where(p => p.Value.IsEnabled).Select((i, t) => new { A = i, B = t - (page - 1) * 12 }).Skip((page - 1) * 12).Take(12))
            {
                cont.Add(new CuiElement()
                {
                    Parent = Layer + "-Search",
                    Name = Layer + "-Search" + ".Player" + skinItem.B,
                    Components =
                    {
                        new CuiImageComponent()
                        {
                            Color = "0.35 0.35 0.35 0.65"
                        },
                        new CuiRectTransformComponent
                        {
                            AnchorMin = $"0 0.5",
                            AnchorMax = $"0 0.5",
                            OffsetMin = $"{4 + skinItem.B * 90 - Math.Floor((double) skinItem.B / 4) * 4 * 90} {60- Math.Floor((double) skinItem.B / 4) * 98}",
                            OffsetMax = $"{90 + skinItem.B * 90 - Math.Floor((double) skinItem.B / 4) * 4 * 90} {143 - Math.Floor((double) skinItem.B / 4) * 98}"
                        }
                    }
                });
                cont.Add(new CuiElement()
                {
                    Parent = Layer + "-Search" + ".Player" + skinItem.B,
                    Components =
                    {
                        new CuiImageComponent()
                        {
                            ItemId = GetItemId(weapon.Contains("hazmatsuit") ? _hazmats[skinItem.A.Key] : weapon),
                            SkinId = skinItem.A.Key
                        },
                        //new CuiRawImageComponent()
                        //{
                        //    Png =  GetImage($"LSKINLOAD({Version})"+ weapon +"_" + skinItem.A.Key)
                        //},
                        new CuiRectTransformComponent()
                        {
                            AnchorMin = "0.5 0.5",
                            AnchorMax = "0.5 0.5",
                            OffsetMin = $"{-30} {-30}",
                            OffsetMax = $"{30} {30}"
                        }
                    }
                });
                cont.Add(new CuiElement()
                {
                    Parent = Layer + "-Search" + ".Player" + skinItem.B,
                    Components =
                    {
                        new CuiTextComponent()
                        {
                            Text = skinItem.A.Value.MarketName, Align = TextAnchor.MiddleCenter,
                            Font = regular,
                            FontSize = 9
                        },
                        new CuiRectTransformComponent()
                        {
                            AnchorMin = "0.5 0",
                            AnchorMax = "0.5 0",
                            OffsetMin = $"{-40} {-15}",
                            OffsetMax = $"{40} {0}"
                        }
                    }
                });
                var type = isentity ? "setskinent" : "setskin";
                cont.Add(new CuiButton()
                {
                    RectTransform =
                    {
                        AnchorMin = "0.5 0.5",
                        AnchorMax = "0.5 0.5",
                        OffsetMin = $"{-30} {-30}",
                        OffsetMax = $"{30} {30}"
                    },
                    Button =
                    {
                        Command = $"uiskinmenu {type} {itemId} {skinItem.A.Key}",
                        Color = "0 0 0 0"
                    },
                    Text = { Text = "" }
                }, Layer + "-Search" + ".Player" + skinItem.B);

                if (weapons._izvSkins.ContainsKey(weapon) &&
                    weapons._izvSkins[weapon].ContainsKey(skinItem.A.Key))
                {
                    cont.Add(new CuiButton()
                    {
                        RectTransform =
                        {
                            AnchorMin = "0 1",
                            AnchorMax = "0 1",
                            OffsetMin = $"{1} {-18}",
                            OffsetMax = $"{18} {-1}"
                        },
                        Button =
                        {
                            Command = $"uiskinmenu setizbranoe {weapon} {skinItem.A.Key} {page} {itemId}",
                            Color = HexToRustFormat("#dead39"),
                            Sprite = "assets/icons/favourite_servers.png",
                        },
                        Text = { Text = "" }
                    }, Layer + "-Search" + ".Player" + skinItem.B);
                }
                else
                {
                    cont.Add(new CuiButton()
                    {
                        RectTransform =
                        {
                            AnchorMin = "0 1",
                            AnchorMax = "0 1",
                            OffsetMin = $"{1} {-18}",
                            OffsetMax = $"{18} {-1}"
                        },
                        Button =
                        {
                            Command = $"uiskinmenu setizbranoe {weapon} {skinItem.A.Key} {page} {itemId}",
                            Color = "1 1 1 1",
                            Sprite = "assets/icons/favourite_servers.png",
                        },
                        Text = { Text = "" }
                    }, Layer + "-Search" + ".Player" + skinItem.B);
                }

                if (permission.UserHasPermission(player.UserIDString, cfg.canusedefault))
                {
                    if (playerData.TryGetValue(player.userID, out weapons) && weapons._defaultSkins.ContainsKey(weapon) && weapons._defaultSkins[weapon].skinId == skinItem.A.Key)
                    {
                        cont.Add(new CuiButton()
                        {
                            RectTransform =
// ... [Code preview truncated due to length. Full source in attached file] ...

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