C#:
using Network;
using Newtonsoft.Json;
using Oxide.Core;
using Oxide.Core.Configuration;
using Oxide.Core.Libraries.Covalence;
using Oxide.Game.Rust.Cui;
using Rust;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
namespace Oxide.Plugins {
[Info("CPS", "kils", "1.1.1")]
class myplugin : RustPlugin {
[ChatCommand("gaga")]
void cmdChatPos(BasePlayer player) {
}
private void MainUi(BasePlayer player) {
#region [Vars]
var container = new CuiElementContainer();
#endregion
#region [Parrent]
container.Add(new CuiPanel {
CursorEnabled = true, RectTransform = {
AnchorMin = "0 0", AnchorMax = "1 1", OffsetMax = "0 0"
}
, Image = {
Material = "assets/content/ui/uibackgroundblur.mat", Color = "0 0 0 0.77"
}
}
, "Overlay", Layer);
container.Add(new CuiElement {
Parent = Layer, Components = {
new CuiRawImageComponent {
Png = (string)plugins.Find("ImageLibrary")?.Call("GetImage", "bBlock"), Color = "1 1 1 0"
}
, new CuiRectTransformComponent {
AnchorMin = "0 0", AnchorMax = "1 1"
}
}
}
);
container.Add(new CuiButton {
RectTransform = {
AnchorMin = "0 0", AnchorMax = "1 1"
}
, Button = {
Color = "0.36 0.33 0.28 0", Material = "assets/icons/greyout.mat", Close = Layer
}
}
, Layer);
#endregion
#region [Main-Ui]
container.Add(new CuiPanel {
Image = {
Color = "0.36 0.34 0.32 0.72", Material = "assets/icons/greyout.mat"
}
, RectTransform = {
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "-455 -268", OffsetMax = "457 268"
}
, CursorEnabled = true,
}
, Layer, Layer + ".Main");
container.Add(new CuiElement {
Parent = Layer + ".Main", Components = {
new CuiTextComponent {
Color = "1 1 1 0.8", Text = "Список заблокированых предметов после вайпа", FontSize = 20, Align = TextAnchor.MiddleCenter, Font = "robotocondensed-bold.ttf"
}
, new CuiRectTransformComponent {
AnchorMin = "0 0.925", AnchorMax = "1 1"
}
,
}
}
);
#endregion
#region [Items]
foreach (var check in config.blockItems.Select((i, t) => new {
A = i, B = t
}
)) {
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = $"{0.008 + check.B * 0.09875 - Math.Floor((float) check.B / 10) * 10 * 0.09875} {0.755 - Math.Floor((float) check.B / 10) * 0.1685}", AnchorMax = $"{0.093 + check.B * 0.09875 - Math.Floor((float) check.B / 10) * 10 * 0.09875} {0.915 - Math.Floor((float) check.B / 10) * 0.1685}",
}
, Image = {
Color = "0 0 0 0", Material = "assets/icons/greyout.mat"
}
}
, Layer + ".Main", Layer + ".Main" + ".Items" + $".{check.B}");
container.Add(new CuiElement {
Parent = Layer + ".Main" + ".Items" + $".{check.B}", Components = {
new CuiImageComponent {
ItemId = FindItemID(check.A.Key), SkinId = 0, Color = BlockTimeGui(check.A.Key) ? $"1 1 1 0.65" : "1 1 1 1"
}
, new CuiRectTransformComponent {
AnchorMin = "-0.05 0", AnchorMax = "1.05 1"
}
}
}
);
container.Add(new CuiElement {
Parent = Layer + ".Main" + ".Items" + $".{check.B}", Name = Layer + ".Main" + ".Items" + $".{check.B}" + "Time", Components = {
new CuiTextComponent {
Text = BlockTimeGui(check.A.Key) ? $"<color=#FFFFFF>{Convert.ToInt32(Math.Floor(TimeSpan.FromSeconds(IsBlocked(check.A.Key)).TotalHours))}ч{TimeSpan.FromSeconds(IsBlocked(check.A.Key)).Minutes}м</color>" : "<color=#D4AD5A>Доступно</color>", FontSize = 14, Align = TextAnchor.MiddleCenter, Font = "robotocondensed-regular.ttf"
}
, new CuiRectTransformComponent {
AnchorMin = "0.04 0", AnchorMax = "1 0.18"
}
,
}
}
);
}
#endregion
CuiHelper.DestroyUi(player, Layer);
CuiHelper.AddUi(player, container);
}
}
}