C#:
// Все права принадлежат дискорд сообществу https://discord.gg/VgNHPpNrz6
using Newtonsoft.Json;
using Oxide.Core;
using Oxide.Core.Libraries;
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace Oxide.Plugins {
[Info("zEcoLootUI", "EcoSmile", "1.1.8")]
class zEcoLootUI : RustPlugin {
private Dictionary<string, string> containerNames = new Dictionary<string, string>() {
["crate_basic"]
= "Маленький деревянный ящик", ["crate_elite"] = "Элитный ящик", ["crate_mine"] = "Ящик из пещер", ["crate_tools"] = "Ящик с инструментами", ["crate_normal"] = "Зеленый военный ящик", ["crate_normal_2"] = "Обычный деревянный ящик", ["crate_normal_2_food"] = "Ящик с едой", ["crate_normal_2_medical"] = "Ящик с медециной", ["crate_underwater_advanced"] = "Большой подводный ящик", ["crate_underwater_basic"] = "Малый подводный ящик", ["foodbox"] = "Корзинка с едой", ["loot_barrel_1"] = "Синяя бочка у дорог", ["loot_barrel_2"] = "Ржавая бочка у дорог", ["loot-barrel-1"] = "Ржавая бочка на РТ", ["loot-barrel-2"] = "Синяя бочка на РТ", ["minecart"] = "Тележка с углем", ["bradley_crate"] = "Бредли ящик", ["oil_barrel"] = "Нефтяная бочка", ["heli_crate"] = "Вертолетный ящик", ["codelockedhackablecrate"] = "Ящик с электронным замком", ["supply_drop"] = "Аир дроп", ["trash-pile-1"] = "Корзинка с припасами", ["vehicle_parts"] = "Ящик с частями", ["codelockedhackablecrate_oilrig"] = "Ящик с электронным замком с Нефтевышки", ["presentdrop"] = "Новогодний дроп"
}
;
List<string> prefabcontaner = new List<string>() {
"assets/bundled/prefabs/radtown/crate_basic.prefab", "assets/bundled/prefabs/radtown/crate_elite.prefab", "assets/bundled/prefabs/radtown/crate_mine.prefab", "assets/bundled/prefabs/radtown/crate_tools.prefab", "assets/bundled/prefabs/radtown/crate_normal.prefab", "assets/bundled/prefabs/radtown/crate_normal_2.prefab", "assets/bundled/prefabs/radtown/crate_normal_2_food.prefab", "assets/bundled/prefabs/radtown/crate_normal_2_medical.prefab", "assets/bundled/prefabs/radtown/crate_underwater_advanced.prefab", "assets/bundled/prefabs/radtown/crate_underwater_basic.prefab", "assets/bundled/prefabs/radtown/foodbox.prefab", "assets/bundled/prefabs/radtown/loot_barrel_1.prefab", "assets/bundled/prefabs/radtown/loot_barrel_2.prefab", "assets/bundled/prefabs/autospawn/resource/loot/loot-barrel-1.prefab", "assets/bundled/prefabs/autospawn/resource/loot/loot-barrel-2.prefab", "assets/bundled/prefabs/radtown/minecart.prefab", "assets/prefabs/npc/m2bradley/bradley_crate.prefab", "assets/bundled/prefabs/radtown/oil_barrel.prefab", "assets/prefabs/npc/patrol helicopter/heli_crate.prefab", "assets/prefabs/deployable/chinooklockedcrate/codelockedhackablecrate.prefab", "assets/prefabs/misc/supply drop/supply_drop.prefab", "assets/bundled/prefabs/autospawn/resource/loot/trash-pile-1.prefab", "assets/bundled/prefabs/radtown/vehicle_parts.prefab", "assets/prefabs/deployable/chinooklockedcrate/codelockedhackablecrate_oilrig.prefab", "assets/prefabs/misc/xmas/sleigh/presentdrop.prefab"
}
;
PluginConfig config;
public class PluginConfig {
[JsonProperty("Настройка контейнеров")]
public Dictionary<string, LootSetting> crateSetting;
}
public class LootSetting {
[JsonProperty("Рандомить количество слотов в ящике? (false - будет браться максимум)")]
public bool RandomItemAmount;
[JsonProperty("Максимум слотов")]
public int MaxItemInCrate;
[JsonProperty("Минимум слотов")]
public int MinItemInCrate;
[JsonProperty("Удалять ящик если не был залутан до конца?")]
public bool DeleteCrate;
[JsonProperty("Интервал удаления ящика (минуты)")]
public int DeleteTimer;
}
Dictionary<string, LootSetting> ConfigSetup() {
Dictionary<string, LootSetting> setting = new Dictionary<string, LootSetting>();
foreach (var value in containerNames.Values) setting.Add(value, new LootSetting() {
RandomItemAmount = false, MaxItemInCrate = 4, MinItemInCrate = 4, DeleteCrate = true, DeleteTimer = 5
}
);
return setting;
}
protected override void LoadDefaultConfig() {
config = new PluginConfig() {
crateSetting = ConfigSetup()
}
;
}
protected override void LoadConfig() {
base.LoadConfig();
config = Config.ReadObject<PluginConfig>();
foreach (KeyValuePair<string, string> value in containerNames.Where(x => !config.crateSetting.ContainsKey(x.Value))) {
PrintWarning($"Added New crate {value.Value}");
config.crateSetting.Add(value.Value, new LootSetting() {
RandomItemAmount = false, MaxItemInCrate = 4, MinItemInCrate = 4, DeleteCrate = true, DeleteTimer = 5
}
);
}
SaveConfig();
}
protected override void SaveConfig() => Config.WriteObject(config);
void OnServerInitialized() {
version = $"{this.Version.Major}_{this.Version.Minor}_{this.Version.Patch}";
ChekNewItem();
GetDefaultLoot();
RestoreBase();
LootTimer();
}
string version = $"";
private Dictionary<BasePlayer, bool> visionImage = new Dictionary<BasePlayer, bool>();
void RestoreBase() {
foreach (var prefab in containerNames) {
List<ItemSetting> itemlist = Interface.Oxide.DataFileSystem.ReadObject<List<ItemSetting>>($"zEcoLootUI/{prefab.Value}");
foreach (var loot in itemlist) {
if (loot.version == $"{this.Version.Major}_{this.Version.Minor}_{this.Version.Patch}") continue;
loot.version = version;
Item it = ItemManager.CreateByName(loot.shortname);
if (it.hasCondition && (loot.Condition == 0f || loot.Condition > 100f)) {
var fraction = UnityEngine.Random.Range(it.info.condition.foundCondition.fractionMin, it.info.condition.foundCondition.fractionMax);
var condition = fraction * 100f;
loot.Condition = condition;
}
loot.HasCondition = it.hasCondition;
}
Interface.Oxide.DataFileSystem.WriteObject($"zEcoLootUI/{prefab.Value}", itemlist);
}
}
void Unload() {
foreach (var pl in BasePlayer.activePlayerList) {
CuiHelper.DestroyUi(pl, "zEcoLootUI.Main.UI");
}
}
void OnHammerHit(BasePlayer player, HitInfo info) {
if (!player.IsAdmin) return;
if (!(info.HitEntity is LootContainer)) return;
CuiHelper.DestroyUi(player, "zEcoLootUI.Main.UI");
var container = new CuiElementContainer();
container.Add(new CuiElement() {
Parent = "Overlay", Name = "zEcoLootUI.Main.UI", Components = {
new CuiButtonComponent {
Close = "zEcoLootUI.Main.UI", Color = "0 0 0 0.8", Sprite = "assets/content/ui/ui.background.transparent.radial.psd", Material = "assets/content/ui/uibackgroundblur.mat"
}
, new CuiNeedsCursorComponent {
}
, new CuiRectTransformComponent {
AnchorMin = "0 0", AnchorMax = "1 1",
}
}
}
);
container.Add(new CuiElement() {
Parent = "zEcoLootUI.Main.UI", Name = $"zEcoLootUI.Main.UI.text", Components = {
new CuiTextComponent {
Text = $"Редактируется:\n{(containerNames.ContainsKey(info.HitEntity.ShortPrefabName) ? containerNames[info.HitEntity.ShortPrefabName] : info.HitEntity.ShortPrefabName)}", Align = TextAnchor.MiddleCenter, FontSize = 22
}
, new CuiOutlineComponent {
Color = "0 0 0 1", Distance = "-1 1"
}
, new CuiRectTransformComponent {
AnchorMin = $"0.5 0.9", AnchorMax = $"0.5 0.9", OffsetMin = $"-250 -64", OffsetMax = $"250 80",
}
}
}
);
CuiHelper.AddUi(player, container);
DrawPanel(player, info.HitEntity.ShortPrefabName);
}
void DrawPanel(BasePlayer player, string prefab) {
if (coroutine != null) ServerMgr.Instance.StopCoroutine(coroutine);
var container = new CuiElementContainer();
CuiHelper.DestroyUi(player, "zEcoLootUI.Main.UI.BG");
container.Add(new CuiElement() {
Parent = "zEcoLootUI.Main.UI", Name = "zEcoLootUI.Main.UI.BG", Components = {
new CuiImageComponent {
Color = "0 0 0 0.0"
}
, new CuiRectTransformComponent {
AnchorMin = "0 0", AnchorMax = "1 1",
}
}
}
);
CuiHelper.AddUi(player, container);
DrawCrateitem(player, prefab);
}
void DrawCrateitem(BasePlayer player, string prefab, int page = 0) {
ServerMgr.Instance.StartCoroutine(DrawCrateItem(player, prefab, page));
}
Coroutine coroutine;
[PluginReference]
Plugin ImageLibrary;
[ConsoleCommand("AddSlot")]
void AddSlot(ConsoleSystem.Arg arg) {
var player = arg.Player();
config.crateSetting[containerNames[arg.Args[0]]].MinItemInCrate++;
config.crateSetting[containerNames[arg.Args[0]]].MaxItemInCrate = config.crateSetting[containerNames[arg.Args[0]]].MinItemInCrate;
Config.WriteObject(config);
CuiHelper.DestroyUi(player, "zEcoLootUI.Main.UI.BG.Slot");
var container = new CuiElementContainer();
container.Add(new CuiElement() {
Parent = "zEcoLootUI.Main.UI.BG", Name = $"zEcoLootUI.Main.UI.BG.Slot", Components = {
new CuiTextComponent {
Text = $"{config.crateSetting[containerNames[arg.Args[0]]].MinItemInCrate}", Align = TextAnchor.MiddleCenter, FontSize = 22
}
, new CuiOutlineComponent {
Color = "0 0 0 1", Distance = "-1 1"
}
, new CuiRectTransformComponent {
AnchorMin = $"0.15 0.95", AnchorMax = $"0.15 0.95", OffsetMin = $"-30 -15", OffsetMax = $"30 15",
}
}
}
);
CuiHelper.AddUi(player, container);
}
[ConsoleCommand("RemSlot")]
void RemSlot(ConsoleSystem.Arg arg) {
var player = arg.Player();
config.crateSetting[containerNames[arg.Args[0]]].MinItemInCrate--;
if (config.crateSetting[containerNames[arg.Args[0]]].MinItemInCrate < 1) config.crateSetting[containerNames[arg.Args[0]]].MinItemInCrate = 1;
config.crateSetting[containerNames[arg.Args[0]]].MaxItemInCrate = config.crateSetting[containerNames[arg.Args[0]]].MinItemInCrate;
Config.WriteObject(config);
CuiHelper.DestroyUi(player, "zEcoLootUI.Main.UI.BG.Slot");
var container = new CuiElementContainer();
container.Add(new CuiElement() {
Parent = "zEcoLootUI.Main.UI.BG", Name = $"zEcoLootUI.Main.UI.BG.Slot", Components = {
new CuiTextComponent {
Text = $"{config.crateSetting[containerNames[arg.Args[0]]].MinItemInCrate}", Align = TextAnchor.MiddleCenter, FontSize = 22
}
, new CuiOutlineComponent {
Color = "0 0 0 1", Distance = "-1 1"
}
, new CuiRectTransformComponent {
AnchorMin = $"0.15 0.95", AnchorMax = $"0.15 0.95", OffsetMin = $"-30 -15", OffsetMax = $"30 15",
}
}
}
);
CuiHelper.AddUi(player, container);
}
IEnumerator DrawCrateItem(BasePlayer player, string prefab, int page = 0) {
CuiHelper.DestroyUi(player, "zEcoLootUI.Main.UI.BG");
if (!visionImage.ContainsKey(player)) visionImage.Add(player, false);
List<ItemSetting> itemlist = Interface.Oxide.DataFileSystem.ReadObject<List<ItemSetting>>($"zEcoLootUI/{containerNames[prefab]}");
var container = new CuiElementContainer();
container.Add(new CuiElement() {
Parent = "zEcoLootUI.Main.UI", Name = "zEcoLootUI.Main.UI.BG", Components = {
new CuiImageComponent {
Color = "0 0 0 0.0"
}
, new CuiRectTransformComponent {
AnchorMin = "0 0", AnchorMax = "1 1",
}
}
}
);
container.Add(new CuiButton() {
Button = {
Command = $"AddSlot {prefab}", Color = "0 1 0 0.3"
}
, Text = {
Text = "+Slot", Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = "0.1 0.95", AnchorMax = "0.1 0.95", OffsetMin = "-30 -15", OffsetMax = "30 15"
}
}
, "zEcoLootUI.Main.UI.BG", "AddSlot");
container.Add(new CuiElement() {
Parent = "zEcoLootUI.Main.UI.BG", Name = $"zEcoLootUI.Main.UI.BG.Slot", Components = {
new CuiTextComponent {
Text = $"{config.crateSetting[containerNames[prefab]].MinItemInCrate}", Align = TextAnchor.MiddleCenter, FontSize = 22
}
, new CuiOutlineComponent {
Color = "0 0 0 1", Distance = "-1 1"
}
, new CuiRectTransformComponent {
AnchorMin = $"0.15 0.95", AnchorMax = $"0.15 0.95", OffsetMin = $"-30 -15", OffsetMax = $"30 15",
}
}
}
);
container.Add(new CuiButton() {
Button = {
Command = $"RemSlot {prefab}", Color = "0 1 0 0.3"
}
, Text = {
Text = "-Slot", Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = "0.2 0.95", AnchorMax = "0.2 0.95", OffsetMin = "-30 -15", OffsetMax = "30 15"
}
}
, "zEcoLootUI.Main.UI.BG", "RemSlot");
container.Add(new CuiButton() {
Button = {
Command = $"Add {prefab}", Color = "0 1 0 0.3"
}
, Text = {
Text = "ДОБАВИТЬ", Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = "0.4 0.05", AnchorMax = "0.4 0.05", OffsetMin = "-60 -15", OffsetMax = "60 15"
}
}
, "zEcoLootUI.Main.UI.BG", "AddBtn");
container.Add(new CuiButton() {
Button = {
Command = $"hidelootimage {prefab}", Color = "1 1 1 0.3"
}
, Text = {
Text = visionImage.ContainsKey(player) ? visionImage[player] ? "Показать картинки" : "Скрыть картинки" : "Скрыть картинки", Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = "0.5 0.05", AnchorMax = "0.5 0.05", OffsetMin = "-60 -20", OffsetMax = "40 20"
}
}
, "zEcoLootUI.Main.UI.BG", "HideImageBtn");
container.Add(new CuiButton() {
Button = {
Command = $"AddInv {prefab}", Color = "1 1 1 0.2"
}
, Text = {
Text = "ДОБАВИТЬ ИЗ ИНВЕТАРЯ", Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = "0.6 0.05", AnchorMax = "0.6 0.05", OffsetMin = "-80 -15", OffsetMax = "80 15"
}
}
, "zEcoLootUI.Main.UI.BG", "AddBtn");
CuiHelper.AddUi(player, container);
var starthorisontal = 0.05f;
var startvertical = 0.8f;
var horisontal = starthorisontal;
var vertical = startvertical;
var widthBtn = 32;
var hightBtn = 32;
int count = 0;
int i = page == 0 ? 0 : page * 60;
foreach (var item in itemlist.Skip(page * 60).Take(60)) {
var itemContainer = new CuiElementContainer();
if (!visionImage[player]) {
itemContainer.Add(new CuiElement() {
Parent = "zEcoLootUI.Main.UI.BG", Name = $"zEcoLootUI.Main.UI.BG.{i}", Components = {
new CuiRawImageComponent {
Png = GetItemImage(item.shortname, item.skin)
}
, new CuiRectTransformComponent {
AnchorMin = $"{horisontal} {vertical}", AnchorMax = $"{horisontal} {vertical}", OffsetMin = $"-{widthBtn} -{hightBtn}", OffsetMax = $"{widthBtn} {hightBtn}",
}
}
}
);
}
else {
itemContainer.Add(new CuiElement() {
Parent = "zEcoLootUI.Main.UI.BG", Name = $"zEcoLootUI.Main.UI.BG.{i}", Components = {
new CuiImageComponent {
Color = "1 1 1 0.1"
}
, new CuiRectTransformComponent {
AnchorMin = $"{horisontal} {vertical}", AnchorMax = $"{horisontal} {vertical}", OffsetMin = $"-{widthBtn} -{hightBtn}", OffsetMax = $"{widthBtn} {hightBtn}",
}
}
}
);
}
itemContainer.Add(new CuiElement() {
Parent = $"zEcoLootUI.Main.UI.BG.{i}", Name = $"zEcoLootUI.Main.UI.BG.{i}.Btn_Delete", Components = {
new CuiButtonComponent {
Color = "1 0 0 0.4", Command = $"Delete {prefab} {page} {i}"
}
, new CuiRectTransformComponent {
AnchorMin = "1 1", AnchorMax = "1 1", OffsetMin = "-20 -16", OffsetMax = "0 0"
}
}
}
);
itemContainer.Add(new CuiElement() {
Parent = $"zEcoLootUI.Main.UI.BG.{i}.Btn_Delete", Name = $"zEcoLootUI.Main.UI.BG.{i}.Btn_Delete.Txt", Components = {
new CuiTextComponent {
Text = "Del", Align = TextAnchor.MiddleCenter, FontSize = 12
}
, new CuiRectTransformComponent {
AnchorMin = "0 0", AnchorMax = "1 1"
}
}
}
);
if (item.IsBp) itemContainer.Add(new CuiElement() {
Parent = $"zEcoLootUI.Main.UI.BG.{i}", Name = $"zEcoLootUI.Main.UI.BG.{i}.IsBP", Components = {
//new CuiRawImageComponent{Png = GetItemImage("blueprintbase") },
new CuiRawImageComponent {
Sprite ="assets/icons/blueprint.png"
}
, new CuiRectTransformComponent {
AnchorMin = "0 1", AnchorMax = "0 1", OffsetMin = "0 -20", OffsetMax = "20 0"
}
}
}
);
else {
if (item.HasCondition) {
itemContainer.Add(new CuiElement() {
Parent = $"zEcoLootUI.Main.UI.BG.{i}", Name = $"zEcoLootUI.Main.UI.BG.{i}.condition.BG", Components = {
new CuiImageComponent {
Color = "1 1 1 0.5"
}
, new CuiRectTransformComponent {
AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "1 1", OffsetMax = "5 62"
}
}
}
);
var cond = 62 * item.Condition / 100f;
itemContainer.Add(new CuiElement() {
Parent = $"zEcoLootUI.Main.UI.BG.{i}.condition.BG", Name = $"zEcoLootUI.Main.UI.BG.{i}.condition", Components = {
new CuiImageComponent {
Color = "0 0.5 0 1"
}
, new CuiRectTransformComponent {
AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "0 0", OffsetMax = $"4 {cond}"
}
}
}
);
itemContainer.Add(new CuiElement() {
Parent = $"zEcoLootUI.Main.UI.BG.{i}", Name = $"zEcoLootUI.Main.UI.BG.{i}.Btn_Condition", Components = {
new CuiButtonComponent {
Color = "1 1 1 0.3", Command = $"condition {prefab} {page} {i}"
}
, new CuiRectTransformComponent {
AnchorMin = "0 1", AnchorMax = "0 1", OffsetMin = "1 -11", OffsetMax = "25 -1"
}
}
}
);
itemContainer.Add(new CuiElement() {
Parent = $"zEcoLootUI.Main.UI.BG.{i}.Btn_Condition", Name = $"zEcoLootUI.Main.UI.BG.{i}.Btn_Condition.Txt", Components = {
new CuiTextComponent {
Text = "cond", Align = TextAnchor.MiddleCenter, FontSize = 9, Color = "1 1 1 1"
}
, new CuiRectTransformComponent {
AnchorMin = "0 0", AnchorMax = "1 1"
}
}
}
);
}
}
itemContainer.Add(new CuiElement() {
Parent = $"zEcoLootUI.Main.UI.BG.{i}", Name = $"zEcoLootUI.Main.UI.BG.{i}.text", Components = {
new CuiTextComponent {
Text = string.IsNullOrEmpty(item.custonname) ? ItemManager.CreateByName(item.shortname).info.displayName.english : item.custonname, Align = TextAnchor.MiddleCenter
}
, new CuiRectTransformComponent {
AnchorMin = $"0.5 0", AnchorMax = $"0.5 0", OffsetMin = $"-{widthBtn+5} -40", OffsetMax = $"{widthBtn+5} -5",
}
}
}
);
itemContainer.Add(new CuiButton() {
Button = {
Command = $"BPChange {prefab} {page} {i}", Color = "1 1 1 0.3"
}
, Text = {
Text = "BP", Align = TextAnchor.MiddleCenter, FontSize = 8
}
, RectTransform = {
AnchorMin = $"0.5 0", AnchorMax = $"0.5 0", OffsetMin = $"45 41", OffsetMax = $"66 50",
}
}
, $"zEcoLootUI.Main.UI.BG.{i}", $"ButtonMinBP.{i}");
itemContainer.Add(new CuiElement() {
Parent = $"zEcoLootUI.Main.UI.BG.{i}", Name = $"zEcoLootUI.Main.UI.BG.{i}.textmin", Components = {
new CuiTextComponent {
Text = $"min - {item.minamount}" , Align = TextAnchor.MiddleRight, FontSize = 9
}
, new CuiRectTransformComponent {
AnchorMin = $"0.5 0", AnchorMax = $"0.5 0", OffsetMin = $"-{widthBtn+10} 15", OffsetMax = $"{widthBtn+10} 35",
}
}
}
);
itemContainer.Add(new CuiButton() {
Button = {
Command = $"editfeil {prefab} {page} {i} minminus", Color = "1 1 1 0.3"
}
, Text = {
Text = "edit", Align = TextAnchor.MiddleCenter, FontSize = 8
}
, RectTransform = {
AnchorMin = $"0.5 0", AnchorMax = $"0.5 0", OffsetMin = $"45 21", OffsetMax = $"66 30",
}
}
, $"zEcoLootUI.Main.UI.BG.{i}", $"ButtonMinMinus.{i}");
itemContainer.Add(new CuiElement() {
Parent = $"zEcoLootUI.Main.UI.BG.{i}", Name = $"zEcoLootUI.Main.UI.BG.{i}.textmax", Components = {
new CuiTextComponent {
Text = $"max - {item.maxamount}" , Align = TextAnchor.MiddleRight, FontSize = 9
}
, new CuiRectTransformComponent {
AnchorMin = $"0.5 0", AnchorMax = $"0.5 0", OffsetMin = $"-{widthBtn+10} 5", OffsetMax = $"{widthBtn+10} 25",
}
}
}
);
itemContainer.Add(new CuiButton() {
Button = {
Command = $"editfeil {prefab} {page} {i} maxminus", Color = "1 1 1 0.3"
}
, Text = {
Text = "edit", Align = TextAnchor.MiddleCenter, FontSize = 8
}
, RectTransform = {
AnchorMin = $"0.5 0", AnchorMax = $"0.5 0", OffsetMin = $"45 10", OffsetMax = $"66 19",
}
}
, $"zEcoLootUI.Main.UI.BG.{i}", $"ButtonMaxMinus.{i}");
itemContainer.Add(new CuiElement() {
Parent = $"zEcoLootUI.Main.UI.BG.{i}", Name = $"zEcoLootUI.Main.UI.BG.{i}.textchance", Components = {
new CuiTextComponent {
Text = $"chance - {item.chansedrop}%" , Align = TextAnchor.MiddleRight, FontSize = 9
}
, new CuiRectTransformComponent {
AnchorMin = $"0.5 0", AnchorMax = $"0.5 0", OffsetMin = $"-{widthBtn+10} -10", OffsetMax = $"{widthBtn+10} 15",
}
}
}
);
itemContainer.Add(new CuiButton() {
Button = {
Command = $"editfeil {prefab} {page} {i} chanceminus", Color = "1 1 1 0.3"
}
, Text = {
Text = "edit", Align = TextAnchor.MiddleCenter, FontSize = 8
}
, RectTransform = {
AnchorMin = $"0.5 0", AnchorMax = $"0.5 0", OffsetMin = $"45 -1", OffsetMax = $"66 8",
}
}
, $"zEcoLootUI.Main.UI.BG.{i}", $"ButtonMaxChanceMinus.{i}");
horisontal += 0.08f;
if (horisontal > 0.95) {
horisontal = starthorisontal;
vertical -= 0.15f;
}
count++;
i++;
CuiHelper.DestroyUi(player, $"zEcoLootUI.Main.UI.BG.{i}");
CuiHelper.AddUi(player, itemContainer);
yield return null;
}
if (count == 0) {
page--;
if (coroutine != null) ServerMgr.Instance.StopCoroutine(coroutine);
DrawCrateitem(player, prefab, page);
yield break;
}
if (page != 0) {
var continerBack = new CuiElementContainer();
continerBack.Add(new CuiButton() {
Button = {
Command = $"pages {prefab} {page - 1}", Color = "1 1 1 0.5"
}
, Text = {
Text = "Назад", Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = "0.02 0.02", AnchorMax = "0.02 0.02", OffsetMax = "60 30"
}
}
, "zEcoLootUI.Main.UI.BG", "ButtonBack");
CuiHelper.AddUi(player, continerBack);
}
if (count == 60) {
var continerNext = new CuiElementContainer();
continerNext.Add(new CuiButton() {
Button = {
Command = $"pages {prefab} {page + 1}", Color = "1 1 1 0.5"
}
, Text = {
Text = "Далее", Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = "0.98 0.02", AnchorMax = "0.98 0.02", OffsetMin = "-60 0", OffsetMax = "0 30"
}
}
, "zEcoLootUI.Main.UI.BG", "ButtonNext");
CuiHelper.AddUi(player, continerNext);
}
}
void RedrawItem(BasePlayer player, ItemSetting item, int i, string prefab, int page) {
CuiHelper.DestroyUi(player, "zEcoLootUI.Main.UI.Adding.BG");
CuiHelper.DestroyUi(player, $"zEcoLootUI.Main.UI.BG.{i}.textmin");
CuiHelper.DestroyUi(player, $"zEcoLootUI.Main.UI.BG.{i}.IsBP");
CuiHelper.DestroyUi(player, $"zEcoLootUI.Main.UI.BG.{i}.textmax");
CuiHelper.DestroyUi(player, $"zEcoLootUI.Main.UI.BG.{i}.condition.BG");
CuiHelper.DestroyUi(player, $"zEcoLootUI.Main.UI.BG.{i}.Btn_Condition");
CuiHelper.DestroyUi(player, $"ButtonMinMinus.{i}");
CuiHelper.DestroyUi(player, $"ButtonMaxMinus.{i}");
CuiHelper.DestroyUi(player, $"zEcoLootUI.Main.UI.BG.{i}.textchance");
CuiHelper.DestroyUi(player, $"ButtonMaxChancePlus.{i}");
CuiHelper.DestroyUi(player, $"ButtonMaxChanceMinus.{i}");
CuiHelper.DestroyUi(player, $"ButtonMinBP.{i}");
var container = new CuiElementContainer();
if (item.IsBp) container.Add(new CuiElement() {
Parent = $"zEcoLootUI.Main.UI.BG.{i}", Name = $"zEcoLootUI.Main.UI.BG.{i}.IsBP", Components = {
new CuiRawImageComponent {
Png = GetItemImage("blueprintbase")
}
, new CuiRectTransformComponent {
AnchorMin = "0 1", AnchorMax = "0 1", OffsetMin = "0 -20", OffsetMax = "20 0"
}
}
}
);
else {
if (item.HasCondition) {
container.Add(new CuiElement() {
Parent = $"zEcoLootUI.Main.UI.BG.{i}", Name = $"zEcoLootUI.Main.UI.BG.{i}.condition.BG", Components = {
new CuiImageComponent {
Color = "1 1 1 0.5"
}
, new CuiRectTransformComponent {
AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "1 1", OffsetMax = "5 62"
}
}
}
);
var cond = 62 * item.Condition / 100f;
container.Add(new CuiElement() {
Parent = $"zEcoLootUI.Main.UI.BG.{i}.condition.BG", Name = $"zEcoLootUI.Main.UI.BG.{i}.condition", Components = {
new CuiImageComponent {
Color = "0 0.5 0 1"
}
, new CuiRectTransformComponent {
AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "0 0", OffsetMax = $"4 {cond}"
}
}
}
);
container.Add(new CuiElement() {
Parent = $"zEcoLootUI.Main.UI.BG.{i}", Name = $"zEcoLootUI.Main.UI.BG.{i}.Btn_Condition", Components = {
new CuiButtonComponent {
Color = "1 1 1 0.3", Command = $"condition {prefab} {page} {i}"
}
, new CuiRectTransformComponent {
AnchorMin = "0 1", AnchorMax = "0 1", OffsetMin = "1 -11", OffsetMax = "25 -1"
}
}
}
);
container.Add(new CuiElement() {
Parent = $"zEcoLootUI.Main.UI.BG.{i}.Btn_Condition", Name = $"zEcoLootUI.Main.UI.BG.{i}.Btn_Condition.Txt", Components = {
new CuiTextComponent {
Text = "cond", Align = TextAnchor.MiddleCenter, FontSize = 9, Color = "1 1 1 1"
}
, new CuiRectTransformComponent {
AnchorMin = "0 0", AnchorMax = "1 1"
}
}
}
);
}
}
container.Add(new CuiButton() {
Button = {
Command = $"BPChange {prefab} {page} {i}", Color = "1 1 1 0.3"
}
, Text = {
Text = "BP", Align = TextAnchor.MiddleCenter, FontSize = 8
}
, RectTransform = {
AnchorMin = $"0.5 0", AnchorMax = $"0.5 0", OffsetMin = $"45 41", OffsetMax = $"66 50",
}
}
, $"zEcoLootUI.Main.UI.BG.{i}", $"ButtonMinBP.{i}");
container.Add(new CuiElement() {
Parent = $"zEcoLootUI.Main.UI.BG.{i}", Name = $"zEcoLootUI.Main.UI.BG.{i}.textmin", Components = {
new CuiTextComponent {
Text = $"min - {item.minamount}" , Align = TextAnchor.MiddleRight, FontSize = 9
}
, //new CuiOutlineComponent{Color = "0 0 0 1", Distance = "-1 1"},
new CuiRectTransformComponent {
AnchorMin = $"0.5 0", AnchorMax = $"0.5 0", OffsetMin = $"-42 15", OffsetMax = $"42 35",
}
}
}
);
container.Add(new CuiButton() {
Button = {
Command = $"editfeil {prefab} {page} {i} minminus", Color = "1 1 1 0.3"
}
, Text = {
Text = "edit", Align = TextAnchor.MiddleCenter, FontSize = 8
}
, RectTransform = {
AnchorMin = $"0.5 0", AnchorMax = $"0.5 0", OffsetMin = $"45 21", OffsetMax = $"66 30",
}
}
, $"zEcoLootUI.Main.UI.BG.{i}", $"ButtonMinMinus.{i}");
container.Add(new CuiElement() {
Parent = $"zEcoLootUI.Main.UI.BG.{i}", Name = $"zEcoLootUI.Main.UI.BG.{i}.textmax", Components = {
new CuiTextComponent {
Text = $"max - {item.maxamount}" , Align = TextAnchor.MiddleRight, FontSize = 9
}
, //new CuiOutlineComponent{Color = "0 0 0 1", Distance = "-1 1"},
new CuiRectTransformComponent {
AnchorMin = $"0.5 0", AnchorMax = $"0.5 0", OffsetMin = $"-42 5", OffsetMax = $"42 25",
}
}
}
);
container.Add(new CuiButton() {
Button = {
Command = $"editfeil {prefab} {page} {i} maxminus", Color = "1 1 1 0.3"
}
, Text = {
Text = "edit", Align = TextAnchor.MiddleCenter, FontSize = 8
}
, RectTransform = {
AnchorMin = $"0.5 0", AnchorMax = $"0.5 0", OffsetMin = $"45 10", OffsetMax = $"66 19",
}
}
, $"zEcoLootUI.Main.UI.BG.{i}", $"ButtonMaxMinus.{i}");
container.Add(new CuiElement() {
Parent = $"zEcoLootUI.Main.UI.BG.{i}", Name = $"zEcoLootUI.Main.UI.BG.{i}.textchance", Components = {
new CuiTextComponent {
Text = $"chance - {item.chansedrop}%" , Align = TextAnchor.MiddleRight, FontSize = 9
}
, //new CuiOutlineComponent{Color = "0 0 0 1", Distance = "-1 1"},
new CuiRectTransformComponent {
AnchorMin = $"0.5 0", AnchorMax = $"0.5 0", OffsetMin = $"-{32+10} -10", OffsetMax = $"{32+10} 15",
}
}
}
);
container.Add(new CuiButton() {
Button = {
Command = $"editfeil {prefab} {page} {i} chanceminus", Color = "1 1 1 0.3"
}
, Text = {
Text = "edit", Align = TextAnchor.MiddleCenter, FontSize = 8
}
, RectTransform = {
AnchorMin = $"0.5 0", AnchorMax = $"0.5 0", OffsetMin = $"45 -1", OffsetMax = $"66 8",
}
}
, $"zEcoLootUI.Main.UI.BG.{i}", $"ButtonMaxChanceMinus.{i}");
CuiHelper.AddUi(player, container);
}
[ConsoleCommand("hidelootimage")]
void HideImage(ConsoleSystem.Arg arg) {
var player = arg.Player();
var prefab = arg.Args[0];
if (visionImage.ContainsKey(player)) visionImage[player] = !visionImage[player];
else visionImage.Add(player, false);
DrawPanel(player, prefab);
}
[ConsoleCommand("chanceminus")]
void chanceminus(ConsoleSystem.Arg arg) {
var player = arg.Player();
var prefab = arg.Args[0];
List<ItemSetting> itemlist = Interface.Oxide.DataFileSystem.ReadObject<List<ItemSetting>>($"zEcoLootUI/{containerNames[prefab]}");
var page = arg.GetInt(1);
var index = arg.GetInt(2);
int amount = 0;
if (int.TryParse(arg.Args[3], out amount)) itemlist[index].chansedrop = amount;
if (amount > 100) amount = 100;
if (amount < 100) amount = 0;
Interface.Oxide.DataFileSystem.WriteObject($"zEcoLootUI/{containerNames[prefab]}", itemlist);
RedrawItem(player, itemlist[index], index, prefab, page);
}
[ConsoleCommand("minplus")]
void minplus(ConsoleSystem.Arg arg) {
var player = arg.Player();
List<ItemSetting> itemlist = Interface.Oxide.DataFileSystem.ReadObject<List<ItemSetting>>($"zEcoLootUI/{containerNames[arg.Args[0]]}");
var page = arg.GetInt(1);
var index = arg.GetInt(2);
var prefab = arg.Args[0];
itemlist[index].minamount++;
if (itemlist[index].minamount > itemlist[index].maxamount) itemlist[index].maxamount = itemlist[index].minamount;
Interface.Oxide.DataFileSystem.WriteObject($"zEcoLootUI/{containerNames[prefab]}", itemlist);
RedrawItem(player, itemlist[index], index, arg.Args[0], page);
}
[ConsoleCommand("BPChange")]
void BPChange(ConsoleSystem.Arg arg) {
var player = arg.Player();
List<ItemSetting> itemlist = Interface.Oxide.DataFileSystem.ReadObject<List<ItemSetting>>($"zEcoLootUI/{containerNames[arg.Args[0]]}");
var page = arg.GetInt(1);
var index = arg.GetInt(2);
var prefab = arg.Args[0];
itemlist[index].IsBp = !itemlist[index].IsBp;
Interface.Oxide.DataFileSystem.WriteObject($"zEcoLootUI/{containerNames[prefab]}", itemlist);
RedrawItem(player, itemlist[index], index, arg.Args[0], page);
}
[ConsoleCommand("minminus")]
void minminus(ConsoleSystem.Arg arg) {
var player = arg.Player();
List<ItemSetting> itemlist = Interface.Oxide.DataFileSystem.ReadObject<List<ItemSetting>>($"zEcoLootUI/{containerNames[arg.Args[0]]}");
var page = arg.GetInt(1);
var index = arg.GetInt(2);
int amount = arg.GetInt(3);
itemlist[index].minamount = amount;
if (itemlist[index].minamount > itemlist[index].maxamount) itemlist[index].maxamount = itemlist[index].minamount;
if (itemlist[index].minamount < 1) itemlist[index].minamount = 1;
Interface.Oxide.DataFileSystem.WriteObject($"zEcoLootUI/{containerNames[arg.Args[0]]}", itemlist);
RedrawItem(player, itemlist[index], index, arg.Args[0], page);
}
void EditCondition(BasePlayer player, string prefab, int page, int index) {
CuiHelper.DestroyUi(player, "zEcoLootUI.Main.UI.Adding.BG");
var container = new CuiElementContainer();
container.Add(new CuiElement() {
Parent = "zEcoLootUI.Main.UI", Name = "zEcoLootUI.Main.UI.Adding.BG", Components = {
new CuiButtonComponent {
Close = "zEcoLootUI.Main.UI.Adding.BG", Color = "0 0 0 0.8", Sprite = "assets/content/ui/ui.background.transparent.radial.psd", Material = "assets/content/ui/uibackgroundblur.mat"
}
, new CuiRectTransformComponent {
AnchorMin = "0 0", AnchorMax = "1 1",
}
}
}
);
container.Add(new CuiElement() {
Parent = "zEcoLootUI.Main.UI.Adding.BG", Name = "MinAmountUnput.Panel", Components = {
new CuiImageComponent {
Color = "0 0 0 0.8"
}
, new CuiRectTransformComponent {
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "-250 -100", OffsetMax = "250 100",
}
}
}
);
container.Add(new CuiElement() {
Parent = "MinAmountUnput.Panel", Name = "MinAmountUnput.Panel.HeaderTxT", Components = {
new CuiTextComponent {
Text = $"ВВЕДИТЕ ПРОЧНОСТЬ B %", Align = TextAnchor.MiddleCenter, FontSize = 18
}
, new CuiRectTransformComponent {
AnchorMin = "0.5 0.85", AnchorMax = "0.5 0.85", OffsetMin = "-250 -50", OffsetMax = "250 50",
}
}
}
);
container.Add(new CuiElement() {
Parent = "MinAmountUnput.Panel", Name = "MinAmountUnput.BG", Components = {
new CuiImageComponent {
Color = "1 1 1 0.4"
}
, new CuiRectTransformComponent {
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "-150 -25", OffsetMax = "150 25",
}
}
}
);
container.Add(new CuiElement() {
Parent = "MinAmountUnput.BG", Name = "MinAmountUnput", Components = {
new CuiInputFieldComponent {
Color = "0 0 0 1", FontSize = 22, Command = $"conditionvalue {prefab} {page} {index}", Align = TextAnchor.MiddleLeft
}
, new CuiRectTransformComponent {
AnchorMin = "0.01 0", AnchorMax = "0.99 1",
}
}
}
);
CuiHelper.AddUi(player, container);
}
void EditField(BasePlayer player, string cmd, string prefab, int page, int index) {
CuiHelper.DestroyUi(player, "zEcoLootUI.Main.UI.Adding.BG");
var container = new CuiElementContainer();
container.Add(new CuiElement() {
Parent = "zEcoLootUI.Main.UI", Name = "zEcoLootUI.Main.UI.Adding.BG", Components = {
new CuiButtonComponent {
Close = "zEcoLootUI.Main.UI.Adding.BG", Color = "0 0 0 0.8", Sprite = "assets/content/ui/ui.background.transparent.radial.psd", Material = "assets/content/ui/uibackgroundblur.mat"
}
, new CuiRectTransformComponent {
AnchorMin = "0 0", AnchorMax = "1 1",
}
}
}
);
container.Add(new CuiElement() {
Parent = "zEcoLootUI.Main.UI.Adding.BG", Name = "MinAmountUnput.Panel", Components = {
new CuiImageComponent {
Color = "0 0 0 0.8"
}
, new CuiRectTransformComponent {
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "-250 -100", OffsetMax = "250 100",
}
}
}
);
container.Add(new CuiElement() {
Parent = "MinAmountUnput.Panel", Name = "MinAmountUnput.Panel.HeaderTxT", Components = {
new CuiTextComponent {
Text = $"ВВЕДИТЕ КОЛИЧЕСТВО", Align = TextAnchor.MiddleCenter, FontSize = 18
}
, new CuiRectTransformComponent {
AnchorMin = "0.5 0.85", AnchorMax = "0.5 0.85", OffsetMin = "-250 -50", OffsetMax = "250 50",
}
}
}
);
// ... [Code preview truncated due to length. Full source in attached file] ...