C#:
using ConVar;
using Oxide.Game.Rust.Cui;
using Oxide.Core.Plugins;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Collections;
using UnityEngine;
using Object = System.Object;
using Network;
using System.Text;
using Oxide.Core;
using Newtonsoft.Json;
namespace Oxide.Plugins {
[Info("IQWipeBlock", "Sempai#3239", "1.2.6")]
[Description("Блокируй по умному с IQWipeBlock")]
class IQWipeBlock : RustPlugin {
void RegisteredUser(BasePlayer player) {
if (BlockHideInfo.ContainsKey(player.userID)) return;
BlockHideInfo.Add(player.userID, false);
}
[ConsoleCommand("iqwb")]
void ConsoleFuncCommand(ConsoleSystem.Arg arg) {
if (arg == null || arg.Args.Length == 0) return;
BasePlayer player = arg.Player();
if (player == null) return;
String Action = (String)arg.Args[0];
if (Action == null || String.IsNullOrWhiteSpace(Action)) return;
switch (Action) {
case "popup" : {
String Shortname = (String)arg.Args[1];
Configuration.Blocks.BlockElement BlockElement = GetBlockElement(Shortname);
UI_Category_More_Popup(player, BlockElement);
break;
}
case "hide.panel.btn" : {
Boolean IsMenu = Boolean.Parse(arg.Args[1]);
HideOrUnHigePanel(player, IsMenu);
break;
}
}
}
private new void LoadDefaultMessages() {
lang.RegisterMessages(new Dictionary<String, String> {
["TITLE_BLOCK"]
= "<size=35><b>BLOCKED WIPE</b></size>", ["TITLE_CATEGORY_WEAPON_TOOL"] = "<size=16><b>WEAPONS AND TOOLS</b></size>", ["TITLE_CATEGORY_ATTIRE"] = "<size=16><b>EQUIPMENT</b></size>", ["TITLE_CATEGORY_BOOM"] = "<size=16><b>EXPLOSIVES AND AMMUNITION</b></size>", ["TITLE_BLOCK_MORE"] = "<size=17><b>LOCKING ELEMENTS TO THIS ITEM</b></size>", ["TITLE_FORMAT_LOCKED_DAYS"] = "<size=12><b>D</b></size>", ["TITLE_FORMAT_LOCKED_HOURSE"] = "<size=12><b>H</b></size>", ["TITLE_FORMAT_LOCKED_MINUTES"] = "<size=12><b>M</b></size>", ["TITLE_FORMAT_LOCKED_SECONDS"] = "<size=12><b>S</b></size>", ["TITLE_BUTTON_CLOSE"] = "<size=35><b>CLOSE</b></size>", ["TITLE_INFO_BLOCKED"] = "<size=10><b>- BLOCKED</b></size>", ["TITLE_INFO_UNBLOCKED"] = "<size=10><b>- UNBLOCKED</b></size>", ["TITLE_INFO_PREBLOCKED"] = "<size=10><b>- IN THE PROCESS OF UNLOCKING</b></size>", ["TITLE_INFO_MOREBLOCKED"] = "<size=10><b>- ADDITIONAL BLOCKING</b></size>", ["UI_BLOCK_TITLE"] = "<size=18><b>THE ITEM IS TEMPORARILY BLOCKED</b></size>", ["UI_BLOCK_DESCRIPTION_ONE"] = "<size=12><b>This item item is temporarily blocked {0}</b></size>", ["UI_BLOCK_DESCRIPTION_TWO"] = "<size=12><b>This item is temporarily blocked on {0}</b></size>", ["UI_PANEL_BUTTON_TITLE"] = "<size=18><b>TEMPORARY BLOCKING OF ITEMS</b></size>", ["UI_PANEL_BUTTON_DESCRIPTION"] = "<size=13>CLICK TO OPEN THE MENU WITH THE LOCK</size>", ["UI_PANEL_BUTTON_HIDE"] = "<size=11>HIDE THIS WINDOW</size>", ["UI_PANEL_BUTTON_HIDE_ISMENU_OFF"] = "<size=11>HIDE MENU SHORTCUT BUTTONS</size>", ["UI_PANEL_BUTTON_HIDE_ISMENU_ON"] = "<size=11>EXPAND THE QUICK ACCESS BUTTONS TO THE MENU</size>", ["CHAT_ALERT_ALL_USERS_ALL_UNLOCK"] = "Hurray! All items have been unlocked!",
}
, this);
lang.RegisterMessages(new Dictionary<String, String> {
["TITLE_BLOCK"]
= "<size=35><b>БЛОКИРОВКА ПОСЛЕ ВАЙПА</b></size>", ["TITLE_BLOCK_MORE"] = "<size=17><b>БЛОКИРОВКА ЭЛЕМЕНТОВ К ЭТОМУ ПРЕДМЕТУ</b></size>", ["TITLE_CATEGORY_WEAPON_TOOL"] = "<size=16><b>ОРУЖИЕ И ИНСТРУМЕНТЫ</b></size>", ["TITLE_CATEGORY_BOOM"] = "<size=16><b>ВЗРЫВЧАТКА И БОЕПРИПАСЫ</b></size>", ["TITLE_CATEGORY_ATTIRE"] = "<size=16><b>СНАРЯЖЕНИЕ</b></size>", ["TITLE_FORMAT_LOCKED_DAYS"] = "<size=12><b>Д</b></size>", ["TITLE_FORMAT_LOCKED_HOURSE"] = "<size=12><b>Ч</b></size>", ["TITLE_FORMAT_LOCKED_MINUTES"] = "<size=12><b>М</b></size>", ["TITLE_FORMAT_LOCKED_SECONDS"] = "<size=12><b>С</b></size>", ["TITLE_BUTTON_CLOSE"] = "<size=35><b>ЗАКРЫТЬ</b></size>", ["TITLE_INFO_BLOCKED"] = "<size=10><b>- ЗАБЛОКИРОВАНО</b></size>", ["TITLE_INFO_UNBLOCKED"] = "<size=10><b>- РАЗБЛОКИРОВАНО</b></size>", ["TITLE_INFO_PREBLOCKED"] = "<size=10><b>- В ПРОЦЕССЕ РАЗБЛОКИРОВКИ</b></size>", ["TITLE_INFO_MOREBLOCKED"] = "<size=10><b>- ДОПОЛНИТЕЛЬНАЯ БЛОКИРОВКА</b></size>", ["UI_BLOCK_TITLE"] = "<size=18><b>ПРЕДМЕТ ВРЕМЕННО ЗАБЛОКИРОВАН</b></size>", ["UI_BLOCK_DESCRIPTION_ONE"] = "<size=12><b>Данный элемент предмета временно заблокирован {0}</b></size>", ["UI_BLOCK_DESCRIPTION_TWO"] = "<size=12><b>Данный предмет временно заблокирован на {0}</b></size>", ["UI_PANEL_BUTTON_TITLE"] = "<size=18><b>ВРЕМЕННАЯ БЛОКИРОВКА ПРЕДМЕТОВ</b></size>", ["UI_PANEL_BUTTON_DESCRIPTION"] = "<size=13>НАЖМИТЕ ЧТОБЫ ОТКРЫТЬ МЕНЮ С БЛОКИРОВКОЙ</size>", ["UI_PANEL_BUTTON_HIDE"] = "<size=11>СКРЫТЬ ДАННОЕ ОКНО</size>", ["UI_PANEL_BUTTON_HIDE_ISMENU_OFF"] = "<size=11>СКРЫТЬ КНОПКИ БЫСТРОГО ДОСТУПА К МЕНЮ</size>", ["UI_PANEL_BUTTON_HIDE_ISMENU_ON"] = "<size=11>РАСКРЫТЬ КНОПКИ БЫСТРОГО ДОСТУПА К МЕНЮ</size>", ["CHAT_ALERT_ALL_USERS_ALL_UNLOCK"] = "Ура! Все предметы были разблокированы!",
}
, this, "ru");
PrintWarning(LanguageEn ? "Language file uploaded successfully" : "Языковой файл загружен успешно");
}
[ChatCommand("block")]
void ChatCommandBlock(BasePlayer player) {
if (player == null) return;
UI_IQ_WipeBlock(player);
}
private IEnumerator DownloadImages() {
var Block = config.Block;
Dictionary<String, Configuration.Blocks.BlockElement> BlockAll = (Dictionary<String, Configuration.Blocks.BlockElement>)Block.BlockArmory.Concat(Block.BlockWeaponAndTools).Concat(Block.BlockBoom).ToDictionary(x => x.Key, x => x.Value);
Puts("AddImages SkyPlugins.ru...");
foreach (var Item in BlockAll) {
if (Item.Value.SkinID != 0) if (!HasImage($"{Item.Key}_128px_{Item.Value.SkinID}")) AddImage($"http://api.skyplugins.ru/api/getskin/{Item.Value.SkinID}/128", $"{Item.Key}_128px_{Item.Value.SkinID}", Item.Value.SkinID);
if (!HasImage($"{Item.Key}_128px")) AddImage($"http://api.skyplugins.ru/api/getimage/{Item.Key}/128", $"{Item.Key}_128px");
foreach (var ItemMore in Item.Value.BlockMoreList) if (!HasImage($"{ItemMore.Key}_128px")) AddImage($"http://api.skyplugins.ru/api/getimage/{ItemMore.Key}/128", $"{ItemMore.Key}_128px");
}
if (!String.IsNullOrWhiteSpace(config.Interface.BackgroundUrl)) if (!HasImage($"BACKGROUND_{config.Interface.BackgroundUrl}")) AddImage(config.Interface.BackgroundUrl, $"BACKGROUND_{config.Interface.BackgroundUrl}");
yield return new WaitForSeconds(0.04f);
Puts("AddImages SkyPlugins.ru - completed..");
}
public String FormatTime(TimeSpan time, String UserID) {
Boolean UseFullTime = config.Interface.UseFormatTime;
String Result = String.Empty;
String Days = GetLang("TITLE_FORMAT_LOCKED_DAYS", UserID);
String Hourse = GetLang("TITLE_FORMAT_LOCKED_HOURSE", UserID);
String Minutes = GetLang("TITLE_FORMAT_LOCKED_MINUTES", UserID);
String Seconds = GetLang("TITLE_FORMAT_LOCKED_SECONDS", UserID);
if (!UseFullTime) {
if (time.Seconds != 0) Result = $"{Format(time.Seconds, Seconds, Seconds, Seconds)}";
if (time.Minutes != 0) Result = $"{Format(time.Minutes, Minutes, Minutes, Minutes)}";
if (time.Hours != 0) Result = $"{Format(time.Hours, Hourse, Hourse, Hourse)}";
if (time.Days != 0) Result = $"{Format(time.Days, Days, Days, Days)}";
}
else {
if (time.Days != 0) Result += $"{Format(time.Days, Days, Days, Days)} ";
if (time.Hours != 0) Result += $"{Format(time.Hours, Hourse, Hourse, Hourse)} ";
if (time.Minutes != 0) Result += $"{Format(time.Minutes, Minutes, Minutes, Minutes)} ";
if (time.Days == 0 && time.Hours == 0 && time.Minutes == 0 && time.Seconds != 0) Result = $"{Format(time.Seconds, Seconds, Seconds, Seconds)} ";
}
return Result;
}
void UI_Category_More_Popup(BasePlayer player, Configuration.Blocks.BlockElement BlockElement) {
CuiHelper.DestroyUi(player, IQWIPE_PARENT + "POPUP");
CuiElementContainer container = new CuiElementContainer();
Single FadeIn = 0.2f;
var Interface = config.Interface;
var BlockMore = BlockElement.BlockMoreList;
var Block = config.Block;
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0 0", AnchorMax = "1 1"
}
, Image = {
FadeIn = FadeIn, Color = HexToRustFormat(Interface.BackgroundMoreBlurColor), Material = "assets/content/ui/uibackgroundblur-ingamemenu.mat"
}
}
, IQWIPE_PARENT, IQWIPE_PARENT + "POPUP");
container.Add(new CuiButton {
FadeOut = 0.2f, RectTransform = {
AnchorMin = $"0 0", AnchorMax = $"1 1"
}
, Button = {
Close = IQWIPE_PARENT + "POPUP", Color = "0 0 0 0"
}
, Text = {
Text = ""
}
}
, IQWIPE_PARENT + "POPUP", IQWIPE_PARENT + "POPUP" + "BUTTON_CLOSE");
container.Add(new CuiLabel {
RectTransform = {
AnchorMin = "0.3281249 0.6796", AnchorMax = "0.6927969 0.7268518"
}
, Text = {
FadeIn = FadeIn, Text = GetLang("TITLE_BLOCK_MORE", player.UserIDString), Color = HexToRustFormat(Interface.Labels), Font = "robotocondensed-bold.ttf", Align = TextAnchor.MiddleCenter
}
}
, IQWIPE_PARENT + "POPUP", IQWIPE_PARENT + "POPUP_TITLE");
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0.4036451 0.6824123", AnchorMax = "0.5916615 0.6829678"
}
, Image = {
FadeIn = FadeIn, Color = HexToRustFormat(Interface.Lines)
}
}
, IQWIPE_PARENT + "POPUP", IQWIPE_PARENT + "POPUP_TITLE_LINE");
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0.2432292 0.06944448", AnchorMax = "0.7546969 0.6583334"
}
, Image = {
FadeIn = FadeIn, Color = "0 0 0 0"
}
}
, IQWIPE_PARENT + "POPUP", IQWIPE_PARENT + "POPUP" + "ITEMS_PANEL");
Int32 ItemCount = 0;
Single itemMinPosition = 219f;
Single itemWidth = 0.1f;
/// Ширина
Single itemMargin = 0.062f;
/// Расстояние между
Int32 itemCount = BlockMore.Count;
Single itemMinHeight = 0.85f;
// Сдвиг по вертикали
Single itemHeight = 0.15f;
/// Высота
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;
Int32 Count = 0;
Int32 Items = BlockMore.Count;
Boolean SkipElement = (Boolean)(BlockMore.Count(x => TimeUnblock(Block.VaribleUnlockMore ? x.Value + BlockElement.TimeBlock : x.Value) > 0) >= 1);
foreach (var Item in BlockMore.OrderBy(i => i.Value).Take(28)) {
Int32 ItemValue = Block.VaribleUnlockMore ? Item.Value + BlockElement.TimeBlock : Item.Value;
String ColorBackground = SkipElement && TimeUnblock(ItemValue) > 0 ? Interface.NextBlockedPanel : TimeUnblock(ItemValue) > 0 ? Interface.BlockedPanel : Interface.UnblockedPanel;
String LineColor = TimeUnblock(ItemValue) > 0 ? Interface.Lines : Interface.LinesUnblock;
container.Add(new CuiElement {
Parent = IQWIPE_PARENT + "POPUP" + "ITEMS_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(ItemValue) > 0) {
if (Interface.UseProgressiveBackground) {
Single ProgressiveX = (Single)((ItemValue - TimeUnblock(ItemValue)) / ItemValue * 1f) >= 1 ? 1 : (Single)((ItemValue - TimeUnblock(ItemValue)) / ItemValue * 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}");
}
}
container.Add(new CuiElement {
Parent = IQWIPE_PARENT + $"PANEL_ITEM_{ItemCount}", Name = IQWIPE_PARENT + $"IMG_{ItemCount}", Components = {
new CuiRawImageComponent {
FadeIn = FadeIn, Png = GetImage($"{Item.Key}_128px")
}
, new CuiRectTransformComponent {
AnchorMin = "0.03992017 0.04031476", AnchorMax = $"0.9481039 0.9574757"
}
,
}
}
);
if (!config.GeneralSetting.UseShowAllTime) {
if (SkipElement && TimeUnblock(ItemValue) > 0) {
String TimeLeft = FormatTime(TimeSpan.FromSeconds(TimeUnblock(ItemValue)), player.UserIDString);
container.Add(new CuiLabel {
RectTransform = {
AnchorMin = "0.06480032 0.7686631", AnchorMax = "0.9430439 0.980315"
}
, Text = {
FadeIn = FadeIn, Text = TimeLeft, FontSize = 12, Color = HexToRustFormat(Interface.Labels), Font = "robotocondensed-bold.ttf", Align = TextAnchor.MiddleLeft
}
}
, IQWIPE_PARENT + $"PANEL_ITEM_{ItemCount}", IQWIPE_PARENT + "UNLOCK_TIME" + itemCount);
}
}
else {
if (TimeUnblock(ItemValue) > 0) {
String TimeLeft = FormatTime(TimeSpan.FromSeconds(TimeUnblock(ItemValue)), player.UserIDString);
container.Add(new CuiLabel {
RectTransform = {
AnchorMin = "0.06480032 0.7686631", AnchorMax = "0.9430439 0.980315"
}
, Text = {
FadeIn = FadeIn, Text = TimeLeft, FontSize = 12, Color = HexToRustFormat(Interface.Labels), Font = "robotocondensed-bold.ttf", Align = TextAnchor.MiddleLeft
}
}
, IQWIPE_PARENT + $"PANEL_ITEM_{ItemCount}", IQWIPE_PARENT + "UNLOCK_TIME" + itemCount);
}
}
if (!SkipElement && TimeUnblock(ItemValue) > 0) {
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 + $"IMG_{ItemCount}", IQWIPE_PARENT + $"IMG_{ItemCount}" + "BLUR");
container.Add(new CuiElement {
Parent = IQWIPE_PARENT + $"IMG_{ItemCount}" + "BLUR", Name = IQWIPE_PARENT + $"IMG_{ItemCount}" + "BLOCKED", Components = {
new CuiImageComponent {
FadeIn = FadeIn, Sprite = Interface.SpriteBlocked, Color = HexToRustFormat(Interface.Labels)
}
, new CuiRectTransformComponent {
AnchorMin = "0.33 0.3399995", AnchorMax = $"0.65 0.6599998"
}
,
}
}
);
}
Count++;
if (Count != 4 && Items - Count != 0) {
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "1 0.5", AnchorMax = "1 0.5", OffsetMin = "1.5 -1", OffsetMax = $"41 1"
}
, Image = {
FadeIn = FadeIn, Color = HexToRustFormat(Interface.Lines)
}
}
, IQWIPE_PARENT + $"PANEL_ITEM_{ItemCount}", IQWIPE_PARENT + $"PANEL_ITEM_{ItemCount}" + $"LINE_{ItemCount}");
if (TimeUnblock(ItemValue) < 0 || (SkipElement && TimeUnblock(ItemValue) > 0)) {
Single ProgressiveX = (Single)((ItemValue - TimeUnblock(ItemValue)) / ItemValue * 1f) >= 1 ? 1 : (Single)((ItemValue - TimeUnblock(ItemValue)) / ItemValue * 1f);
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0 0", AnchorMax = $"{ProgressiveX - 0.04} 1", OffsetMin = "0 0", OffsetMax = "0 -0.1"
}
, Image = {
FadeIn = FadeIn, Color = HexToRustFormat(Interface.LinesUnblock)
}
}
, IQWIPE_PARENT + $"PANEL_ITEM_{ItemCount}" + $"LINE_{ItemCount}", IQWIPE_PARENT + $"PANEL_ITEM_{ItemCount}" + $"LINE_{ItemCount}" + "PROGRESSIVE");
}
}
if (SkipElement && TimeUnblock(ItemValue) > 0) SkipElement = false;
if (Count == 4) {
Items -= 4;
if (Items != 0) {
Int32 SizeLine = Items == 1 ? -131 : Items == 2 ? -215 : Items == 3 ? -260 : -293;
//
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0.5 0", AnchorMax = "0.5 0", OffsetMin = "-1 -10", OffsetMax = "1 0"
}
, Image = {
FadeIn = FadeIn, Color = HexToRustFormat(LineColor)
}
}
, IQWIPE_PARENT + $"PANEL_ITEM_{ItemCount}", IQWIPE_PARENT + $"PANEL_ITEM_{ItemCount}" + $"LINE_{ItemCount}");
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = $"{SizeLine} -1", OffsetMax = "2 1"
}
, Image = {
FadeIn = FadeIn, Color = HexToRustFormat(LineColor)
}
}
, IQWIPE_PARENT + $"PANEL_ITEM_{ItemCount}" + $"LINE_{ItemCount}", IQWIPE_PARENT + $"PANEL_ITEM_{ItemCount}" + $"LINE_{ItemCount}" + "LEFT");
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "-1 -7", OffsetMax = "1 2"
}
, Image = {
FadeIn = FadeIn, Color = HexToRustFormat(LineColor)
}
}
, IQWIPE_PARENT + $"PANEL_ITEM_{ItemCount}" + $"LINE_{ItemCount}" + "LEFT", IQWIPE_PARENT + $"PANEL_ITEM_{ItemCount}" + $"LINE_{ItemCount}" + "LEFT" + "DOWN");
}
Count = 0;
}
ItemCount++;
itemMinPosition += (itemWidth + itemMargin);
if (ItemCount % ItemTarget == 0) {
itemMinHeight -= (itemHeight + (itemMargin * 0.7f));
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;
}
}
CuiHelper.AddUi(player, container);
}
private object OnReloadWeapon(BasePlayer player, BaseProjectile projectile) => OnReloadMagazine(player, projectile);
void Unload() {
WriteData();
ServerMgr.Instance.StopCoroutine(routineDownloadImage);
ServerMgr.Instance.CancelInvoke(CheckAllUnlock);
foreach (BasePlayer player in BasePlayer.activePlayerList) {
CuiHelper.DestroyUi(player, IQWIPE_PARENT);
CuiHelper.DestroyUi(player, IQWIPE_PARENT_PANEL_BTN);
}
}
object OnLootNetworkUpdate(PlayerLoot loot) {
if (loot == null) return null;
BasePlayer player = loot.GetComponent<BasePlayer>();
if (player == null) return null;
if (loot.entitySource == null || loot.entitySource.net == null) return null;
UInt64 NetID = loot.entitySource.net.ID;
NetworkIDGetSet(NetID, true, player);
return null;
}
Configuration.Blocks.BlockElement GetBlockElement(String Shortname) {
var Block = config.Block;
Dictionary<String, Configuration.Blocks.BlockElement> BlockAll = (Dictionary<String, Configuration.Blocks.BlockElement>)Block.BlockArmory.Concat(Block.BlockWeaponAndTools).Concat(Block.BlockBoom).ToDictionary(x => x.Key, x => x.Value);
if (!BlockAll.ContainsKey(Shortname)) return null;
return BlockAll[Shortname];
}
Boolean Block_Skin_Controller(Configuration.Blocks.BlockElement BlockInfo, Dictionary<String, Configuration.Blocks.BlockElement> BlockAll, Boolean BlockStatusShortname, UInt64 SkinID = 0) {
if (BlockStatusShortname && SkinID != 0 && SkinID == BlockInfo.SkinID) return true;
else if (BlockInfo.SkinID == 0 && SkinID == 0 && BlockStatusShortname) return true;
else if (BlockStatusShortname && BlockInfo.SkinID == 0 && BlockAll.Count(x => x.Value.SkinID == SkinID) == 0) return true;
else return false;
}
public Boolean AddImage(String url, String shortname, UInt64 skin = 0) => (Boolean)ImageLibrary?.Call("AddImage", url, shortname, skin);
readonly static String PermissionIgnoreBlock = "iqwipeblock.ignore";
void SetFlagItem(Item item, Boolean FlagStatus) {
var Config = config.GeneralSetting;
if (!Config.UseFlags || item == null) return;
if (!FlagStatus && item.flags == global : : Item.Flag.None) return;
global : : Item.Flag Flag = Config.TypeLock == TypeLock.Fire ? global : : Item.Flag.OnFire : Config.TypeLock == TypeLock.Flash ? global : : Item.Flag.Cooking : Config.TypeLock == TypeLock.Locked ? global : : Item.Flag.IsLocked : global : : Item.Flag.Placeholder;
if (FlagStatus && item.HasFlag(Flag)) return;
if (item.flags != Flag) item.SetFlag(item.flags, false);
item.SetFlag(Flag, FlagStatus);
}
private static string HexToRustFormat(String hex) {
UnityEngine.Color color;
ColorUtility.TryParseHtmlString(hex, out color);
return String.Format("{0:F2} {1:F2} {2:F2} {3:F2}", color.r, color.g, color.b, color.a);
}
private void Init() {
Unsubscribe(nameof(OnItemAddedToContainer));
ReadData();
permission.RegisterPermission(PermissionIgnoreBlock, this);
}
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");
if (Interface.ShowInformationBlocks) {
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");
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");
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");
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");
}
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);
}
public String GetLang(String LangKey, String userID = null, params object[] args) {
sb.Clear();
if (args != null) {
sb.AppendFormat(lang.GetMessage(LangKey, this, userID), args);
return sb.ToString();
}
return lang.GetMessage(LangKey, this, userID);
}
private void OnServerInitialized() {
PrintWarning("\n-----------------------------\n" + " Author - Sempai#3239\n" + " VK - https://vk.com/rustnastroika/n" + " Discord - https://discord.gg/5DPTsRmd3G/n" if(!ImageLibrary) {
PrintWarning("ImageLibrary не установлен! Плагин выгружен...( https://umod.org/plugins/image-library )");
Interface.Oxide.UnloadPlugin(this.Name);
return;
}
routineDownloadImage = ServerMgr.Instance.StartCoroutine(DownloadImages());
ServerMgr.Instance.InvokeRepeating(CheckAllUnlock, 0f, 60f);
NextTick(() => {
foreach (BasePlayer player in BasePlayer.activePlayerList) OnPlayerConnected(player);
Subscribe(nameof(OnItemAddedToContainer));
}
);
}
public Dictionary<UInt64, List<Connection>> ContainerGetPlayer = new Dictionary<UInt64, List<Connection>>();
public void SendImage(BasePlayer player, String imageName, UInt64 imageId = 0) => ImageLibrary?.Call("SendImage", player, imageName, imageId);
[ConsoleCommand("block")]
void ConsoleCommandBlock(ConsoleSystem.Arg arg) {
BasePlayer player = arg.Player();
if (player == null) return;
UI_IQ_WipeBlock(player);
}
Boolean Interface_UI_Block(BasePlayer player, String Shortname, String ShortnameModule = "", UInt64 SkinID = 0, List<Connection> playerList = null) {
if (Shortname == null || String.IsNullOrWhiteSpace(Shortname)) return true;
if(Shortname.Contains(".ice")) Shortname = Shortname.Replace(".ice", "");
if (playerList == null) {
if (player != null) {
CuiHelper.DestroyUi(player, "ALERT_UI_BLOCK");
if (permission.UserHasPermission(player.UserIDString, PermissionIgnoreBlock)) return true;
}
}
else CommunityEntity.ServerInstance.ClientRPCEx(new SendInfo(playerList), null, "DestroyUI", "ALERT_UI_BLOCK");
String LangID = player == null ? null : player.UserIDString;
Single FadeIn = 0f;
Single FadeOut = 0f;
var Interface = config.Interface;
var Block = config.Block;
Dictionary<String, Configuration.Blocks.BlockElement> BlockAll = (Dictionary<String, Configuration.Blocks.BlockElement>)Block.BlockArmory.Concat(Block.BlockWeaponAndTools).Concat(Block.BlockBoom).ToDictionary(x => x.Key, x => x.Value);
if (!BlockAll.ContainsKey(Shortname)) return true;
if (!String.IsNullOrWhiteSpace(ShortnameModule) && !BlockAll[Shortname].BlockMoreList.ContainsKey(ShortnameModule)) return true;
String ColorBackground = Block_Skin_Controller(BlockAll[Shortname], BlockAll, TimeUnblock(BlockAll[Shortname].TimeBlock) > 0, SkinID) ? Interface.BlockedPanel : BlockAll[Shortname].BlockMoreList.Count > 0 && !String.IsNullOrWhiteSpace(ShortnameModule) && TimeUnblock(Block.VaribleUnlockMore ? BlockAll[Shortname].TimeBlock + BlockAll[Shortname].BlockMoreList[ShortnameModule] : BlockAll[Shortname].BlockMoreList[ShortnameModule]) > 0 ? Interface.UnblockedMorePanel : "";
String LineColor = Block_Skin_Controller(BlockAll[Shortname], BlockAll, TimeUnblock(BlockAll[Shortname].TimeBlock) > 0, SkinID) ? Interface.Lines : BlockAll[Shortname].BlockMoreList.Count > 0 && !String.IsNullOrWhiteSpace(ShortnameModule) && TimeUnblock(Block.VaribleUnlockMore ? BlockAll[Shortname].TimeBlock + BlockAll[Shortname].BlockMoreList[ShortnameModule] : BlockAll[Shortname].BlockMoreList[ShortnameModule]) > 0 ? Interface.PreBlockedMoreLine : "";
String LangVaribles = Block_Skin_Controller(BlockAll[Shortname], BlockAll, TimeUnblock(BlockAll[Shortname].TimeBlock) > 0, SkinID) ? GetLang("UI_BLOCK_DESCRIPTION_TWO", LangID, FormatTime(TimeSpan.FromSeconds(TimeUnblock(BlockAll[Shortname].TimeBlock)), LangID ?? "0")) : BlockAll[Shortname].BlockMoreList.Count > 0 && !String.IsNullOrWhiteSpace(ShortnameModule) && TimeUnblock(Block.VaribleUnlockMore ? BlockAll[Shortname].TimeBlock + BlockAll[Shortname].BlockMoreList[ShortnameModule] : BlockAll[Shortname].BlockMoreList[ShortnameModule]) > 0 && !String.IsNullOrEmpty(ShortnameModule) ? GetLang("UI_BLOCK_DESCRIPTION_ONE", LangID, FormatTime(TimeSpan.FromSeconds(TimeUnblock(BlockAll[Shortname].BlockMoreList[ShortnameModule])), LangID ?? "0")) : "";
if (String.IsNullOrWhiteSpace(ColorBackground) || String.IsNullOrWhiteSpace(LineColor) || String.IsNullOrWhiteSpace(LangVaribles)) return true;
CuiElementContainer container = new CuiElementContainer();
container.Add(new CuiElement {
FadeOut = FadeOut, Parent = "Overlay", Name = "ALERT_UI_BLOCK", Components = {
new CuiImageComponent {
FadeIn = FadeIn, Color = HexToRustFormat(ColorBackground), Material = "assets/content/ui/uibackgroundblur-ingamemenu.mat"
}
, new CuiRectTransformComponent {
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "-199 -265", OffsetMax = "180 -225"
}
, new CuiOutlineComponent {
Color = HexToRustFormat(LineColor), Distance = "-1.32 1.32", UseGraphicAlpha = true
}
}
}
);
container.Add(new CuiLabel {
FadeOut = FadeOut, RectTransform = {
AnchorMin = "0.1125769 0.4749999", AnchorMax = "1 0.9833333"
}
, Text = {
FadeIn = FadeIn, Text = GetLang("UI_BLOCK_TITLE", LangID), FontSize = 18, Color = HexToRustFormat(Interface.Labels), Font = "robotocondensed-bold.ttf", Align = TextAnchor.MiddleCenter
}
}
, "ALERT_UI_BLOCK", "ALERT_UI_BLOCK_TITLE_ONE");
container.Add(new CuiLabel {
FadeOut = FadeOut, RectTransform = {
AnchorMin = "0.1125769 0.04166643", AnchorMax = "1 0.5499999"
}
, Text = {
FadeIn = FadeIn, Text = LangVaribles, FontSize = 12, Color = HexToRustFormat(Interface.Labels), Font = "robotocondensed-bold.ttf", Align = TextAnchor.MiddleCenter
}
}
, "ALERT_UI_BLOCK", "ALERT_UI_BLOCK_TITLE_TWO");
container.Add(new CuiElement {
FadeOut = FadeOut + 0.2f, Parent = "ALERT_UI_BLOCK", Name = "ALERT_UI_BLOCK_SPRITE", Components = {
new CuiImageComponent {
FadeIn = FadeIn - 0.8f, Sprite = "assets/icons/connection.png", Color = HexToRustFormat(Interface.Labels)
}
, new CuiRectTransformComponent {
AnchorMin = "0 1", AnchorMax = $"0 1", OffsetMin = "-20 -48", OffsetMax = "40 10"
}
,
}
}
);
if (playerList == null) {
if (player != null) CuiHelper.AddUi(player, container);
timer.Once(3f, () => {
if (player != null) {
CuiHelper.DestroyUi(player, "ALERT_UI_BLOCK");
CuiHelper.DestroyUi(player, "ALERT_UI_BLOCK_TITLE_ONE");
CuiHelper.DestroyUi(player, "ALERT_UI_BLOCK_TITLE_TWO");
CuiHelper.DestroyUi(player, "ALERT_UI_BLOCK_SPRITE");
}
}
);
}
else {
CommunityEntity.ServerInstance.ClientRPCEx(new SendInfo(playerList), null, "AddUI", container.ToJson());
timer.Once(3f, () => {
CommunityEntity.ServerInstance.ClientRPCEx(new SendInfo(playerList), null, "DestroyUI", "ALERT_UI_BLOCK");
CommunityEntity.ServerInstance.ClientRPCEx(new SendInfo(playerList), null, "DestroyUI", "ALERT_UI_BLOCK_TITLE_ONE");
CommunityEntity.ServerInstance.ClientRPCEx(new SendInfo(playerList), null, "DestroyUI", "ALERT_UI_BLOCK_TITLE_TWO");
CommunityEntity.ServerInstance.ClientRPCEx(new SendInfo(playerList), null, "DestroyUI", "ALERT_UI_BLOCK_SPRITE");
}
);
}
return false;
}
public Double TimeUnblock(Int32 BlockTime) => (SaveRestore.SaveCreatedTime.ToUniversalTime().Subtract(epoch).TotalSeconds + BlockTime) - (CurrentTime + SkipTimeBlocked);
void NetworkIDGetSet(UInt64 NetID, Boolean SetOrRemove, BasePlayer player = null) {
if (player == null) return;
if (!ContainerGetPlayer.ContainsKey(NetID)) ContainerGetPlayer.Add(NetID, new List<Connection> {
player.Connection
}
);
else {
if (SetOrRemove) {
if (!ContainerGetPlayer[NetID].Contains(player.Connection)) ContainerGetPlayer[NetID].Add(player.Connection);
}
else {
if (ContainerGetPlayer[NetID].Count <= 1) ContainerGetPlayer.Remove(NetID);
else ContainerGetPlayer[NetID].Remove(player.Connection);
}
}
}
private Coroutine routineDownloadImage;
[JsonProperty(LanguageEn ? "" : "Дата с информацией о игроках")]
public Dictionary<UInt64, Boolean> BlockHideInfo = new Dictionary<UInt64, Boolean>();
[ConsoleCommand("bpanel")]
void ConsoleCommandBlockPanel(ConsoleSystem.Arg arg) {
var General = config.GeneralSetting;
if (!General.UsePanelButton) return;
BasePlayer player = arg.Player();
if (player == null) return;
HideOrUnHigePanel(player, false);
}
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 =
// ... [Code preview truncated due to length. Full source in attached file] ...