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

FREE IQBackpack : 1.36.57 1.36.57

Нет прав для скачивания
C#:
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using Network;
using System;
using UnityEngine;
using System.Linq;
using ConVar;
using Newtonsoft.Json;
using VLB;
using System.Text;
using System.Collections;
using Oxide.Core;
using System.Collections.Generic;
using Pool = Facepunch.Pool;
using Object = System.Object;
namespace Oxide.Plugins {
    [Info("IQBackpack", "Mercury", "1.36.57")]
    [Description("Just your favorite backpack :)")]
    class IQBackpack : RustPlugin {
        ItemContainer.CanAcceptResult? CanAcceptItem(ItemContainer container, Item item, int targetPos) {
            try {
                if (container == null || item == null) return null;
                BasePlayer player = container.playerOwner;
                if (player == null) {
                    if (config.TurnedsSetting.Types == TypeBackpack.Wear) {
                        if(config.TurnedsSetting.NoMoveStorage) if (item.skin == config.BackpackItem.SkinID) return ItemContainer.CanAcceptResult.CannotAccept;
                        NextTick(() => {
                            if (item.parent == null || item.parent.entityOwner == null || item.parent.entityOwner.net == null) return;
                            if (item.skin != config.BackpackItem.SkinID) return;
                            UInt64 NetID = item.parent.entityOwner.net.ID.Value;
                            if (NetID == 0) return;
                            if (ContainerGetPlayer.ContainsKey(NetID)) {
                                CommunityEntity.ServerInstance.ClientRPCEx(new SendInfo(ContainerGetPlayer[NetID]), null, "DestroyUI", "UI_BACKPACK_VISUAL");
                                CommunityEntity.ServerInstance.ClientRPCEx(new SendInfo(ContainerGetPlayer[NetID]), null, "DestroyUI", "HIDE_LAYER");
                                CommunityEntity.ServerInstance.ClientRPCEx(new SendInfo(ContainerGetPlayer[NetID]), null, "DestroyUI", "UNHIDE_LAYER");
                            }
                        }
                        );
                    }
                    return null;
                }
                else {
                    if (!player.userID.IsSteamId() || player.IsNpc) return null;
                    if (!PlayerUseBackpacks.Contains(player) && !PlayerUpgrades.ContainsKey(player)) return null;
                    if (config.TurnedsSetting.Types == TypeBackpack.Wear) if (item.skin == config.BackpackItem.SkinID) {
                        if (item.IsLocked()) return ItemContainer.CanAcceptResult.CannotAccept;
                        CuiHelper.DestroyUi(player, InterfaceBuilder.UI_Backpack_Visual);
                        CuiHelper.DestroyUi(player, "HIDE_LAYER");
                        CuiHelper.DestroyUi(player, "UNHIDE_LAYER");
                        BackpackRemoveSpine(player);
                        return null;
                    }
                    if (item.IsLocked() && item.HasFlag(global : : Item.Flag.IsOn) && (container == player.inventory.containerMain || container == player.inventory.containerBelt || container == player.inventory.containerWear)) return ItemContainer.CanAcceptResult.CannotAccept;
                    Configuration.Backpack.BackpackCraft OptionBackpack = GetBackpackOption(player);
                    if (OptionBackpack == null) return null;
                    if (usePlayerSorteds.Contains(player)) return null;
                    if ((OptionBackpack.BlackListItems.Contains(item.info.shortname) && item.IsLocked()) || (PlayerUpgrades.ContainsKey(player) && PlayerUpgrades[player] != null && PlayerUpgrades[player].Container != null && item.IsLocked())) return ItemContainer.CanAcceptResult.CannotAccept;
                }
            }
            catch (Exception e) {
                LogToFile("IQBackpack", $"===== START ===== \n {e.Message}\n\n{e}\n ===== END =====", this);
                PrintWarning(LanguageEn ? "An unknown action has come out!Inform the developer about this and attach .log (IQBackpack/Debug/Logs)" : "Вышло неизвестное действие!Сообщите разработчику об этом и прикрепите .log (IQBackpack/Debug/Logs)");
                throw;
            }
            return null;
        }
        private static Configuration config = new Configuration();
        private class Configuration {
            internal class Turneds {
                internal class BackpackVisualSetting {
                    [JsonProperty(LanguageEn ? "Size backpack model" : "Размер модели рюкзака")]
                    public Single SizeBackpack;
                    internal class QuaternionPos {
                        public Single Y;
                        public Single X;
                        public Single Z;
                        public Single W;
                    }
                    [JsonProperty(LanguageEn ? "Local rotation of the backpack on the player's back (Quaternion)" : "Локальная ротация рюкзака на спине игрока (Quaternion)")]
                    public QuaternionPos LocalRotation;
                    [JsonProperty(LanguageEn ? "Local position of the backpack on the player's back" : "Локальная позиция рюкзака на спине игрока")]
                    public Vector3 LocalPosition;
                }
                [JsonProperty(LanguageEn ? "Automatically clear players' backpack upgrades after a wipe (true - yes/false - no)" : "Автоматически очищать улучшение рюкзаков игроков после вайпа (true - да/false - нет)")]
                public Boolean WipeCleaningUpdates = false;
                [JsonProperty(LanguageEn ? "Use the opportunity to improve backpacks and increase slots in it (true - yes/false - no) [Additionally configurable in each backpack, please note - this is a general parameter, detailed configuration in variations of backpacks]" : "Использовать возможность улучшать рюкзаки и увеличивать в нем слоты (true - да/false - нет) [Дополнительно настраивается в каждом рюкзаке, учтите - это общий параметр, детальная настройка в вариациях рюкзаков]")]
                public Boolean UseUpgradeBackpack = true;
                [JsonProperty(LanguageEn ? "The type of Entity in which the opportunity to improve the backpack will open : 0 - Workbench, 1 - RepairBox" : "Тип Entity в котором будет открываться возможность улучшить рюкзак : 0 - Верстак, 1 - Ремонтный стол")]
                public TypeUseUpgradeEntity TypeUseUpgradeEntitys = TypeUseUpgradeEntity.Workbench;
                [JsonProperty(LanguageEn ? "Configuring the interface" : "Настройка интерфейса")]
                public VisualBackpackSlot VisualBackpackSlots = new VisualBackpackSlot();
                internal class SaveItemsWipe {
                    [JsonProperty(LanguageEn ? "Enable players to save N number of items for the next wipe (automatic clearing after wipe must be enabled)" : "Использовать возможность игрокам сохранить N количество предметов на следующий вайп (должна быть включена автоматическая очистка после вайпа)")]
                    public Boolean useSaveItems;
                    [JsonProperty(LanguageEn ? "Setting up player highlighting on the map after saving items for the next wipe" : "Настройка подсвечивания игрока на карте после сохранения предметов на следующий вайп")]
                    public MapMarkerController mapMarkerController = new();
                    [JsonProperty(LanguageEn ? "Notify all players that a player is transferring or has canceled the transfer of items" : "Оповещать всех игроков о том, что игрок переносит или отменил перенос предметов")]
                    public Boolean useMessageAlert;
                    [JsonProperty(LanguageEn ? "Reload before transferring items to the next WIPE" : "Перезарядка перед переносом предметов на следующий WIPE")]
                    public Int32 cooldownTransferItems;
                    internal class MapMarkerController {
                        [JsonProperty(LanguageEn ? "To highlight a player on the map after they save items for transfer (removing the items will remove the highlight)" : "Подсвечивать игрока на карте после того как он сохранит предметы для переноса (при удалении предметов - он перестанет быть подсвечен)")]
                        public Boolean useMapMarkerPlayer;
                        [JsonProperty(LanguageEn ? "The radius of the placemark display on the map" : "Радиус отображения метки на карте")]
                        public Single radius;
                        [JsonProperty(LanguageEn ? "Time to update the placemark (In seconds)" : "Время обновления метки (В секундах)" )]
                        public Single refreshRate;
                        [JsonProperty(LanguageEn ? "Название метки (%NAME% - выведет имя игрока)" : "Marker name (%NAME% - displays the player's name)")]
                        public String markerName;
                        [JsonProperty(LanguageEn ? "HEX Marker color" : "HEX цвет метки")]
                        public String color;
                        [JsonProperty(LanguageEn ? "HEX color of the marker outline" : "HEX цвет обводки метки")]
                        public String outLineColor;
                    }
                    [JsonProperty(LanguageEn ? "How many days after the wipe will it be possible to save items in the backpack" : "Через сколько дней после вайпа можно будет сохранить предметы в рюкзаке")]
                    public Int32 dayUnlockButton;
                    [JsonProperty(LanguageEn ? "How many items can be transferred to the next wipe based on the privilege [rights] = quantity" : "Сколько предметов можно перенести на следующий вайп по привилегии [права] = количество")]
                    public Dictionary<String, Int32> amountTransferItems = new Dictionary<String, Int32>();
                    [JsonProperty(LanguageEn ? "Blacklist of items to be ignored during saving (short names)" : "Черный список предметов, которые будут игнорироваться при сохранении (шортнейм)")]
                    public List<String> saveBlackList = new List<String>();
                }
                [JsonProperty(LanguageEn ? "Disallow transferring backpacks to crates (true - yes/false - no)" : "Запретить переносить рюкзак в ящики (true - да/false - нет)")]
                public Boolean NoMoveStorage = false;
                [JsonProperty(LanguageEn ? "Use the opportunity to craft a backpack (true - yes/false - no)" : "Использовать возможность скрафтить рюкзак (true - да/false - нет)")]
                public Boolean UseCrafting = true;
                [JsonProperty(LanguageEn ? "Close the backpack when clicking on the UI again/using the bind if it is open" : "Закрывать рюкзак при повторном нажатии на UI/использовании бинда, если он открыт")]
                public Boolean ClosePressedAgain = true;
                [JsonProperty(LanguageEn ? "Display a backpack behind the player's back (a backpack model, works on all turns and bends of the player) [ATTENTION, USE THIS ON THE PVE SERVER, BECAUSE OF THE FEATURES OF THE GAME, SUCH A BACKPACK ON THE BACK WILL NOT TAKE DAMAGE]" : "Отображать рюкзак за спиной игрока(модельку рюкзака, работает на всех поворотах и изгибах игрока) [ВНИМАНИЕ, ИСПОЛЬЗУЙТЕ ЭТО НА PVE СЕРВЕРЕ, ИЗ-ЗА ОСОБЕННОСТЕЙ ИГРЫ В ТАКОЙ РЮКЗАК НА СПИНЕ НЕ БУДЕТ ПРОХОДИТЬ УРОН]")]
                public Boolean UseSpineBackpack = false;
                internal class VisualBackpackSlot {
                    [JsonProperty(LanguageEn ? "Use the display of the backpack UI near the slots (true - yes/false - no)" : "Использовать отображение UI рюкзака возле слотов (true - да/false - нет)")]
                    public Boolean UseVisual = true;
                    [JsonProperty(LanguageEn ? "Display the number of slots in the backpack on the UI (true - yes/false - no)" : "Отображать количество слотов в рюкзаке на UI (true - да/false - нет)")]
                    public Boolean UseSlots = true;
                    [JsonProperty(LanguageEn ? "Allow to open the backpack by clicking on the UI interface (true - yes/false - no)" : "Разрешить открывать рюкзак нажава на UI интерфейс (true - да/false - нет)")]
                    public Boolean UseButton = true;
                    [JsonProperty(LanguageEn ? "Enable support for collapsing the UI interface" : "Включить поддержку сворачивания UI-интерфейса")]
                    public Boolean UseHideButton;
                    [JsonProperty(LanguageEn ? "Setting the UI position for the hide button" : "Настройка позиции UI для кнопки скрытия")]
                    public Position PositionHide = new Position();
                    [JsonProperty(LanguageEn ? "Link to the image for hiding the backpack UI" : "Ссылка на картинку для скрытия UI рюкзака")]
                    public String UrlButtonHide;
                    [JsonProperty(LanguageEn ? "Link to the image for unhiding the backpack UI" : "Ссылка на картинку для раскрытия UI рюкзака")]
                    public String UrlButtonUnHide;
                    [JsonProperty(LanguageEn ? "Adjusting the colors of the fullness bar" : "Настройка цветов полосы заполненности")]
                    public ColorProgress ColorProgressBar = new ColorProgress();
                    [JsonProperty(LanguageEn ? "Setting up the position of the UI slot with a backpack" : "Настройка позиции UI слота с рюкзаком")]
                    public Position PositionSlotVisual = new Position();
                    [JsonProperty(LanguageEn ? "Customizing the UI position to improve the backpack" : "Настройка позиции UI для улучшения рюкзака")]
                    public Position PositionUpgrade = new Position();
                    internal class ColorProgress {
                        [JsonProperty(LanguageEn ? "The color of the fullness band when the backpack is filled at >30%" : "Цвет полосы заполненности, когда рюкзак заполнен на >30%")]
                        public String ColorMinimal = "0.44 0.53 0.26 1.00";
                        [JsonProperty(LanguageEn ? "The color of the fullness band when the backpack is filled at >60%" : "Цвет полосы заполненности, когда рюкзак заполнен на >60%")]
                        public String ColorAverage = "0.98 0.53 0.26 1.00";
                        [JsonProperty(LanguageEn ? "The color of the fullness band when the backpack is filled to >80%" : "Цвет полосы заполненности, когда рюкзак заполнен на >80%")]
                        public String ColorMaximum = "0.98 0.20 0.28 1.00";
                    }
                    internal class Position {
                        public String AnchorMin;
                        public String AnchorMax;
                        public String OffsetMin;
                        public String OffsetMax;
                    }
                }
                [JsonProperty(LanguageEn ? "Automatically clear the inventory of players' backpacks after the wipe (true - yes/false - no)" : "Автоматически очищать инвентарь рюкзаков игроков после вайпа (true - да/false - нет)")]
                public Boolean WipeCleaning = false;
                [JsonProperty(LanguageEn ? "Transferring items to the next wipe" : "Перенос предметов на следующий вайп")]
                public SaveItemsWipe WipeSaveItems = new SaveItemsWipe();
                [JsonProperty(LanguageEn ? "The type of work of the backpack: 0 - you need to put it on to use, 1 - only permissions are required (from the variations of backpacks)" : "Тип работы рюкзака : 0 - требуется надеть его, чтобы пользоватья, 1 - требуются лишь права(из вариаций рюкзаков)")]
                public TypeBackpack Types = TypeBackpack.Wear;
                [JsonProperty(LanguageEn ? "Type of backpack dropout : 0 - Does not drop out at death, 1 - Throws objects around the corpse, 2 - Throws out a backpack with objects" : "Тип выпадения рюкзака : 0 - Не выпадает при смерти, 1 - Выбрасывает предметы вокруг трупа, 2 - Выбрасывает рюкзак с предметами")]
                public TypeDropBackpack TypeDropBackpack = TypeDropBackpack.DropBackpack;
                [JsonProperty(LanguageEn ? "Time to remove the backpack when falling out (Works with : 2 - Throws the backpack with objects)" : "Время удаления рюкзака при выпадении (Работает с : 2 - Выбрасывает рюкзак с предметами)")]
                public Single RemoveBackpack = 200f;
                [JsonProperty(LanguageEn ? "Setting Backpack Model" : "Настройки модели рюкзака")]
                public BackpackVisualSetting VisualBackpack = new BackpackVisualSetting();
            }
            [JsonProperty(LanguageEn ? "Setting up a backpack" : "Настройка рюкзака")]
            public Backpack BackpackItem = new Backpack();
            [JsonProperty(LanguageEn ? "Configuring supporting plugins" : "Настройка поддерживающих плагинов")]
            public Reference References = new Reference();
            internal class Reference {
                [JsonProperty(LanguageEn ? "Setting IQChat" : "Настройка IQChat")]
                public IQChat IQChatSetting = new IQChat();
                internal class IQChat {
                    [JsonProperty(LanguageEn ? "IQChat : Custom prefix in the chat" : "IQChat : Кастомный префикс в чате")]
                    public String CustomPrefix = "[IQBackpack]";
                    [JsonProperty(LanguageEn ? "IQChat : Custom avatar in the chat (If required)" : "IQChat : Кастомный аватар в чате(Если требуется)")]
                    public String CustomAvatar = "0";
                    [JsonProperty(LanguageEn ? "IQChat : Use UI notifications" : "IQChat : Использовать UI уведомления")]
                    public Boolean UIAlertUse = false;
                }
            }
            public static Configuration GetNewConfiguration() {
                return new Configuration {
                    BackpackItem = new Backpack {
                        Shortname = "burlap.gloves", SkinID = 2726640855, UrlBackpack = "https://i.postimg.cc/G2F6jgbz/rPeKd9R.png", BackpacOption = new List<Backpack.BackpackCraft> {
                            new Backpack.BackpackCraft {
                                AmountSlot = 7, Permissions = "iqbackpack.7slot", BlackListItems = new List<String> {
                                }
                                , CraftItems = new List<Backpack.BackpackCraft.ItemCraft> {
                                }
                                , UpgradeList = new List<Backpack.BackpackCraft.UpgradeBackpack> {
                                }
                                ,
                            }
                            , new Backpack.BackpackCraft {
                                AmountSlot = 15, Permissions = "iqbackpack.15slot", BlackListItems = new List<String> {
                                    "rocket.launcher", "ammo.rocket.basic", "explosive.satchel", "supply.signal", "explosive.timed",
                                }
                                , CraftItems = new List<Backpack.BackpackCraft.ItemCraft> {
                                    new Backpack.BackpackCraft.ItemCraft {
                                        Shortname = "leather", Amount = 50, SkinID = 0
                                    }
                                    , new Backpack.BackpackCraft.ItemCraft {
                                        Shortname = "cloth", Amount = 200, SkinID = 0
                                    }
                                    , new Backpack.BackpackCraft.ItemCraft {
                                        Shortname = "sewingkit", Amount = 10, SkinID = 0
                                    }
                                    ,
                                }
                                , UpgradeList = new List<Backpack.BackpackCraft.UpgradeBackpack> {
                                    new Backpack.BackpackCraft.UpgradeBackpack {
                                        SlotUpgrade = 3, CraftItems = new List<Backpack.BackpackCraft.ItemCraft> {
                                            new Backpack.BackpackCraft.ItemCraft {
                                                Shortname = "burlap.gloves", Amount = 1, SkinID = 2726640855
                                            }
                                            , new Backpack.BackpackCraft.ItemCraft {
                                                Shortname = "leather", Amount = 150, SkinID = 0
                                            }
                                            , new Backpack.BackpackCraft.ItemCraft {
                                                Shortname = "cloth", Amount = 300, SkinID = 0
                                            }
                                            , new Backpack.BackpackCraft.ItemCraft {
                                                Shortname = "sewingkit", Amount = 5, SkinID = 0
                                            }
                                            , new Backpack.BackpackCraft.ItemCraft {
                                                Shortname = "metal.fragments", Amount = 1000, SkinID = 0
                                            }
                                            ,
                                        }
                                    }
                                    , new Backpack.BackpackCraft.UpgradeBackpack {
                                        SlotUpgrade = 10, CraftItems = new List<Backpack.BackpackCraft.ItemCraft> {
                                            new Backpack.BackpackCraft.ItemCraft {
                                                Shortname = "burlap.gloves", Amount = 1, SkinID = 2726640855
                                            }
                                            , new Backpack.BackpackCraft.ItemCraft {
                                                Shortname = "leather", Amount = 500, SkinID = 0
                                            }
                                            , new Backpack.BackpackCraft.ItemCraft {
                                                Shortname = "cloth", Amount = 1000, SkinID = 0
                                            }
                                            , new Backpack.BackpackCraft.ItemCraft {
                                                Shortname = "sewingkit", Amount = 25, SkinID = 0
                                            }
                                            , new Backpack.BackpackCraft.ItemCraft {
                                                Shortname = "metal.fragments", Amount = 15000, SkinID = 0
                                            }
                                            ,
                                        }
                                    }
                                    ,
                                }
                            }
                        }
                    }
                    , TurnedsSetting = new Turneds {
                        Types = TypeBackpack.Wear, WipeCleaning = false, WipeCleaningUpdates = false, WipeSaveItems = new Turneds.SaveItemsWipe() {
                            useMessageAlert = false, useSaveItems = false, cooldownTransferItems = 3600, mapMarkerController = new Turneds.SaveItemsWipe.MapMarkerController {
                                useMapMarkerPlayer = false, radius = 0.65f, refreshRate = 0.2f, markerName = "%NAME%", color = "#ff4948", outLineColor = "#333336",
                            }
                            , dayUnlockButton = 4, amountTransferItems = new Dictionary<String, Int32>() {
                                ["iqbackpack.premium"]
                                = 10, ["iqbackpack.vip"] = 6, ["iqbackpack.default"] = 3,
                            }
                            , saveBlackList = new List<String>() {
                                "shortname", "shortname",
                            }
                            ,
                        }
                        , NoMoveStorage = false, UseCrafting = true, UseUpgradeBackpack = true, ClosePressedAgain = true, UseSpineBackpack = false, TypeUseUpgradeEntitys = TypeUseUpgradeEntity.Workbench, VisualBackpack = new Turneds.BackpackVisualSetting() {
                            SizeBackpack = 1f, LocalPosition = new Vector3(-0.05f, 0.03f, 0f), LocalRotation = new Turneds.BackpackVisualSetting.QuaternionPos() {
                                X = -3f, Y = 0f, W = 0f, Z = 3f,
                            }
                        }
                        , TypeDropBackpack = TypeDropBackpack.DropBackpack, RemoveBackpack = 200f, VisualBackpackSlots = new Turneds.VisualBackpackSlot {
                            UseVisual = true, UseSlots = true, UseButton = true, UseHideButton = false, PositionHide = new Turneds.VisualBackpackSlot.Position() {
                                AnchorMin = "0.5 0", AnchorMax = "0.5 0", OffsetMin = "-216.93200 63.66600", OffsetMax = "-203.724 78.087",
                            }
                            , UrlButtonHide = "https://i.postimg.cc/hG1y57rV/Hide.png", UrlButtonUnHide = "https://i.postimg.cc/15MD2rhm/unhide.png", ColorProgressBar = new Turneds.VisualBackpackSlot.ColorProgress {
                                ColorMinimal = "0.44 0.53 0.26 1.00", ColorAverage = "0.98 0.53 0.26 1.00", ColorMaximum = "0.98 0.20 0.28 1.00",
                            }
                            , PositionSlotVisual = new Turneds.VisualBackpackSlot.Position {
                                AnchorMin = "0.5 0", AnchorMax = "0.5 0", OffsetMin = "-264.276 17.943", OffsetMax = "-203.724 78.087"
                            }
                            , PositionUpgrade = new Turneds.VisualBackpackSlot.Position {
                                AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "194.836 -36.769", OffsetMax = "575.164 36.785"
                            }
                        }
                        ,
                    }
                    , References = new Reference {
                        IQChatSetting = new Reference.IQChat {
                            CustomAvatar = "0", CustomPrefix = "[IQBackpack] ", UIAlertUse = false,
                        }
                    }
                }
                ;
            }
            [JsonProperty(LanguageEn ? "Additional configuration" : "Дополнительная настройка")]
            public Turneds TurnedsSetting = new Turneds();
            internal class Backpack {
                [JsonProperty(LanguageEn ? "Shortname for a backpack (you need an item that is clothing)" : "Shortname для рюкзака (нужен предмет, который является одеждой)")]
                public String Shortname = "burlap.gloves";
                [JsonProperty(LanguageEn ? "Backpack SkinID" : "SkinID рюкзака")]
                public UInt64 SkinID = 2726640855;
                [JsonProperty(LanguageEn ? "Link to the picture to display the backpack" : "Ссылка на картинку для отображения рюкзака")]
                public String UrlBackpack = "https://i.postimg.cc/G2F6jgbz/rPeKd9R.png";
                [JsonProperty(LanguageEn ? "Variations of backpacks by privileges (An available set is given to the player who is higher than others)" : "Вариации рюкзаков по привилегиям (Дается доступный набор игроку, который выше других)")]
                public List<BackpackCraft> BackpacOption = new List<BackpackCraft>();
                internal class BackpackCraft {
                    [JsonProperty(LanguageEn ? "Permission to be able to craft and carry this backpack (do not leave this field empty, otherwise it will not be taken into account)" : "Права для возможности крафтить и носить данный рюкзак(не оставляйте это поле пустым, иначе оно не будет учитываться)")]
                    public String Permissions = "iqbackpack.7slot";
                    [JsonProperty(LanguageEn ? "The amount slots in this backpack" : "Количество слотов у данного рюкзака")]
                    public Int32 AmountSlot = 7;
                    [JsonProperty(LanguageEn ? "Blacklist of items for this backpack" : "Черный список предметов для данного рюкзака")]
                    public List<String> BlackListItems = new List<String>();
                    [JsonProperty(LanguageEn ? "Backpack Crafting Items" : "Предметы для крафта рюкзака")]
                    public List<ItemCraft> CraftItems = new List<ItemCraft>();
                    [JsonProperty(LanguageEn ? "Setting upgrade backpack improvements (Upgrades will be gradual depending on the sheet, top -> down (maximum number of slots - 42))" : "Настройка улучшений рюкзака (Улучшение будет постепенное в зависимости от листа, сверху -> вниз (максимальное количество слотов - 42))")]
                    public List<UpgradeBackpack> UpgradeList = new List<UpgradeBackpack>();
                    internal class UpgradeBackpack {
                        [JsonProperty(LanguageEn ? "Items to upgrade to this level" : "Предметы для улучшения на этот уровень")]
                        public List<ItemCraft> CraftItems = new List<ItemCraft>();
                        [JsonProperty(LanguageEn ? "How many slots to add for this improvement" : "Сколько слотов добавлять за это улучшение")]
                        public Int32 SlotUpgrade;
                    }
                    internal class ItemCraft {
                        public String Shortname;
                        public UInt64 SkinID;
                        [JsonProperty(LanguageEn ? "Amount" : "Количество")]
                        public Int32 Amount;
                    }
                }
            }
        }
        void OnPlayerDisconnected(BasePlayer player, string reason) => BackpackRemoveSpine(player);
        private void TakeItems(BasePlayer player, List<Configuration.Backpack.BackpackCraft.ItemCraft> BPCraft, ItemContainer contaner = null) {
            Int32 Index = 0;
            List<Int32> ItemList = new List<Int32>();
            List<Item> playerInventoryItems = null;
            List<Item> ContainerItems = contaner == null ? (playerInventoryItems = GetAllItems(player)) : contaner.itemList;
            foreach (Configuration.Backpack.BackpackCraft.ItemCraft ItemTake in BPCraft) {
                ItemList.Add(ItemTake.Amount);
                foreach (Item ItemPlayer in ContainerItems.Where(x => x.skin == ItemTake.SkinID && x.info.shortname == ItemTake.Shortname)) {
                    if (ItemList[Index] <= 0) continue;
                    ItemList[Index] -= ItemPlayer.amount;
                    ItemPlayer.UseItem(ItemList[Index] > 0 ? ItemList[Index] : ItemTake.Amount);
                }
                Index++;
            }
            if (playerInventoryItems != null) Pool.FreeUnmanaged(ref playerInventoryItems);
        }
        internal class BackpackInfo {
            public Int32 AmountSlot = 0;
            public Int32 IndexUpgrade = -1;
            public List<SavedItem> Items = new List<SavedItem>();
            public Boolean hideUI = false;
            public Boolean useSaveItems = false;
            public Double cooldownTransfer;
            internal class SavedItem {
                public Int32 TargetSlot;
                public String Shortname;
                public Int32 Itemid;
                public Single Condition;
                public Single Maxcondition;
                public Int32 Amount;
                public Int32 Ammoamount;
                public String Ammotype;
                public Int32 Flamefuel;
                public UInt64 Skinid;
                public String Name;
                public Boolean Weapon;
                public Int32 Blueprint;
                public Single BusyTime;
                public Boolean OnFire;
                public Boolean isLocked;
                public String FileContentsArray;
                public UInt64 IdPhoto;
                public String Text;
                public Int32 GrowableGenes;
                public Int32 CountSlotsArmor;
                public List<SavedItem> Mods;
            }
        }
        private readonly DateTime RealTime = DateTime.UtcNow.Date;
        protected override void LoadDefaultConfig() => config = Configuration.GetNewConfiguration();
        private Dictionary<BaseEntity, CustomMapMarker> MapMarkers = new();
        void OnIQPermissionInitialized() {
            if (config.TurnedsSetting.Types == TypeBackpack.OnlyPermission) {
                Subscribe("OnUserPermissionGranted");
                Subscribe("OnUserPermissionRevoked");
                Subscribe("OnUserGroupAdded");
                Subscribe("OnUserGroupRemoved");
            }
        }
        [ChatCommand("backpack")]
        void BackpackCraftMenu(BasePlayer player) {
            if (IsDuel(player.userID.Get())) return;
            if (!config.TurnedsSetting.UseCrafting || config.TurnedsSetting.Types == TypeBackpack.OnlyPermission) return;
            if (_interface == null) {
                SendChat(GetLang("BACKPACK_NO_INITIALIZE", player.UserIDString), player);
                return;
            }
            DrawUI_Backpack_Main(player);
        }
        protected override void SaveConfig() => Config.WriteObject(config);
        private void DrawUI_Backpack_ItemCrafts(BasePlayer player) {
            if (_interface == null) return;
            if (!config.TurnedsSetting.UseCrafting || config.TurnedsSetting.Types == TypeBackpack.OnlyPermission) return;
            Configuration.Backpack.BackpackCraft BCraft = GetBackpackOption(player);
            if (BCraft == null || BCraft.CraftItems == null) return;
            Int32 ItemCount = 0;
            Single itemMinPosition = 219f;
            Single itemWidth = 0.15f;
            /// Ширина
            Single itemMargin = 0.062f;
            /// Расстояние между
            Int32 itemCount = BCraft.CraftItems.Count;
            Single itemMinHeight = 0.84f;
            // Сдвиг по вертикали
            Single itemHeight = 0.16f;
            /// Высота
            Int32 ItemTarget = 5;
            if (itemCount > ItemTarget) {
                itemMinPosition = 0.5f - ItemTarget / 2f * itemWidth - (ItemTarget - 1) / 2f * itemMargin;
                itemCount -= ItemTarget;
            }
            else itemMinPosition = 0.5f - itemCount / 2f * itemWidth - (itemCount - 1) / 2f * itemMargin;
            foreach (Configuration.Backpack.BackpackCraft.ItemCraft item in BCraft.CraftItems) {
                InterfaceBuilder.DrawBackpack_Craft(player, $"{itemMinPosition} {itemMinHeight}", $"{itemMinPosition + itemWidth} {itemMinHeight + itemHeight}", ItemManager.FindItemDefinition(item.Shortname).itemid, UInt32.Parse(item.SkinID.ToString()), item.Amount, HaveItem(player, item.Shortname, item.Amount, item.SkinID) ? "0.57 1.00 0.65 1.00" : "0.98 0.13 0.18 1.00");
                ItemCount++;
                itemMinPosition += (itemWidth + itemMargin);
                if (ItemCount % ItemTarget == 0) {
                    itemMinHeight -= (itemHeight + (itemMargin * 0.5f));
                    if (itemCount > ItemTarget) {
                        itemMinPosition = 0.5f - ItemTarget / 2f * itemWidth - (ItemTarget - 1) / 2f * itemMargin;
                        itemCount -= ItemTarget;
                    }
                    else itemMinPosition = 0.5f - itemCount / 2f * itemWidth - (itemCount - 1) / 2f * itemMargin;
                }
            }
        }
        private class CustomMapMarker : MonoBehaviour {
            private MapMarkerGenericRadius generic;
            public BaseEntity parent;
            public Vector3 position;
            public Single radius;
            public Color color;
            public Color outLineColor;
            public String displayName;
            public Single refreshRate;
            private void OnDestroy() {
                DestroyMakers();
            }
            private VendingMachineMapMarker vending;
            private void UpdatePosition() {
                if (parent.IsValid() == false) {
                    Destroy(this);
                    return;
                }
                Vector3 pos = parent.transform.position;
                transform.position = pos;
                vending.transform.position = pos;
                generic.transform.position = pos;
                UpdateMarkers();
            }
            private void CreateMarkers() {
                vending = GameManager.server.CreateEntity(VendingPrefab, position).GetComponent<VendingMachineMapMarker>();
                vending.markerShopName = displayName;
                vending.enableSaving = false;
                vending.Spawn();
                generic = GameManager.server.CreateEntity(GenericPrefab).GetComponent<MapMarkerGenericRadius>();
                generic.color1 = color;
                generic.color2 = outLineColor;
                generic.radius = radius;
                generic.alpha = 1f;
                generic.enableSaving = false;
                generic.SetParent(vending);
                generic.Spawn();
                UpdateMarkers();
                if (refreshRate > 0f) InvokeRepeating(nameof(UpdatePosition), refreshRate, refreshRate);
            }
            private void Start() {
                transform.position = position;
                CreateMarkers();
            }
            private void DestroyMakers() {
                if (vending.IsValid()) vending.Kill();
                if (generic.IsValid()) generic.Kill();
            }
            public void UpdateMarkers() {
                vending.SendNetworkUpdate();
                generic.SendUpdate();
                generic.SendNetworkUpdate();
            }
        }
        private Dictionary<BasePlayer, BackpackBehaviour> PlayerBackpack = new Dictionary<BasePlayer, BackpackBehaviour>();
        void OnServerInitialized() {
            _ = this;
            TimeCreatedSave = SaveRestore.SaveCreatedTime.Date;
            WipeTime = RealTime.Subtract(TimeCreatedSave).Days;
            ServerMgr.Instance.StartCoroutine(DownloadImages());
            RegisteredPermissions();
            if ((config.TurnedsSetting.WipeCleaning && config.TurnedsSetting.WipeSaveItems.useSaveItems) && IQWipeBlock && IQWipeBlock.Version < new VersionNumber(1, 8, 7)) {
                PrintWarning(LanguageEn ? "You have IQWipeBlock installed, and the item transfer feature is enabled. However, you have an outdated version of IQWipeBlock installed, which may lead to conflicts and alter the plugin's behavior." : "У вас установлен IQWipeBlock и включена функция переноса предметов. Но у вас установлена устаревшая версия IQWipeBlock, может возникнуть конфликт и поведение плагина изменится");
            }
            if(config.TurnedsSetting.TypeDropBackpack == TypeDropBackpack.NoDrop) {
                Unsubscribe("OnPlayerDeath");
                Unsubscribe("OnEntityKill");
            }
            if (config.TurnedsSetting.Types == TypeBackpack.OnlyPermission) {
                Unsubscribe("CanWearItem");
                if (!IQPermissions) {
                    Subscribe("OnUserPermissionGranted");
                    Subscribe("OnUserPermissionRevoked");
                    Subscribe("OnUserGroupAdded");
                    Subscribe("OnUserGroupRemoved");
                }
            }
            else {
                Unsubscribe("OnUserPermissionGranted");
                Unsubscribe("OnUserPermissionRevoked");
                Unsubscribe("OnUserGroupAdded");
                Unsubscribe("OnUserGroupRemoved");
            }
            if (!config.TurnedsSetting.UseUpgradeBackpack && !config.TurnedsSetting.WipeSaveItems.useSaveItems) {
                Unsubscribe("CanLootEntity");
                Unsubscribe("OnItemStacked");
                Unsubscribe("OnItemSplit");
                Unsubscribe("CanStackItem");
            }
            if (!config.TurnedsSetting.UseSpineBackpack) Unsubscribe("OnPlayerDisconnected");
        }
        private UInt64 GetBackpackID(BasePlayer player) {
            UInt64 ID = 0;
            if (config.TurnedsSetting.Types == TypeBackpack.Wear) {
                Item Backpack = GetBackpack(player);
                if (Backpack == null) return ID;
                ID = Backpack.uid.Value;
            }
            else ID = player.userID;
            return ID;
        }
        private void RemoveMarkers() {
            foreach (CustomMapMarker marker in MapMarkers.Values) UnityEngine.Object.Destroy(marker);
        }
        public Boolean AddImage(String url, String shortname, UInt64 skin = 0) => (Boolean)ImageLibrary?.Call("AddImage", url, shortname, skin);
        [ConsoleCommand("bp_hide")]
        void BpHideFunctionCommand(ConsoleSystem.Arg arg) {
            BasePlayer player = arg.Player();
            if (player == null) return;
            UInt64 idBackpack = GetBackpackID(player);
            if (!Backpacks.ContainsKey(idBackpack)) return;
            Boolean thisHideStatus = Backpacks[idBackpack].hideUI;
            Backpacks[idBackpack].hideUI = !thisHideStatus;
            if (thisHideStatus) DrawUI_Backpack_Visual(player);
            else CuiHelper.DestroyUi(player, InterfaceBuilder.UI_Backpack_Visual);
            DrawUI_HideOrUnHide(player);
        }
        private Int32 GetSlotsPercent(Single Percent, Single Slots) {
            Single ReturnSlot = (((Single)Slots / 100.0f) * Percent);
            return (Int32)ReturnSlot;
        }
        public static StorageContainer CreateContainer(BasePlayer player) {
            StorageContainer storage = GameManager.server.CreateEntity("assets/prefabs/misc/halloween/coffin/coffinstorage.prefab") as StorageContainer;
            if (storage == null) return null;
            StorageContainer containerEntity = storage as StorageContainer;
            if (containerEntity == null) {
                UnityEngine.Object.Destroy(storage);
                return null;
            }
            UnityEngine.Object.DestroyImmediate(storage.GetComponent<DestroyOnGroundMissing>());
            UnityEngine.Object.DestroyImmediate(storage.GetComponent<GroundWatch>());
            foreach (Collider collider in storage.GetComponentsInChildren<Collider>()) UnityEngine.Object.DestroyImmediate(collider);
            storage.transform.position = new Vector3(player.ServerPosition.x, player.ServerPosition.y - 100f, player.ServerPosition.z);
            storage.panelName = "generic_resizable";
            ItemContainer container = new ItemContainer {
                playerOwner = player
            }
            ;
            container.ServerInitialize((Item)null, _.GetSlotsBackpack(player));
            if ((Int32)container.uid.Value == 0) container.GiveUID();
            container.entityOwner = storage;
            storage._inventory = container;
            storage.OwnerID = player.userID;
            storage._limitedNetworking = false;
            storage.EnableSaving(false);
            storage.SendMessage("SetDeployedBy", player, (SendMessageOptions)SendMessageOptions.DontRequireReceiver);
            storage.Spawn();
            storage.inventory.allowedContents = ItemContainer.ContentsType.Generic;
            //storage.inventory.dirty = true;
            return storage;
        }
        [ChatCommand("wew")]
        private void fjjfjf(BasePlayer player) {
            Item weapon = ItemManager.CreateByName("rifle.ak");
            weapon.name = "TEST AK47 100% YOU BRO";
            Item fff = ItemManager.CreateByName("weapon.mod.oilfiltersilencer");
            fff.name = "TEST 100% БОБРИК";
            player.GiveItem(weapon);
            player.GiveItem(fff);
        }
        [ConsoleCommand("remove_items_bp")]
        void ConsoleCommandRemoveItemsBP(ConsoleSystem.Arg args) {
            BasePlayer player = args.Player();
            if (player == null) return;
            BackpackRemoveSaveItems(player);
        }
        private void OnStartSortedContainer(BasePlayer player, ItemContainer container)  ////IQSorter
        {
            if (!usePlayerSorteds.Contains(player)) usePlayerSorteds.Add(player);
        }
        private Boolean IsValidSaveBP(BasePlayer player) {
            if (!config.TurnedsSetting.WipeSaveItems.useSaveItems && !config.TurnedsSetting.WipeCleaning) return false;
            if (!PlayerBackpack.ContainsKey(player)) return false;
            UInt64 bpID = GetBackpackID(player);
            if (!Backpacks.ContainsKey(bpID)) return false;
            return leftDaySave() <= 0;
        }
        void OnPlayerDeath(BasePlayer player, HitInfo info) {
            if (player == null) return;
            if (!player.userID.IsSteamId() || player.IsNpc) return;
            if (IsDuel(player.userID.Get())) return;
            if (permission.UserHasPermission(player.UserIDString, PermissionNoDropBP)) return;
            Object hookResult = CanDropBackpack(player.userID.Get(), new Vector3());
            if (hookResult is Boolean && (Boolean)hookResult == false) return;
            BackpackRemoveSaveItems(player, true);
            DropBackpack(player, config.TurnedsSetting.TypeDropBackpack);
            return;
        }
        private const String GenericPrefab = "assets/prefabs/tools/map/genericradiusmarker.prefab";
        private Int32 GetBusySlotsBackpack(BasePlayer player) {
            if (config.TurnedsSetting.Types == TypeBackpack.Wear) {
                Item item = GetBackpack(player);
                if (item != null) if (Backpacks.ContainsKey(item.uid.Value)) {
                    return Backpacks[item.uid.Value].Items.Count;
                }
            }
            else {
                if (Backpacks.ContainsKey(player.userID)) return Backpacks[player.userID].Items.Count;
            }
            return 0;
        }
        static Item BuildItem(BackpackInfo.SavedItem sItem) {
            if (sItem.Amount < 1) sItem.Amount = 1;
            Item item = null;
            item = ItemManager.CreateByItemID(sItem.Itemid, sItem.Amount, sItem.Skinid);
            item.position = sItem.TargetSlot;
            if (sItem.Name != null) item.name = sItem.Name;
            if (sItem.Text != null && !String.IsNullOrWhiteSpace(sItem.Text)) item.text = sItem.Text;
            if (sItem.GrowableGenes != 0) GrowableGeneEncoding.EncodeGenesToItem(sItem.GrowableGenes, item);
            if (sItem.Mods != null) {
                if (sItem.CountSlotsArmor != 0 && item.info.category == ItemCategory.Attire) {
                    item.info.TryGetComponent(out ItemModContainerArmorSlot armorContainer);
                    if (armorContainer) armorContainer.CreateAtCapacity(sItem.CountSlotsArmor, item);
                }
                foreach (var mod in sItem.Mods) item.contents.AddItem(BuildItem(mod).info, mod.Amount, mod.Skinid);
            }
            if (item.hasCondition) {
                item.condition = sItem.Condition;
                item.maxCondition = sItem.Maxcondition;
                item.busyTime = sItem.BusyTime;
            }
            if (sItem.Blueprint != 0) item.blueprintTarget = sItem.Blueprint;
            if (sItem.OnFire) item.SetFlag(global : : Item.Flag.OnFire, true);
            if (sItem.isLocked) {
                item.SetFlag(global : : Item.Flag.IsLocked, true);
                item.SetFlag(global : : Item.Flag.IsOn, true);
            }
            FlameThrower flameThrower = item.GetHeldEntity()?.GetComponent<FlameThrower>();
            if (flameThr
// ... [Code preview truncated due to length. Full source in attached file] ...

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