C#:
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using UnityEngine;
using System.Linq;
using System.Text;
using Network;
using ConVar;
using Oxide.Core;
using Object = System.Object;
namespace Oxide.Plugins {
[Info("IQWipeBlock", "IQWipeBlock", "1.11.13")]
[Description("Блокируй по умному с IQWipeBlock")]
class IQWipeBlock : RustPlugin {
/// <summary>
/// Обновление 1./// - Предотвращение возможного дюпа в связке с XSkinMenu
/// </summary>
private const Boolean LanguageEn = true;
#region Reference
[PluginReference]
Plugin IQChat, ImageLibrary, Battles, Duel, Duelist, ArenaTournament, AimTraining, XFarmRoom, OneVSOne, EventHelper, IQBackpack, IQRecycler;
// https://umod.org/plugins/duelist
#region IQChat
public void SendChat(string Message, BasePlayer player, Chat.ChatChannel channel = Chat.ChatChannel.Global) {
var Chat = config.GeneralSetting.ReferenceSettings.ChatSettings;
if (IQChat) if (Chat.UIAlertUse) IQChat?.Call("API_ALERT_PLAYER_UI", player, Message);
else IQChat?.Call("API_ALERT_PLAYER", player, Message, Chat.CustomPrefix, Chat.CustomAvatar);
else player.SendConsoleCommand("chat.add", channel, 0, Message);
}
#endregion
#region ImageLibrary
private String GetImage(String fileName, UInt64 skin = 0) {
var imageId = (String)plugins.Find("ImageLibrary").CallHook("GetImage", fileName, skin);
if (!string.IsNullOrEmpty(imageId)) return imageId;
return String.Empty;
}
public Boolean AddImage(String url, String shortname, UInt64 skin = 0) => (Boolean)ImageLibrary?.Call("AddImage", url, shortname, skin);
public void SendImage(BasePlayer player, String imageName, UInt64 imageId = 0) => ImageLibrary?.Call("SendImage", player, imageName, imageId);
public Boolean HasImage(String imageName) => (Boolean)ImageLibrary?.Call("HasImage", imageName);
#endregion
#region IsDuel
public Boolean IsDuel(UInt64 userID) {
Object obj = Interface.Oxide.RootPluginManager.GetPlugin("AimTraining")?.CallHook("IsArenaPlayer", userID);
if (obj is Boolean) return (Boolean)obj;
if (EventHelper) {
if ((Boolean)EventHelper.CallHook("EMAtEvent", userID)) return true;
}
if (OneVSOne) if ((Boolean)OneVSOne.Call("IsEventPlayer", BasePlayer.FindByID(userID))) return true;
if (Battles) if ((Boolean)Battles.Call("IsPlayerOnBattle", userID)) return true;
if (Duel) if ((Boolean)Duel.Call("IsPlayerOnActiveDuel", BasePlayer.FindByID(userID))) return true;
if (Duelist) if ((Boolean)Duelist.Call("inEvent", BasePlayer.FindByID(userID))) return true;
if (ArenaTournament) if (ArenaTournament.Call<Boolean>("IsOnTournament", userID)) return true;
if (XFarmRoom) if (XFarmRoom.Call<Boolean>("API_PlayerInRoom", userID)) return true;
return false;
}
#endregion
#endregion
#region Vars
private Boolean IsUnlockedAll = false;
readonly static String PermissionIgnoreBlock = "iqwipeblock.ignore";
public enum TypeLock {
Locked, Fire, Flash
}
#endregion
#region Configuration
private static Configuration config = new Configuration();
private class Configuration {
[JsonProperty(LanguageEn ? "Setting up Locks" : "Настройка блокировок")]
public Blocks Block = new Blocks();
[JsonProperty(LanguageEn ? "Configuring the interface" : "Настройка интерфейса")]
public Interfaces Interface = new Interfaces();
[JsonProperty(LanguageEn ? "Configuring the plugin" : "Настройка плагина")]
public GeneralSettings GeneralSetting = new GeneralSettings();
internal class GeneralSettings {
[JsonProperty(LanguageEn ? "Use the label in the player's inventory if the item is locked(the label will be right on the item being locked)" : "Использовать метку в инвентаре игрока если предмет заблокирован(метка будет прям на предмете блокировки)")]
public Boolean UseFlags;
[JsonProperty(LanguageEn ? "Enable menu to open wipeblock" : "Включить меню для открытия вайпблока")]
public Boolean UsePanelButton;
[JsonProperty(LanguageEn ? "Enable the ability to hide the menu to users" : "Включить возможность скрыть меню пользователям")]
public Boolean UseHidePanelButton;
[JsonProperty(LanguageEn ? "Select the label type : 0 - Grid, 1-Flame, 2-Lightning" : "Выберите тип метки : 0 - Сетка, 1 - Пламя, 2 - Молния")]
public TypeLock TypeLock;
[JsonProperty(LanguageEn ? "Display time on all blocked items, regardless of progress" : "Отображать время на всех заблокированных предметах, независимо от прогресса")]
public Boolean UseShowAllTime;
[JsonProperty(LanguageEn ? "Settings for collaboration with other plugins" : "Настройки совместной работы с другими плагинами")]
public ReferenceSetting ReferenceSettings = new ReferenceSetting();
[JsonProperty(LanguageEn ? "Notify players that all items have been fully unlocked (true - yes/false - no).The message is configured in lang" : "Уведомлять игроков о том, что произошла полная разблокировка всех предметов (true - да/false - нет).Сообщение настраивается в lang")]
public Boolean AlertAllUsersUnlocked = true;
[JsonProperty(LanguageEn ? "Notify players every time they log on to the server that all items are unlocked (true - yes/false - no).The message is configured in lang" : "Уведомлять игроков при каждом входе на сервер, что все предметы разблокированы (true - да/false - нет).Сообщение настраивается в lang")]
public Boolean AlertConnectedUserUnlocked = false;
internal class ReferenceSetting {
[JsonProperty(LanguageEn ? "IQChat : Chat Settings" : "IQChat : Настройки чата")]
public ChatSetting ChatSettings = new ChatSetting();
internal class ChatSetting {
[JsonProperty(LanguageEn ? "IQChat : Custom prefix in chat" : "IQChat : Кастомный префикс в чате")]
public String CustomPrefix = "[IQWipeBlock]";
[JsonProperty(LanguageEn ? "IQChat : Custom avatar in the chat (If required)" : "IQChat : Кастомный аватар в чате(Если требуется)")]
public String CustomAvatar = "";
[JsonProperty(LanguageEn ? "IQChat : Use UI notifications" : "IQChat : Использовать UI уведомления")]
public Boolean UIAlertUse = false;
}
}
}
internal class Blocks {
[JsonProperty(LanguageEn ? "Configuring weapon and Tool Locks" : "Настройка блокировок оружия и инструментов")]
public Dictionary<String, BlockElement> BlockWeaponAndTools = new Dictionary<String, BlockElement>();
[JsonProperty(LanguageEn ? "Configuring Gear locks" : "Настройка блокировок снаряжения")]
public Dictionary<String, BlockElement> BlockArmory = new Dictionary<String, BlockElement>();
[JsonProperty(LanguageEn ? "Setting up explosive locks" : "Настройка блокировок взрывчатки")]
public Dictionary<String, BlockElement> BlockBoom = new Dictionary<String, BlockElement>();
[JsonProperty(LanguageEn ? "Unlock additional items after unlocking the main one (true) or jointly (false)" : "Разблокировку дополнительных предметов запускать после разблокировки основного (true) или совместно (false)")]
public Boolean VaribleUnlockMore;
internal class BlockElement {
[JsonProperty(LanguageEn ? "Time to lock this item(in seconds)" : "Время блокировки данного предмета(в секундах)")]
public Int32 TimeBlock;
[JsonProperty(LanguageEn ? "SkinID for the item(if not required, leave the value 0)" : "SkinID для предмета(если не требуется, оставьте значение 0)")]
public UInt64 SkinID;
[JsonProperty(LanguageEn ? "Additional list related to this subject! (Items that can be applied to the main item, example Weapons - > Ammo)" : "Дополнительный список, относящийся к этому предмету! (Предметы, которые можно применить к основному предмету, пример Оружие -> Патроны)")]
public Dictionary<String, Int32> BlockMoreList = new Dictionary<string, int>();
}
}
internal class Interfaces {
[JsonProperty(LanguageEn ? "In which part of the screen will the interface with the lock of weapons and tools be located(0-Left, 1-Center, 2-Right)" : "В какой части экрана будет расположен интерфейс с блокировкой оружия и инструментов(0 - Слева, 1 - Центр, 2 - Справа)")]
public AlignCategory CategoryWeaponTools;
[JsonProperty(LanguageEn ? "In which part of the screen will the interface with the equipment lock be located (0-Left, 1-Center, 2-Right)" : "В какой части экрана будет расположен интерфейс с блокировкой снаряжения (0 - Слева, 1 - Центр, 2 - Справа)")]
public AlignCategory CategoryArmory;
[JsonProperty(LanguageEn ? "In which part of the screen will the interface with blocking explosives and ammunition be located(0-On the Left, 1-In the Center, 2-on the Right)" : "В какой части экрана будет расположен интерфейс с блокировкой взрывчатки и боеприпасов(0 - Слева, 1 - Центр, 2 - Справа)")]
public AlignCategory CategoryBoom;
[JsonProperty(LanguageEn ? "Display the progress of opening an item by filling in the background" : "Отображать прогресс открытия предмета заполнением заднего фона")]
public Boolean UseProgressiveBackground;
[JsonProperty(LanguageEn ? "Display information-instructions, which block is responsible for what" : "Отображать информацию-инструкцию, какой блок за что отвечает")]
public Boolean ShowInformationBlocks;
[JsonProperty(LanguageEn ? "Use consolidated view for items with the same unlock time (true)" : "Использовать объединенный вид разблокировки предметов с одинаковым временем (true)")]
public Boolean ShowUnblockedItemCompareTime;
[JsonProperty(LanguageEn ? "Link to your background (If not required, leave the field blank)" : "Ссылка на свой задний фон(Если не требуется, оставьте поле пустым)")]
public String BackgroundUrl = String.Empty;
[JsonProperty(LanguageEn ? "HEX background color" : "HEX цвет заднего фона")]
public String BacgkroundColor;
[JsonProperty(LanguageEn ? "HEX background color blurr" : "HEX цвет блюра заднего фона")]
public String BackgroundBlurColor;
[JsonProperty(LanguageEn ? "HEX background color blurr of additional items" : "HEX цвет блюра заднего фона дополнительных предметов")]
public String BackgroundMoreBlurColor;
[JsonProperty(LanguageEn ? "HEX text color" : "HEX цвет текста")]
public String Labels;
[JsonProperty(LanguageEn ? "HEX line color" : "HEX цвет линий")]
public String Lines;
[JsonProperty(LanguageEn ? "HEX line color when unblocking" : "HEX цвет линий при разблокировке")]
public String LinesUnblock;
[JsonProperty(LanguageEn ? "HEX background color of the blocked image" : "HEX цвет заднего фона заблокированного")]
public String BlockedPanel;
[JsonProperty(LanguageEn ? "HEX color of the background color of the blocked background" : "HEX цвет блюра заднего фона заблокированного")]
public String BlurBlockedPanel;
[JsonProperty(LanguageEn ? "HEX background color of the next item to unlock" : "HEX цвет заднего фона следующего предмета под разблокировку")]
public String NextBlockedPanel;
[JsonProperty(LanguageEn ? "HEX background color of the unlocked item" : "HEX цвет заднего фона разблокированного предмета")]
public String UnblockedPanel;
[JsonProperty(LanguageEn ? "HEX background color of an unlocked item with additional locks" : "HEX цвет заднего фона разблокированного предмета с дополнительными блокировками")]
public String UnblockedMorePanel;
[JsonProperty(LanguageEn ? "HEX color of the subject lines with additional locks" : "HEX цвет линий предмета с дополнительными блокировками")]
public String PreBlockedMoreLine;
[JsonProperty(LanguageEn ? "Sprite of the blocked element" : "Sprite заблокированного элемента")]
public String SpriteBlocked;
[JsonProperty(LanguageEn ? "Sprite in the quick access menu" : "Sprite в меню быстрого доступа")]
public String SpriteBlockLogo;
[JsonProperty(LanguageEn ? "Should I hide the interface opening button after unlocking all items" : "Скрывать ли кнопку открытия интерфейса после разблока всех предметов")]
public Boolean ButtonIsBlock;
[JsonProperty(LanguageEn ? "Use the time format (Full - D + H + M(/S) - true / Abbreviated - D/H/M/S - false)" : "Использовать формат времени (Полный - Д + Ч + М(/С) - true / Сокращенный - Д/Ч/М/С - false)")]
public Boolean UseFormatTime = false;
[JsonProperty(LanguageEn ? "AnchorMin : The position of the entire quick menu" : "AnchorMin : Позиция всего быстрого меню")]
public String AnchorMinPositionQuickMenu;
[JsonProperty(LanguageEn ? "AnchorMax : The position of the entire quick menu" : "AnchorMax : Позиция всего быстрого меню")]
public String AnchorMaxPositionQuickMenu;
[JsonProperty(LanguageEn ? "OffsetMin : The position of the entire quick menu" : "OffsetMin : Позиция всего быстрого меню")]
public String OffsetMinPositionQuickMenu;
[JsonProperty(LanguageEn ? "OffsetMax : The position of the entire quick menu" : "OffsetMax : Позиция всего быстрого меню")]
public String OffsetMaxPositionQuickMenu;
[JsonProperty(LanguageEn ? "AnchorMin : Icon position in the Quick access menu" : "AnchorMin : Позиция иконки в меню быстрого доступа")]
public String AnchorMinPositionSpriteLogo;
[JsonProperty(LanguageEn ? "AnchorMax : Icon position in the Quick access menu" : "AnchorMax : Позиция иконки в меню быстрого доступа")]
public String AnchorMaxPositionSpriteLogo;
}
public static Configuration GetNewConfiguration() {
return new Configuration {
GeneralSetting = new GeneralSettings {
UsePanelButton = true, UseHidePanelButton = true, UseFlags = true, TypeLock = TypeLock.Locked, UseShowAllTime = false,
}
, Block = new Blocks {
VaribleUnlockMore = true, BlockWeaponAndTools = new Dictionary<String, Blocks.BlockElement> {
["shotgun.double"]
= new Blocks.BlockElement {
TimeBlock = 7200, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["pistol.revolver"] = new Blocks.BlockElement {
TimeBlock = 7200, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["pistol.python"] = new Blocks.BlockElement {
TimeBlock = 10800, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["pistol.semiauto"] = new Blocks.BlockElement {
TimeBlock = 10800, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["pistol.m92"] = new Blocks.BlockElement {
TimeBlock = 10800, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["shotgun.pump"] = new Blocks.BlockElement {
TimeBlock = 10800, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["shotgun.spas12"] = new Blocks.BlockElement {
TimeBlock = 10800, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["smg.2"] = new Blocks.BlockElement {
TimeBlock = 14400, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["smg.thompson"] = new Blocks.BlockElement {
TimeBlock = 14400, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["rifle.semiauto"] = new Blocks.BlockElement {
TimeBlock = 21600, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["smg.mp5"] = new Blocks.BlockElement {
TimeBlock = 21600, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["flamethrower"] = new Blocks.BlockElement {
TimeBlock = 21600, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["rifle.ak"] = new Blocks.BlockElement {
TimeBlock = 36000, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["rifle.ak.ice"] = new Blocks.BlockElement {
TimeBlock = 36000, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["rifle.lr300"] = new Blocks.BlockElement {
TimeBlock = 36000, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["rifle.m39"] = new Blocks.BlockElement {
TimeBlock = 54000, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["rifle.bolt"] = new Blocks.BlockElement {
TimeBlock = 54000, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["rifle.l96"] = new Blocks.BlockElement {
TimeBlock = 54000, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["lmg.m249"] = new Blocks.BlockElement {
TimeBlock = 54000, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["multiplegrenadelauncher"] = new Blocks.BlockElement {
TimeBlock = 86400, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["rocket.launcher"] = new Blocks.BlockElement {
TimeBlock = 129600, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
,
}
, BlockArmory = new Dictionary<String, Blocks.BlockElement> {
["coffeecan.helmet"]
= new Blocks.BlockElement {
TimeBlock = 21600, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["roadsign.gloves"] = new Blocks.BlockElement {
TimeBlock = 21600, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["roadsign.jacket"] = new Blocks.BlockElement {
TimeBlock = 21600, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["roadsign.kilt"] = new Blocks.BlockElement {
TimeBlock = 21600, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["metal.facemask"] = new Blocks.BlockElement {
TimeBlock = 54000, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["metal.plate.torso"] = new Blocks.BlockElement {
TimeBlock = 54000, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["heavy.plate.helmet"] = new Blocks.BlockElement {
TimeBlock = 129600, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["heavy.plate.jacket"] = new Blocks.BlockElement {
TimeBlock = 129600, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["heavy.plate.pants"] = new Blocks.BlockElement {
TimeBlock = 129600, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
,
}
, BlockBoom = new Dictionary<String, Blocks.BlockElement> {
["grenade.f1"]
= new Blocks.BlockElement {
TimeBlock = 10800, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["ammo.shotgun"] = new Blocks.BlockElement {
TimeBlock = 21600, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["ammo.pistol.fire"] = new Blocks.BlockElement {
TimeBlock = 21600, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["ammo.rifle.incendiary"] = new Blocks.BlockElement {
TimeBlock = 21600, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["grenade.beancan"] = new Blocks.BlockElement {
TimeBlock = 32400, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["explosive.satchel"] = new Blocks.BlockElement {
TimeBlock = 43200, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["ammo.rifle.explosive"] = new Blocks.BlockElement {
TimeBlock = 86400, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["explosive.timed"] = new Blocks.BlockElement {
TimeBlock = 86400, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["ammo.grenadelauncher.smoke"] = new Blocks.BlockElement {
TimeBlock = 86400, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["ammo.grenadelauncher.buckshot"] = new Blocks.BlockElement {
TimeBlock = 86400, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["ammo.grenadelauncher.he"] = new Blocks.BlockElement {
TimeBlock = 86400, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["ammo.rocket.smoke"] = new Blocks.BlockElement {
TimeBlock = 129600, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["ammo.rocket.fire"] = new Blocks.BlockElement {
TimeBlock = 129600, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
, ["ammo.rocket.basic"] = new Blocks.BlockElement {
TimeBlock = 129600, SkinID = 0, BlockMoreList = new Dictionary<String, Int32>()
}
,
}
}
, Interface = new Interfaces {
ShowUnblockedItemCompareTime = false, BackgroundUrl = String.Empty, UseProgressiveBackground = false, ShowInformationBlocks = true, CategoryWeaponTools = AlignCategory.Left, CategoryArmory = AlignCategory.Middle, CategoryBoom = AlignCategory.Right, BacgkroundColor = "#3B3A2EC3", BackgroundBlurColor = "#00000044", BackgroundMoreBlurColor = "#00000076", Labels = "#efedee", Lines = "#5E5E5EC8", UnblockedPanel = "#667345", BlockedPanel = "#16161647", BlurBlockedPanel = "#16161624", NextBlockedPanel = "#161616FF", LinesUnblock = "#7D904EFF", UnblockedMorePanel = "#C67036", PreBlockedMoreLine = "#D08654FF", SpriteBlocked = "assets/icons/bp-lock.png", SpriteBlockLogo = "assets/icons/warning_2.png", ButtonIsBlock = false, UseFormatTime = false, AnchorMinPositionSpriteLogo = "0.05896809 0", AnchorMaxPositionSpriteLogo = "0.2211 1", AnchorMinPositionQuickMenu = "1 1", AnchorMaxPositionQuickMenu = "1 1", OffsetMinPositionQuickMenu = "-380 -70", OffsetMaxPositionQuickMenu = "-10 -10",
}
}
;
}
}
protected override void LoadConfig() {
base.LoadConfig();
try {
config = Config.ReadObject<Configuration>();
if (config == null) LoadDefaultConfig();
if (config.Interface.AnchorMinPositionSpriteLogo == null) config.Interface.AnchorMinPositionSpriteLogo = "0.05896809 0";
if (config.Interface.AnchorMaxPositionSpriteLogo == null) config.Interface.AnchorMaxPositionSpriteLogo = "0.2211 1";
if (config.Interface.AnchorMinPositionQuickMenu == null) config.Interface.AnchorMinPositionQuickMenu = "1 1";
if (config.Interface.AnchorMaxPositionQuickMenu == null) config.Interface.AnchorMaxPositionQuickMenu = "1 1";
if (config.Interface.OffsetMinPositionQuickMenu == null) config.Interface.OffsetMinPositionQuickMenu = "-380 -70";
if (config.Interface.OffsetMaxPositionQuickMenu == null) config.Interface.OffsetMaxPositionQuickMenu = "-10 -10";
}
catch {
PrintWarning(LanguageEn ? $"Error #54328 reading configuration 'oxide/config/{Name}', creating a new configuration!!" : $"Ошибка #54328 чтения конфигурации 'oxide/config/{Name}', создаём новую конфигурацию!!");
LoadDefaultConfig();
}
NextTick(SaveConfig);
}
protected override void LoadDefaultConfig() => config = Configuration.GetNewConfiguration();
protected override void SaveConfig() => Config.WriteObject(config);
#endregion
#region Data
[JsonProperty(LanguageEn ? "" : "Сдвиг времени в секундах")]
public Int32 SkipTimeBlocked = 0;
[JsonProperty(LanguageEn ? "" : "Дата с информацией о игроках")]
public Dictionary<UInt64, Boolean> BlockHideInfo = new Dictionary<UInt64, Boolean>();
void ReadData() {
SkipTimeBlocked = Oxide.Core.Interface.Oxide.DataFileSystem.ReadObject<Int32>("IQWipeBlock/SkipTimeBlocked");
BlockHideInfo = Oxide.Core.Interface.Oxide.DataFileSystem.ReadObject<Dictionary<UInt64, Boolean>>("IQWipeBlock/HideStatus");
}
void WriteData() {
Oxide.Core.Interface.Oxide.DataFileSystem.WriteObject("IQWipeBlock/HideStatus", BlockHideInfo);
Oxide.Core.Interface.Oxide.DataFileSystem.WriteObject("IQWipeBlock/SkipTimeBlocked", SkipTimeBlocked);
}
void RegisteredUser(BasePlayer player) {
if (BlockHideInfo.ContainsKey(player.userID)) return;
BlockHideInfo.Add(player.userID, false);
}
#endregion
#region UI
public enum AlignCategory {
Left, Middle, Right
}
public readonly String IQWIPE_PARENT = "UI_IQWIPE_PARENT_MAIN";
public readonly String IQWIPE_PARENT_PANEL_BTN = "IQWIPE_PARENT_PANEL_BTN";
#region Interface Wipe Block
void UI_IQ_WipeBlock(BasePlayer player) {
CuiHelper.DestroyUi(player, IQWIPE_PARENT);
CuiElementContainer container = new CuiElementContainer();
Single FadeIn = 0.2f;
var Interface = config.Interface;
container.Add(new CuiPanel {
CursorEnabled = true, RectTransform = {
AnchorMin = "0 0", AnchorMax = "1 1"
}
, Image = {
FadeIn = FadeIn, Color = HexToRustFormat(Interface.BacgkroundColor)
}
}
, "Overlay", IQWIPE_PARENT);
if (!String.IsNullOrWhiteSpace(config.Interface.BackgroundUrl)) {
container.Add(new CuiElement {
Parent = IQWIPE_PARENT, Components = {
new CuiRawImageComponent {
Png = GetImage($"BACKGROUND_{config.Interface.BackgroundUrl}")
}
, new CuiRectTransformComponent {
AnchorMin = "0 0", AnchorMax = "1 1"
}
,
}
}
);
}
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0 0", AnchorMax = "1 1"
}
, Image = {
FadeIn = FadeIn, Color = HexToRustFormat(Interface.BackgroundBlurColor), Material = "assets/content/ui/uibackgroundblur-ingamemenu.mat"
}
}
, IQWIPE_PARENT, IQWIPE_PARENT + "BLUR");
container.Add(new CuiLabel {
RectTransform = {
AnchorMin = "0.15572 0.9231482", AnchorMax = "0.8375002 0.9842593"
}
, //
Text = {
FadeIn = FadeIn, Text = GetLang("TITLE_BLOCK", player.UserIDString), Color = HexToRustFormat(Interface.Labels), Font = "robotocondensed-bold.ttf", Align = TextAnchor.MiddleCenter
}
}
, IQWIPE_PARENT, IQWIPE_PARENT + "TITLE");
#region Information Block
if (Interface.ShowInformationBlocks) {
#region Blocked
container.Add(new CuiElement {
Parent = IQWIPE_PARENT, Name = IQWIPE_PARENT + "INFO_BLOCKED", Components = {
new CuiImageComponent {
FadeIn = FadeIn, Color = HexToRustFormat(Interface.BlockedPanel), Material = "assets/content/ui/uibackgroundblur-ingamemenu.mat"
}
, new CuiRectTransformComponent {
AnchorMin = "0.01354169 0.9546172", AnchorMax = "0.03020836 0.9842459", OffsetMax = "0 1", OffsetMin = "0 0.5"
}
, new CuiOutlineComponent {
Color = HexToRustFormat(Interface.Lines), Distance = "-1.35 1.4", UseGraphicAlpha = true
}
}
}
);
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0 0", AnchorMax = "1 1", OffsetMin = "0 -1", OffsetMax = "0 -1"
}
, Image = {
FadeIn = FadeIn, Color = HexToRustFormat(Interface.BlurBlockedPanel), Material = "assets/content/ui/uibackgroundblur.mat"
}
}
, IQWIPE_PARENT + "INFO_BLOCKED", IQWIPE_PARENT + "INFO_BLOCKED" + "BLUR");
container.Add(new CuiElement {
Parent = IQWIPE_PARENT + "INFO_BLOCKED" + "BLUR", Components = {
new CuiImageComponent {
FadeIn = FadeIn, Sprite = Interface.SpriteBlocked, Color = HexToRustFormat(Interface.Labels)
}
, new CuiRectTransformComponent {
AnchorMin = "0.33 0.3399995", AnchorMax = $"0.65 0.6599998"
}
,
}
}
);
container.Add(new CuiLabel {
RectTransform = {
AnchorMin = "0.03281251 0.9546172", AnchorMax = "0.1208333 0.9842459"
}
, Text = {
FadeIn = FadeIn, Text = GetLang("TITLE_INFO_BLOCKED", player.UserIDString), Color = HexToRustFormat(Interface.Labels), Font = "robotocondensed-bold.ttf", Align = TextAnchor.MiddleLeft
}
}
, IQWIPE_PARENT, IQWIPE_PARENT + "TITLE");
#endregion
#region Unblocked
container.Add(new CuiElement {
Parent = IQWIPE_PARENT, Components = {
new CuiImageComponent {
FadeIn = FadeIn, Color = HexToRustFormat(Interface.UnblockedPanel), Material = "assets/content/ui/uibackgroundblur-ingamemenu.mat"
}
, new CuiRectTransformComponent {
AnchorMin = $"0.01354169 0.9175813", AnchorMax = $"0.03020836 0.94721", OffsetMax = "0 1", OffsetMin = "0 1"
}
, new CuiOutlineComponent {
Color = HexToRustFormat(Interface.LinesUnblock), Distance = "-1.35 1.35", UseGraphicAlpha = true
}
}
}
);
container.Add(new CuiLabel {
RectTransform = {
AnchorMin = "0.03281251 0.9175813", AnchorMax = "0.1208333 0.94721"
}
, Text = {
FadeIn = FadeIn, Text = GetLang("TITLE_INFO_UNBLOCKED", player.UserIDString), Color = HexToRustFormat(Interface.Labels), Font = "robotocondensed-bold.ttf", Align = TextAnchor.MiddleLeft
}
}
, IQWIPE_PARENT, IQWIPE_PARENT + "TITLE");
#endregion
#region PreBlocked
container.Add(new CuiElement {
Parent = IQWIPE_PARENT, Components = {
new CuiImageComponent {
FadeIn = FadeIn, Color = HexToRustFormat(Interface.NextBlockedPanel), Material = "assets/content/ui/uibackgroundblur-ingamemenu.mat"
}
, new CuiRectTransformComponent {
AnchorMin = $"0.1239583 0.9546172", AnchorMax = $"0.1406247 0.9842459", OffsetMax = "0 1", OffsetMin = "0 1"
}
, new CuiOutlineComponent {
Color = HexToRustFormat(Interface.Lines), Distance = "-1.35 1.35", UseGraphicAlpha = true
}
}
}
);
container.Add(new CuiLabel {
RectTransform = {
AnchorMin = "0.1432293 0.9546172", AnchorMax = "0.2786458 0.9842459"
}
, Text = {
FadeIn = FadeIn, Text = GetLang("TITLE_INFO_PREBLOCKED", player.UserIDString), Color = HexToRustFormat(Interface.Labels), Font = "robotocondensed-bold.ttf", Align = TextAnchor.MiddleLeft
}
}
, IQWIPE_PARENT, IQWIPE_PARENT + "TITLE");
#endregion
#region MoreBlocked
container.Add(new CuiElement {
Parent = IQWIPE_PARENT, Components = {
new CuiImageComponent {
FadeIn = FadeIn, Color = HexToRustFormat(Interface.UnblockedMorePanel), Material = "assets/content/ui/uibackgroundblur-ingamemenu.mat"
}
, new CuiRectTransformComponent {
AnchorMin = $"0.1239583 0.9175813", AnchorMax = $"0.1406247 0.94721", OffsetMax = "0 1", OffsetMin = "0 1"
}
, new CuiOutlineComponent {
Color = HexToRustFormat(Interface.PreBlockedMoreLine), Distance = "-1.35 1.35", UseGraphicAlpha = true
}
}
}
);
container.Add(new CuiLabel {
RectTransform = {
AnchorMin = "0.1432293 0.9175813", AnchorMax = "0.2786458 0.94721"
}
, Text = {
FadeIn = FadeIn, Text = GetLang("TITLE_INFO_MOREBLOCKED", player.UserIDString), Color = HexToRustFormat(Interface.Labels), Font = "robotocondensed-bold.ttf", Align = TextAnchor.MiddleLeft
}
}
, IQWIPE_PARENT, IQWIPE_PARENT + "TITLE");
#endregion
}
#endregion
container.Add(new CuiButton {
FadeOut = 0.2f, RectTransform = {
AnchorMin = $"0.8151017 0.9231482", AnchorMax = $"0.995831 0.9842593"
}
, Button = {
Close = IQWIPE_PARENT, Color = "0 0 0 0"
}
, Text = {
Text = GetLang("TITLE_BUTTON_CLOSE", player.UserIDString), Color = HexToRustFormat(Interface.Labels), Align = TextAnchor.MiddleCenter
}
}
, IQWIPE_PARENT, IQWIPE_PARENT + "BUTTON_CLOSE");
UI_Category_Show(player, container, Interface, config.Block.BlockWeaponAndTools, config.Interface.CategoryWeaponTools);
UI_Category_Show(player, container, Interface, config.Block.BlockArmory, config.Interface.CategoryArmory);
UI_Category_Show(player, container, Interface, config.Block.BlockBoom, config.Interface.CategoryBoom);
CuiHelper.AddUi(player, container);
if (config.GeneralSetting.UsePanelButton) HideButtonIsMenu(player);
}
void HideButtonIsMenu(BasePlayer player) {
CuiHelper.DestroyUi(player, IQWIPE_PARENT + "HIDE_BTN");
CuiElementContainer container = new CuiElementContainer();
Single FadeIn = 0.2f;
var Interface = config.Interface;
String LangKey = BlockHideInfo[player.userID] ? GetLang("UI_PANEL_BUTTON_HIDE_ISMENU_ON", player.UserIDString) : GetLang("UI_PANEL_BUTTON_HIDE_ISMENU_OFF", player.UserIDString);
container.Add(new CuiButton {
RectTransform = {
AnchorMin = "0.1557295 0.9037", AnchorMax = "0.8375002 0.9351"
}
, Button = {
Command = "iqwb hide.panel.btn true", Color = "0 0 0 0"
}
, Text = {
FadeIn = FadeIn, Text = LangKey, Color = HexToRustFormat(Interface.Labels), Font = "robotocondensed-bold.ttf", Align = TextAnchor.MiddleCenter
}
}
, IQWIPE_PARENT, IQWIPE_PARENT + "HIDE_BTN");
CuiHelper.AddUi(player, container);
}
#endregion
#region Interface Category
void UI_Category_Show(BasePlayer player, CuiElementContainer container, Configuration.Interfaces Interface, Dictionary<String, Configuration.Blocks.BlockElement> CategoryList, AlignCategory Align) {
if (CategoryList == null || CategoryList.Count == 0) return;
var Block = config.Block;
Single FadeIn = 0.2f;
String TitleX = Align == AlignCategory.Left ? "0.08593746 0.8481482" : Align == AlignCategory.Middle ? "0.4072909 0.8481482" : "0.7161464 0.8481482";
String TitleY = Align == AlignCategory.Left ? "0.273958 0.8851852" : Align == AlignCategory.Middle ? "0.5859324 0.8851852" : "0.9192606 0.8851852";
String TitleText = Align == Interface.CategoryWeaponTools ? "TITLE_CATEGORY_WEAPON_TOOL" : Align == Interface.CategoryArmory ? "TITLE_CATEGORY_ATTIRE" : "TITLE_CATEGORY_BOOM";
String PanelX = Align == AlignCategory.Left ? "0.05208334 0" : Align == AlignCategory.Middle ? "0.3687498 0" : "0.6864532 0";
String PanelY = Align == AlignCategory.Left ? "0.3130208 0.8351786" : Align == AlignCategory.Middle ? "0.6296868 0.8351786" : "0.9473904 0.8351786";
String LineX = Align == AlignCategory.Left ? "0.08593746 0.8444445" : Align == AlignCategory.Middle ? "0.4026018 0.8444445" : "0.7244719 0.8444445";
String LineY = Align == AlignCategory.Left ? "0.273958 0.845" : Align == AlignCategory.Middle ? "0.5906243 0.845" : "0.9124945 0.845";
container.Add(new CuiLabel {
RectTransform = {
AnchorMin = TitleX, AnchorMax = TitleY
}
, Text = {
FadeIn = FadeIn, Text = GetLang(TitleText, player.UserIDString), Color = HexToRustFormat(Interface.Labels), Font = "robotocondensed-bold.ttf", Align = TextAnchor.MiddleCenter
}
}
, IQWIPE_PARENT, IQWIPE_PARENT + "TITLE");
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = LineX, AnchorMax = LineY
}
, Image = {
FadeIn = FadeIn, Color = HexToRustFormat(Interface.Lines)
}
}
, IQWIPE_PARENT, IQWIPE_PARENT + "LINE");
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = PanelX, AnchorMax = PanelY
}
, Image = {
FadeIn = FadeIn, Color = "0 0 0 0"
}
}
, IQWIPE_PARENT, IQWIPE_PARENT + "BLOCK_PANEL");
#region Centering
Int32 ItemCount = 0;
Single itemMinPosition = 219f;
Single itemWidth = 0.2f;
/// Ширина
Single itemMargin = 0.062f;
/// Расстояние между
Int32 itemCount = CategoryList.Count;
Single itemMinHeight = 0.87f;
// Сдвиг по вертикали
Single itemHeight = 0.11f;
/// Высота
Int32 ItemTarget = 4;
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;
#endregion
Int32 OldUnblockTime = 0;
Int32 Count = 0;
Int32 Items = CategoryList.Count;
Boolean SkipElement = (Boolean)(CategoryList.Count(x => TimeUnblock(x.Value.TimeBlock) > 0) >= 1);
foreach (var Item in CategoryList.OrderBy(i => i.Value.TimeBlock).Take(28)) {
String ColorBackground = ((SkipElement && TimeUnblock(Item.Value.TimeBlock) > 0) || (OldUnblockTime == Item.Value.TimeBlock)) ? Interface.NextBlockedPanel : TimeUnblock(Item.Value.TimeBlock) > 0 ? Interface.BlockedPanel : Item.Value.BlockMoreList.Count > 0 && TimeUnblock(Item.Value.BlockMoreList.Sum(i => Block.VaribleUnlockMore ? (i.Value + Item.Value.TimeBlock) : i.Value)) > 0 ? Interface.UnblockedMorePanel : Interface.UnblockedPanel;
String LineColor = TimeUnblock(Item.Value.TimeBlock) > 0 ? Interface.Lines : Item.Value.BlockMoreList.Count > 0 && TimeUnblock(Item.Value.BlockMoreList.Sum(i => Block.VaribleUnlockMore ? (i.Value + Item.Value.TimeBlock) : i.Value)) > 0 ? Interface.PreBlockedMoreLine : Interface.LinesUnblock;
container.Add(new CuiElement {
Parent = IQWIPE_PARENT + "BLOCK_PANEL", Name = IQWIPE_PARENT + $"PANEL_ITEM_{ItemCount}", Components = {
new CuiImageComponent {
FadeIn = FadeIn, Color = HexToRustFormat(ColorBackground), Material = "assets/content/ui/uibackgroundblur-ingamemenu.mat"
}
, new CuiRectTransformComponent {
AnchorMin = $"{itemMinPosition} {itemMinHeight}", AnchorMax = $"{itemMinPosition + itemWidth} {itemMinHeight + itemHeight}", OffsetMax = "0 1", OffsetMin = "0 1"
}
, new CuiOutlineComponent {
Color = HexToRustFormat(LineColor), Distance = "-1.35 1.35", UseGraphicAlpha = true
}
}
}
);
if ((SkipElement && TimeUnblock(Item.Value.TimeBlock) > 0) || (OldUnblockTime == Item.Value.TimeBlock)) {
if (Interface.UseProgressiveBackground) {
if (Interface.ShowUnblockedItemCompareTime) OldUnblockTime = Item.Value.TimeBlock;
Single ProgressiveX = (Single)((Item.Value.TimeBlock - TimeUnblock(Item.Value.TimeBlock)) / Item.Value.TimeBlock * 1f) >= 1 ? 1 : (Single)((Item.Value.TimeBlock - TimeUnblock(Item.Value.TimeBlock)) / Item.Value.TimeBlock * 1f);
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0 0", AnchorMax = $"{ProgressiveX} 1", OffsetMin = "0 0", OffsetMax = "0 -0.03"
}
, Image = {
FadeIn = FadeIn, Color = HexToRustFormat(Interface.UnblockedPanel), Material = "assets/content/ui/uibackgroundblur-ingamemenu.mat"
}
}
, IQWIPE_PARENT + $"PANEL_ITEM_{ItemCount}");
// ... [Code preview truncated due to length. Full source in attached file] ...