C#:
// Все права принадлежат дискорд сообществу https://discord.gg/VgNHPpNrz6
using System.Linq;
using Oxide.Game.Rust.Cui;
using ConVar;
using Oxide.Core;
using UnityEngine;
using System.Text;
using Object = System.Object;
using System.Collections.Generic;
using System;
using Oxide.Core.Plugins;
using Newtonsoft.Json;
using Network;
namespace Oxide.Plugins {
[Info("IQWipeBlock", "Mercury", "1.11.10")]
[Description("Блокируй по умному с IQWipeBlock")]
class IQWipeBlock : RustPlugin {
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;
}
static Double CurrentTime => Facepunch.Math.Epoch.Current;
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 bool? CanEquipItem(PlayerInventory inventory, Item item) => CanWearItem(inventory, item);
Boolean Interface_UI_Block(BasePlayer player, String Shortname, String ShortnameModule = "", UInt64 SkinID = 0, List<Connection> playerList = null, Boolean IsCheckConnect = false) {
if (Shortname == null || String.IsNullOrWhiteSpace(Shortname)) return true;
Shortname = ShortnameValidation(Shortname);
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;
if (!IsCheckConnect) {
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.041450043", AnchorMax = "1 0.5445009"
}
, 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 enum TypeLock {
Locked, Fire, Flash
}
object CanMountEntity(BasePlayer player, MLRS entity) {
if (player == null || entity == null) return null;
if (Interface_UI_Block(player, "ammo.rocket.mlrs")) return null;
else return false;
}
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.Value;
NetworkIDGetSet(NetID, true, player);
return null;
}
public void SendImage(BasePlayer player, String imageName, UInt64 imageId = 0) => ImageLibrary?.Call("SendImage", player, imageName, imageId);
void WriteData() {
Oxide.Core.Interface.Oxide.DataFileSystem.WriteObject("IQWipeBlock/HideStatus", BlockHideInfo);
Oxide.Core.Interface.Oxide.DataFileSystem.WriteObject("IQWipeBlock/SkipTimeBlocked", SkipTimeBlocked);
}
void OnPlayerLootEnd(PlayerLoot inventory) {
if (inventory.entitySource == null || inventory.entitySource.net == null) return;
BasePlayer player = inventory.GetComponent<BasePlayer>();
if (player == null) return;
UInt64 NetID = inventory.entitySource.net.ID.Value;
NetworkIDGetSet(NetID, false, player);
}
private void ValidsItemTurret(AutoTurret Turret, Item item, Boolean AddedOrRemove) {
if (!AddedOrRemove) return;
if (item.parent == null) return;
if(item.parent.uid.Value == 384258468) return;
BasePlayer player = BasePlayer.FindByID(Turret.OwnerID);
if (Interface_UI_Block(player, item.info.shortname, "", item.skin)) {
if (Turret.inventory.itemList.Count == 0 || Turret.inventory.itemList[0] == null) return;
if (Interface_UI_Block(player, Turret.inventory.itemList[0].info.shortname, item.info.shortname)) return;
}
if (player != null) {
if (item.MoveToContainer(player.inventory.containerMain)) return;
}
item.Drop(Turret.transform.position + new Vector3(0f, 1f, 0f), Turret.GetDropVelocity());
}
[ConsoleCommand("skip.wb")]
void ConsoleSkipWipeBlock(ConsoleSystem.Arg arg) {
BasePlayer player = arg.Player();
if (player != null && !player.IsAdmin) return;
if (!arg.HasArgs(1)) return;
Int32 SkipTime = 0;
if(!Int32.TryParse(arg.Args[0], out SkipTime)) {
PrintWarning(LanguageEn ? "Syntax error! Syntax : skip.wb Time" : "Ошибка синтаксиса! Синтаксис : skip.wb Time");
return;
}
if(SkipTime < 0) {
PrintWarning(LanguageEn ? "The time cannot be lower than 0!" : "Время не может быть ниже 0!");
return;
}
SkipTimeBlocked = SkipTime;
PrintWarning(LanguageEn ? $"You have successfully set the time {SkipTime}" : $"Вы успешно установили время {SkipTime}");
}
[PluginReference]
Plugin IQChat, ImageLibrary, Battles, Duel, Duelist, ArenaTournament, AimTraining, XFarmRoom, OneVSOne, EventHelper, IQBackpack, IQRecycler;
// https://umod.org/plugins/duelist
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);
}
void HideOrUnHigePanel(BasePlayer player, Boolean IsMenu) {
if (BlockHideInfo[player.userID]) {
BlockHideInfo[player.userID] = false;
if (IsMenu) HideButtonIsMenu(player);
Interface_Button_Panel(player);
}
else {
BlockHideInfo[player.userID] = true;
if (IsMenu) HideButtonIsMenu(player);
CuiHelper.DestroyUi(player, IQWIPE_PARENT_PANEL_BTN);
}
}
[JsonProperty(LanguageEn ? "" : "Сдвиг времени в секундах")]
public Int32 SkipTimeBlocked = 0;
// private void OnPluginLoaded(Plugin plugin)
// {
// if (plugin == null)
// return;
//
// NextTick(TogglePickUpHook);
// }
//
// private void TogglePickUpHook()
// {
// Unsubscribe(nameof(CanAcceptItem));
// Subscribe(nameof(OnItemAddedToContainer));
// }
void OnItemAddedToContainer(ItemContainer container, Item item) {
if (container == null || item == null) return;
BasePlayer player = container.playerOwner;
if (player == null || !player.userID.IsSteamId() || player.IsNpc) return;
if (IsDuel(player.userID)) return;
if (IQBackpack && (Boolean)IQBackpack.CallHook("IsSaveItemBackpack", player, item)) return;
Boolean Status = !Interface_UI_Block(player, item.info.shortname, "", item.skin);
if (IQRecycler && IQRecycler.Call<Boolean>("IsBlackList", player.userID, item) && item.HasFlag(global : : Item.Flag.IsLocked) && !Status) return;
if (Status) {
if (container == player.inventory.containerWear) {
if (player.inventory.containerMain.itemList.Count >= 24) item.DropAndTossUpwards(player.transform.position);
else item.MoveToContainer(player.inventory.containerMain);
}
else if (container == player.inventory.containerBelt) {
if (player.inventory.containerMain.itemList.Count > 24) item.DropAndTossUpwards(player.transform.position);
else item.MoveToContainer(player.inventory.containerMain);
}
else {
if (player.inventory.containerMain.itemList.Count > 24) item.DropAndTossUpwards(player.transform.position);
}
}
SetFlagItem(item, Status);
}
public Double TimeUnblock(Int32 BlockTime) => (SaveRestore.SaveCreatedTime.ToUniversalTime().Subtract(epoch).TotalSeconds + BlockTime) - (CurrentTime + SkipTimeBlocked);
private Vector3 GetDropVelocity(StorageContainer container) {
return container switch {
AttackHelicopterTurret turret => turret.GetDropVelocity(), AttackHelicopterRockets rockets => rockets.GetDropVelocity(), _ => new Vector3(0f, 0f, 0f)
}
;
}
void Unload() {
WriteData();
ServerMgr.Instance.CancelInvoke(CheckAllUnlock);
foreach (BasePlayer player in BasePlayer.activePlayerList) {
CuiHelper.DestroyUi(player, IQWIPE_PARENT);
CuiHelper.DestroyUi(player, IQWIPE_PARENT_PANEL_BTN);
}
}
public Boolean HasImage(String imageName) => (Boolean)ImageLibrary?.Call("HasImage", imageName);
private void ValidsItemAttackHelicopter(StorageContainer container, Item item, Boolean AddedOrRemove) {
if (!AddedOrRemove || item.parent == null || item.parent.uid.Value == 384258468) return;
BasePlayer player = BasePlayer.FindByID(container.OwnerID);
if (Interface_UI_Block(player, item.info.shortname, "", item.skin)) {
if (container.inventory.itemList.Count == 0 || container.inventory.itemList[0] == null) return;
if (Interface_UI_Block(player, container.inventory.itemList[0].info.shortname, item.info.shortname)) return;
}
if (player != null && item.MoveToContainer(player.inventory.containerMain)) return;
item.Drop(container.transform.position + new Vector3(0f, 1f, 0f), GetDropVelocity(container));
}
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.6927 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.7546 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"},
// }
// });
container.Add(new CuiElement {
Parent = IQWIPE_PARENT + $"PANEL_ITEM_{ItemCount}", Name = IQWIPE_PARENT + $"IMG_{ItemCount}", Components = {
new CuiImageComponent() {
FadeIn = FadeIn, Color = "1 1 1 1", ItemId = ItemManager.FindItemDefinition(Item.Key).itemid
}
, 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);
}
public Dictionary<UInt64, List<Connection>> ContainerGetPlayer = new Dictionary<UInt64, List<Connection>>();
protected override void SaveConfig() => Config.WriteObject(config);
object OnMagazineReload(BaseProjectile weapon, IAmmoContainer desiredAmount, BasePlayer player) {
if (player == null || !player.userID.IsSteamId() || player.IsNpc || weapon == null) return null;
if (player.inventory == null) return null;
if (IsDuel(player.userID)) return null;
weapon.SwitchAmmoTypesIfNeeded(player.inventory);
weapon.SendNetworkUpdate();
if (Interface_UI_Block(player, weapon.primaryMagazine.ammoType.shortname)) if (Interface_UI_Block(player, player.GetActiveItem().info.shortname, weapon.primaryMagazine.ammoType.shortname)) return null;
else return false;
else return false;
}
public enum AlignCategory {
Left, Middle, Right
}
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);
}
/// <summary>
/// Обновление 1./// - Предотвращение возможного дюпа в связке с XSkinMenu
/// </summary>
private const Boolean LanguageEn = false;
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 void CheckAllUnlock() {
Double TimeBlockMain = config.Block.BlockWeaponAndTools.Union(config.Block.BlockArmory).Union(config.Block.BlockBoom).ToDictionary(x => x.Key, x => x.Value).Where(x => TimeUnblock(x.Value.TimeBlock) > 0).Sum(s => TimeUnblock(s.Value.TimeBlock));
Double TimeBlockOther = config.Block.BlockWeaponAndTools.Union(config.Block.BlockArmory).Union(config.Block.BlockBoom).ToDictionary(x => x.Key, x => x.Value).Sum(s => s.Value.BlockMoreList.Where(x => TimeUnblock(x.Value) > 0).Sum(z => TimeUnblock(z.Value)));
Double AllTime = TimeBlockMain + TimeBlockOther;
if (AllTime <= 0) {
Unsubscribe("OnPlayerLootEnd");
//Unsubscribe("CanAcceptItem"); //// TODO
//Unsubscribe("OnItemAddedToContainer"); //// TODO
Unsubscribe("CanWearItem");
Unsubscribe("OnItemAction");
Unsubscribe("CanEquipItem");
Unsubscribe("OnWeaponReload");
Unsubscribe("OnMagazineReload");
if (config.Interface.ButtonIsBlock) {
foreach (BasePlayer player in BasePlayer.activePlayerList) CuiHelper.DestroyUi(player, IQWIPE_PARENT_PANEL_BTN);
}
if (config.GeneralSetting.AlertAllUsersUnlocked) foreach (BasePlayer player in BasePlayer.activePlayerList) SendChat(GetLang("CHAT_ALERT_ALL_USERS_ALL_UNLOCK", player.UserIDString), player);
IsUnlockedAll = true;
PrintWarning(LanguageEn ? "All items have been successfully unlocked!" : "Все предметы были успешно разблокированы!");
ServerMgr.Instance.CancelInvoke(CheckAllUnlock);
}
}
[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);
}
private Boolean IsItemBlock(BasePlayer player, String Shortname) {
if (Shortname == null || String.IsNullOrWhiteSpace(Shortname)) return true;
Shortname = ShortnameValidation(Shortname);
if (player != null) if (permission.UserHasPermission(player.UserIDString, PermissionIgnoreBlock)) return true;
Configuration.Blocks Block = config.Block;
Dictionary<String, Configuration.Blocks.BlockElement> BlockAll = Block.BlockArmory.Concat(Block.BlockWeaponAndTools).Concat(Block.BlockBoom).ToDictionary(x => x.Key, x => x.Value);
return BlockAll.ContainsKey(Shortname) && TimeUnblock(BlockAll[Shortname].TimeBlock) > 0;
}
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 if(SkinID == 2907425987) return true;
else if(SkinID == 2904500597) return true;
else return false;
}
void RegisteredUser(BasePlayer player) {
if (BlockHideInfo.ContainsKey(player.userID)) return;
BlockHideInfo.Add(player.userID, false);
}
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 = {
n
// ... [Code preview truncated due to length. Full source in attached file] ...