using Oxide.Core;
using Oxide.Plugins;
using Oxide.Core.Plugins;
using Oxide.Core.Libraries;
using Oxide.Core.Libraries.Covalence;
using Oxide.Game.Rust.Cui;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using Rust;
using System;
namespace Oxide.Plugins
{
[Info("FoxMenu", "Bratura", "1.0.0")]
[Description("Простой плагин для меню в Rust")]
public class FoxMenu : RustPlugin
{
private const string menuPanel = "MenuPanel";
private const string menuAnchorMin = "0 1";
private const string menuAnchorMax = "0 1";
private const string menuOffsetMin = "0 0";
private const string menuOffsetMax = "0 0";
private const string menuColor = "1 0.5 0 0.8";
private const string menuText = "Меню открыто.";
private const string menuTextColor = "1 1 1 1";
private const int menuFontSize = 14;
private const string square2Panel = "Square2Panel";
private const string square2AnchorMin = "1 1";
private const string square2AnchorMax = "1 1";
private const string square2OffsetMin = "10 -110";
private const string square2OffsetMax = "110 -10";
private const string square2Color = "0.5 0.5 0.5 1";
private const string square3Panel = "Square3Panel";
private const string square3AnchorMin = "1 0";
private const string square3AnchorMax = "1 1";
private const string square3OffsetMin = "120 -120";
private const string square3OffsetMax = "350 -10";
private const string square3Color = "1 0.5 0.5 1";
private const string square4Panel = "Square4Panel";
private const string square4AnchorMin = "0.35 0.35";
private const string square4AnchorMax = "0.65 0.65";
private const string square4OffsetMin = "400 -500";
private const string square4OffsetMax = "1100 0";
private const string square4Color = "0.5 0.5 0.5 0.5";
private const string square5Panel = "Square5Panel";
private const string square5AnchorMin = "0.35 0.35";
private const string square5AnchorMax = "0.65 0.65";
private const string square5OffsetMin = "120 -150";
private const string square5OffsetMax = "350 -120";
private const string square5Color = "0.5 0.5 0.5 0.5";
private const string square5Text = "Крафты";
private const string square5TextColor = "1 1 1 1";
private const int square5FontSize = 14;
private const string craftgearPanel = "craftgear";
private const string craftgearAnchorMin = "0.35 0.35";
private const string craftgearAnchorMax = "0.65 0.65";
private const string craftgearOffsetMin = "400 -136";
private const string craftgearOffsetMax = "508 -114";
private const string craftgearColor = "0.5 0.5 0.5 0.5";
private const string craftgearText = "C r a f t";
private const string craftgearTextColor = "1 1 1 1";
private const int craftgearFontSize = 14;
private const string craftgenPanel = "craftgen";
private const string craftgenAnchorMin = "0.35 0.35";
private const string craftgenAnchorMax = "0.65 0.65";
private const string craftgenOffsetMin = "550 -136";
private const string craftgenOffsetMax = "657 -114";
private const string craftgenColor = "0.5 0.5 0.5 0.5";
private const string craftgenText = "C r a f t";
private const string craftgenTextColor = "1 1 1 1";
private const int craftgenFontSize = 14;
private const string craftboltPanel = "craftbolt";
private const string craftboltAnchorMin = "0.35 0.35";
private const string craftboltAnchorMax = "0.65 0.65";
private const string craftboltOffsetMin = "700 -136";
private const string craftboltOffsetMax = "807 -114";
private const string craftboltColor = "0.5 0.5 0.5 0.5";
private const string craftboltText = "C r a f t";
private const string craftboltTextColor = "1 1 1 1";
private const int craftboltFontSize = 14;
private const string craftcolenoPanel = "craftcoleno";
private const string craftcolenoAnchorMin = "0.35 0.35";
private const string craftcolenoAnchorMax = "0.65 0.65";
private const string craftcolenoOffsetMin = "850 -136";
private const string craftcolenoOffsetMax = "957 -114";
private const string craftcolenoColor = "0.5 0.5 0.5 0.5";
private const string craftcolenoText = "C r a f t";
private const string craftcolenoTextColor = "1 1 1 1";
private const int craftcolenoFontSize = 14;
private const string craftburPanel = "craftbur";
private const string craftburAnchorMin = "0.35 0.35";
private const string craftburAnchorMax = "0.65 0.65";
private const string craftburOffsetMin = "1000 -136";
private const string craftburOffsetMax = "1107 -114";
private const string craftburColor = "0.5 0.5 0.5 0.5";
private const string craftburText = "C r a f t";
private const string craftburTextColor = "1 1 1 1";
private const int craftburFontSize = 14;
private const string craftburplusPanel = "craftburplus";
private const string craftburplusAnchorMin = "0.35 0.35";
private const string craftburplusAnchorMax = "0.65 0.65";
private const string craftburplusOffsetMin = "400 -356";
private const string craftburplusOffsetMax = "508 -334";
private const string craftburplusColor = "0.5 0.5 0.5 0.5";
private const string craftburplusText = "C r a f t";
private const string craftburplusTextColor = "1 1 1 1";
private const int craftburplusFontSize = 14;
private const string craftburplussPanel = "craftburpluss";
private const string craftburplussAnchorMin = "0.35 0.35";
private const string craftburplussAnchorMax = "0.65 0.65";
private const string craftburplussOffsetMin = "550 -356";
private const string craftburplussOffsetMax = "657 -334";
private const string craftburplussColor = "0.5 0.5 0.5 0.5";
private const string craftburplussText = "C r a f t";
private const string craftburplussTextColor = "1 1 1 1";
private const int craftburplussFontSize = 14;
private const string resurseboxPanel = "resursebox";
private const string resurseboxAnchorMin = "0.35 0.35";
private const string resurseboxAnchorMax = "0.65 0.65";
private const string resurseboxOffsetMin = "850 -356";
private const string resurseboxOffsetMax = "957 -334";
private const string resurseboxColor = "0.5 0.5 0.5 0.5";
private const string resurseboxText = "C r a f t";
private const string resurseboxTextColor = "1 1 1 1";
private const int resurseboxFontSize = 14;
[PluginReference]
private Plugin BoxPlugin;
private Dictionary<ulong, CuiElement> activeMenus = new Dictionary<ulong, CuiElement>();
private void OpenMenu(BasePlayer player)
{
if (activeMenus.ContainsKey(player.userID))
{
ShowMessage(player, "Меню уже открыто.");
return;
}
var menuRect = new CuiElement
{
Name = menuPanel,
Parent = "Overlay",
FadeOut = 0.5f
};
var rectTransformComponent = new CuiRectTransformComponent
{
AnchorMin = menuAnchorMin,
AnchorMax = menuAnchorMax,
OffsetMin = menuOffsetMin,
OffsetMax = menuOffsetMax
};
var imageComponent = new CuiImageComponent
{
Color = menuColor
};
menuRect.Components.Add(rectTransformComponent);
menuRect.Components.Add(imageComponent);
var elements = new List<CuiElement> { menuRect };
CuiHelper.AddUi(player, elements);
activeMenus[player.userID] = menuRect;
ShowMessage(player, menuText);
CreateSquare2(player);
CreateSquare3(player);
CreateSquare5(player);
}
private void CreateSquare2(BasePlayer player)
{
var square2Rect = new CuiElement
{
Name = square2Panel,
Parent = "MenuPanel",
FadeOut = 0.5f
};
var rectTransformComponent = new CuiRectTransformComponent
{
AnchorMin = "0.25 0.25",
AnchorMax = "0.75 0.75",
OffsetMin = square2OffsetMin,
OffsetMax = square2OffsetMax
};
var imageComponent = new CuiRawImageComponent
{
Url = "https://cdn.discordapp.com/attachments/924019743936086086/1115690135334428682/ebc3789f87214daf.png",
Sprite = "assets/content/textures/generic/fulltransparent.tga"
};
square2Rect.Components.Add(rectTransformComponent);
square2Rect.Components.Add(imageComponent);
CuiHelper.AddUi(player, new List<CuiElement> { square2Rect });
}
private void CreateSquare3(BasePlayer player)
{
var square3Rect = new CuiElement
{
Name = square3Panel,
Parent = "MenuPanel",
FadeOut = 0.5f
};
var rectTransformComponent = new CuiRectTransformComponent
{
AnchorMin = square3AnchorMin,
AnchorMax = square3AnchorMax,
OffsetMin = square3OffsetMin,
OffsetMax = square3OffsetMax
};
var imageComponent = new CuiRawImageComponent
{
Url = "https://cdn.discordapp.com/attachments/1112413941180665877/1148579630794678373/image.png",
Sprite = "assets/content/textures/generic/fulltransparent.tga"
};
square3Rect.Components.Add(rectTransformComponent);
square3Rect.Components.Add(imageComponent);
CuiHelper.AddUi(player, new List<CuiElement> { square3Rect });
}
private void CreateSquare4(BasePlayer player)
{
var square4Rect = new CuiElement
{
Name = square4Panel,
Parent = "MenuPanel",
FadeOut = 0.5f
};
var rectTransformComponent = new CuiRectTransformComponent
{
AnchorMin = square4AnchorMin,
AnchorMax = square4AnchorMax,
OffsetMin = square4OffsetMin,
OffsetMax = square4OffsetMax
};
var imageComponent = new CuiRawImageComponent
{
Url = "https://cdn.discordapp.com/attachments/1112413941180665877/1148586592815026236/image.png",
Sprite = "assets/content/textures/generic/fulltransparent.tga"
};
square4Rect.Components.Add(rectTransformComponent);
square4Rect.Components.Add(imageComponent);
CuiHelper.AddUi(player, new List<CuiElement> { square4Rect });
}
private void CreateSquare5(BasePlayer player)
{
var square5Rect = new CuiElement
{
Name = square5Panel,
Parent = "MenuPanel",
FadeOut = 0.5f
};
var rectTransformComponent = new CuiRectTransformComponent
{
AnchorMin = square5AnchorMin,
AnchorMax = square5AnchorMax,
OffsetMin = square5OffsetMin,
OffsetMax = square5OffsetMax
};
var buttonComponent = new CuiButtonComponent
{
Command = $"openSquare4 {player.userID}"
};
square5Rect.Components.Add(rectTransformComponent);
square5Rect.Components.Add(buttonComponent);
var textElement = new CuiElement
{
Name = "TextElement",
Parent = square5Panel,
Components = {
new CuiTextComponent {
Text = square5Text,
FontSize = square5FontSize,
Align = TextAnchor.MiddleCenter,
Color = square5TextColor
}
}
};
var buttonColor = new CuiElement
{
Name = "ButtonColor",
Parent = square5Panel,
Components = {
new CuiImageComponent { Color = square5Color }
}
};
var elements = new CuiElementContainer();
elements.Add(square5Rect);
elements.Add(buttonColor);
elements.Add(textElement);
CuiHelper.AddUi(player, elements);
}
[ConsoleCommand("openSquare4")]
private void ConsoleCmdOpenSquare4(ConsoleSystem.Arg arg)
{
var player = arg.Player();
if (player == null)
return;
CreateSquare4(player);
craftgear(player);
craftgen(player);
craftbolt(player);
craftbur(player);
craftburplus(player);
craftburpluss(player);
craftcoleno(player);
resursebox(player);
}
private void craftgear(BasePlayer player)
{
var craftgearRect = new CuiElement
{
Name = craftgearPanel,
Parent = "MenuPanel",
FadeOut = 0.5f
};
var rectTransformComponent = new CuiRectTransformComponent
{
AnchorMin = craftgearAnchorMin,
AnchorMax = craftgearAnchorMax,
OffsetMin = craftgearOffsetMin,
OffsetMax = craftgearOffsetMax
};
var buttonComponent = new CuiButtonComponent
{
Command = "craftgear.craft"
};
craftgearRect.Components.Add(rectTransformComponent);
craftgearRect.Components.Add(buttonComponent);
var textElement = new CuiElement
{
Name = "TextElement",
Parent = craftgearPanel,
Components = {
new CuiTextComponent {
Text = craftgearText,
FontSize = craftgearFontSize,
Align = TextAnchor.MiddleCenter,
Color = craftgearTextColor
}
}
};
var buttonColor = new CuiElement
{
Name = "ButtonColor",
Parent = craftgearPanel,
Components = {
new CuiImageComponent { Color = craftgearColor }
}
};
var elements = new CuiElementContainer();
elements.Add(craftgearRect);
elements.Add(buttonColor);
elements.Add(textElement);
CuiHelper.AddUi(player, elements);
}
private void craftgen(BasePlayer player)
{
var craftgenRect = new CuiElement
{
Name = craftgenPanel,
Parent = "MenuPanel",
FadeOut = 0.5f
};
var rectTransformComponent = new CuiRectTransformComponent
{
AnchorMin = craftgenAnchorMin,
AnchorMax = craftgenAnchorMax,
OffsetMin = craftgenOffsetMin,
OffsetMax = craftgenOffsetMax
};
var buttonComponent = new CuiButtonComponent
{
Command = "craftgen.craft"
};
craftgenRect.Components.Add(rectTransformComponent);
craftgenRect.Components.Add(buttonComponent);
var textElement = new CuiElement
{
Name = "TextElement",
Parent = craftgenPanel,
Components = {
new CuiTextComponent {
Text = craftgenText,
FontSize = craftgenFontSize,
Align = TextAnchor.MiddleCenter,
Color = craftgenTextColor
}
}
};
var buttonColor = new CuiElement
{
Name = "ButtonColor",
Parent = craftgenPanel,
Components = {
new CuiImageComponent { Color = craftgenColor }
}
};
var elements = new CuiElementContainer();
elements.Add(craftgenRect);
elements.Add(buttonColor);
elements.Add(textElement);
CuiHelper.AddUi(player, elements);
}
private void craftbolt(BasePlayer player)
{
var craftboltRect = new CuiElement
{
Name = craftboltPanel,
Parent = "MenuPanel",
FadeOut = 0.5f
};
var rectTransformComponent = new CuiRectTransformComponent
{
AnchorMin = craftboltAnchorMin,
AnchorMax = craftboltAnchorMax,
OffsetMin = craftboltOffsetMin,
OffsetMax = craftboltOffsetMax
};
var buttonComponent = new CuiButtonComponent
{
Command = "craftbolt.craft"
};
craftboltRect.Components.Add(rectTransformComponent);
craftboltRect.Components.Add(buttonComponent);
var textElement = new CuiElement
{
Name = "TextElement",
Parent = craftboltPanel,
Components = {
new CuiTextComponent {
Text = craftboltText,
FontSize = craftboltFontSize,
Align = TextAnchor.MiddleCenter,
Color = craftboltTextColor
}
}
};
var buttonColor = new CuiElement
{
Name = "ButtonColor",
Parent = craftboltPanel,
Components = {
new CuiImageComponent { Color = craftboltColor }
}
};
var elements = new CuiElementContainer();
elements.Add(craftboltRect);
elements.Add(buttonColor);
elements.Add(textElement);
CuiHelper.AddUi(player, elements);
}
private void craftcoleno(BasePlayer player)
{
var craftcolenoRect = new CuiElement
{
Name = craftcolenoPanel,
Parent = "MenuPanel",
FadeOut = 0.5f
};
var rectTransformComponent = new CuiRectTransformComponent
{
AnchorMin = craftcolenoAnchorMin,
AnchorMax = craftcolenoAnchorMax,
OffsetMin = craftcolenoOffsetMin,
OffsetMax = craftcolenoOffsetMax
};
var buttonComponent = new CuiButtonComponent
{
Command = "craftcoleno.craft"
};
craftcolenoRect.Components.Add(rectTransformComponent);
craftcolenoRect.Components.Add(buttonComponent);
var textElement = new CuiElement
{
Name = "TextElement",
Parent = craftcolenoPanel,
Components = {
new CuiTextComponent {
Text = craftcolenoText,
FontSize = craftcolenoFontSize,
Align = TextAnchor.MiddleCenter,
Color = craftcolenoTextColor
}
}
};
var buttonColor = new CuiElement
{
Name = "ButtonColor",
Parent = craftcolenoPanel,
Components = {
new CuiImageComponent { Color = craftcolenoColor }
}
};
var elements = new CuiElementContainer();
elements.Add(craftcolenoRect);
elements.Add(buttonColor);
elements.Add(textElement);
CuiHelper.AddUi(player, elements);
}
private void craftbur(BasePlayer player)
{
var craftburRect = new CuiElement
{
Name = craftburPanel,
Parent = "MenuPanel",
FadeOut = 0.5f
};
var rectTransformComponent = new CuiRectTransformComponent
{
AnchorMin = craftburAnchorMin,
AnchorMax = craftburAnchorMax,
OffsetMin = craftburOffsetMin,
OffsetMax = craftburOffsetMax
};
var buttonComponent = new CuiButtonComponent
{
Command = "craftbur.craft"
};
craftburRect.Components.Add(rectTransformComponent);
craftburRect.Components.Add(buttonComponent);
var textElement = new CuiElement
{
Name = "TextElement",
Parent = craftburPanel,
Components = {
new CuiTextComponent {
Text = craftburText,
FontSize = craftburFontSize,
Align = TextAnchor.MiddleCenter,
Color = craftburTextColor
}
}
};
var buttonColor = new CuiElement
{
Name = "ButtonColor",
Parent = craftburPanel,
Components = {
new CuiImageComponent { Color = craftburColor }
}
};
var elements = new CuiElementContainer();
elements.Add(craftburRect);
elements.Add(buttonColor);
elements.Add(textElement);
CuiHelper.AddUi(player, elements);
}
private void craftburplus(BasePlayer player)
{
var craftburplusRect = new CuiElement
{
Name = craftburplusPanel,
Parent = "MenuPanel",
FadeOut = 0.5f
};
var rectTransformComponent = new CuiRectTransformComponent
{
AnchorMin = craftburplusAnchorMin,
AnchorMax = craftburplusAnchorMax,
OffsetMin = craftburplusOffsetMin,
OffsetMax = craftburplusOffsetMax
};
var buttonComponent = new CuiButtonComponent
{
Command = "craftburplus.craft"
};
craftburplusRect.Components.Add(rectTransformComponent);
craftburplusRect.Components.Add(buttonComponent);
var textElement = new CuiElement
{
Name = "TextElement",
Parent = craftburplusPanel,
Components = {
new CuiTextComponent {
Text = craftburplusText,
FontSize = craftburplusFontSize,
Align = TextAnchor.MiddleCenter,
Color = craftburplusTextColor
}
}
};
var buttonColor = new CuiElement
{
Name = "ButtonColor",
Parent = craftburplusPanel,
Components = {
new CuiImageComponent { Color = craftburplusColor }
}
};
var elements = new CuiElementContainer();
elements.Add(craftburplusRect);
elements.Add(buttonColor);
elements.Add(textElement);
CuiHelper.AddUi(player, elements);
}
private void craftburpluss(BasePlayer player)
{
var craftburplussRect = new CuiElement
{
Name = craftburplussPanel,
Parent = "MenuPanel",
FadeOut = 0.5f
};
var rectTransformComponent = new CuiRectTransformComponent
{
AnchorMin = craftburplussAnchorMin,
AnchorMax = craftburplussAnchorMax,
OffsetMin = craftburplussOffsetMin,
OffsetMax = craftburplussOffsetMax
};
var buttonComponent = new CuiButtonComponent
{
Command = "craftburpluss.craft"
};
craftburplussRect.Components.Add(rectTransformComponent);
craftburplussRect.Components.Add(buttonComponent);
var textElement = new CuiElement
{
Name = "TextElement",
Parent = craftburplussPanel,
Components =
{
new CuiTextComponent
{
Text = craftburplussText,
FontSize = craftburplussFontSize,
Align = TextAnchor.MiddleCenter,
Color = craftburplussTextColor
}
}
};
var buttonColor = new CuiElement
{
Name = "ButtonColor",
Parent = craftburplussPanel,
Components =
{
new CuiImageComponent { Color = craftburplussColor }
}
};
{
var elements = new CuiElementContainer();
elements.Add(craftburplussRect);
elements.Add(buttonColor);
elements.Add(textElement);
CuiHelper.AddUi(player, elements);
}
}
private void resursebox(BasePlayer player)
{
var resurseboxRect = new CuiElement
{
Name = resurseboxPanel,
Parent = "MenuPanel",
FadeOut = 0.5f
};
var rectTransformComponent = new CuiRectTransformComponent
{
AnchorMin = resurseboxAnchorMin,
AnchorMax = resurseboxAnchorMax,
OffsetMin = resurseboxOffsetMin,
OffsetMax = resurseboxOffsetMax
};
var buttonComponent = new CuiButtonComponent
{
Command = "resurseboxx.craft"
};
resurseboxRect.Components.Add(rectTransformComponent);
resurseboxRect.Components.Add(buttonComponent);
var textElement = new CuiElement
{
Name = "TextElement",
Parent = resurseboxPanel,
Components =
{
new CuiTextComponent
{
Text = resurseboxText,
FontSize = resurseboxFontSize,
Align = TextAnchor.MiddleCenter,
Color = resurseboxTextColor
}
}
};
var buttonColor = new CuiElement
{
Name = "ButtonColor",
Parent = resurseboxPanel,
Components =
{
new CuiImageComponent { Color = resurseboxColor }
}
};
{
var elements = new CuiElementContainer();
elements.Add(resurseboxRect);
elements.Add(buttonColor);
elements.Add(textElement);
CuiHelper.AddUi(player, elements);
}
}
private void GiveItemWithName(BasePlayer player, string shortname, string displayName, ulong skinId = 0, ulong amount = 1)
{
var itemDefinition = ItemManager.FindItemDefinition(shortname);
if (itemDefinition != null)
{
var item = ItemManager.Create(itemDefinition, (int)amount, skinId);
item.name = displayName; // Устанавливаем имя предмета
var heldEntity = item.GetHeldEntity();
if (heldEntity != null)
{
heldEntity.skinID = skinId;
}
item.MoveToContainer(player.inventory.containerMain);
player.GiveItem(item);
}
CloseMenu(player);
}
[ConsoleCommand("menu.close")]
private void CloseMenuCommand(ConsoleSystem.Arg arg)
{
var player = arg.Connection?.player as BasePlayer;
if (player == null) return;
CloseMenu(player);
ShowMessage(player, "Меню закрыто.");
}
[ConsoleCommand("craftgear.craft")]
private void Craftgear(ConsoleSystem.Arg arg)
{
var player = arg.Connection?.player as BasePlayer;
if (player == null) return;
ulong mvk_amount = 100;
string mvk_shortname = "metal.refined"; // Имя предмета МВК
ulong gears_amount = 10;
string gears_shortname = "gears"; // Имя предмета шестеренок
string battery_name = "appgear"; // Имя кастомного предмета
var mvk = ItemManager.FindItemDefinition(mvk_shortname);
var gears = ItemManager.FindItemDefinition(gears_shortname);
if (mvk != null && gears != null)
{
ulong playerMvkAmount = (ulong)player.inventory.GetAmount(mvk.itemid);
ulong playerGearsAmount = (ulong)player.inventory.GetAmount(gears.itemid);
if (playerMvkAmount >= mvk_amount && playerGearsAmount >= gears_amount)
{
// Выполняем крафт
player.inventory.Take(null, mvk.itemid, (int)mvk_amount);
player.inventory.Take(null, gears.itemid, (int)gears_amount);
// Создаем кастомный предмет с нужным именем
string custom_shortname = "sticks";
ulong skinid = 3033070179; // Укажите здесь реальный ID скина
GiveItemWithName(player, custom_shortname, battery_name, skinid);
// Закрываем меню после успешного крафта
CloseMenu(player);
ShowMessage(player, "Крафт успешен!");
}
else
{
ulong requiredMvk = mvk_amount - playerMvkAmount;
ulong requiredGears = gears_amount - playerGearsAmount;
ShowMessage(player, $"У вас не хватает {requiredMvk} МВК и {requiredGears} шестеренок для крафта.");
}
}
else
{
ShowMessage(player, "Один или оба предмета не найдены (МВК, шестеренки). Проверьте корректность имён предметов.");
}
}
[ConsoleCommand("craftgen.craft")]
private void Craftgen(ConsoleSystem.Arg arg)
{
var player = arg.Connection?.player as BasePlayer;
if (player == null) return;
ulong mvk_amount = 250;
string mvk_shortname = "metal.refined"; // Имя предмета МВК
ulong techparts_amount = 10;
string techparts_shortname = "techparts"; // Имя предмета микросхем
ulong batterylarge_amount = 1;
string batterylarge_shortname = "electric.battery.rechargable.large";
string battery_name = "appgen"; // Имя кастомного предмета
var mvk = ItemManager.FindItemDefinition(mvk_shortname);
var techparts = ItemManager.FindItemDefinition(techparts_shortname);
var batterylarge = ItemManager.FindItemDefinition(batterylarge_shortname);
if (mvk != null && techparts != null && batterylarge != null)
{
ulong playerMvkAmount = (ulong)player.inventory.GetAmount(mvk.itemid);
ulong playerTechpartsAmount = (ulong)player.inventory.GetAmount(techparts.itemid);
ulong playerBatterylargeAmount = (ulong)player.inventory.GetAmount(batterylarge.itemid);
if (playerMvkAmount >= mvk_amount && playerTechpartsAmount >= techparts_amount && playerBatterylargeAmount >= batterylarge_amount)
{
// Выполняем крафт
player.inventory.Take(null, mvk.itemid, (int)mvk_amount);
player.inventory.Take(null, techparts.itemid, (int)techparts_amount);
player.inventory.Take(null, batterylarge.itemid, (int)batterylarge_amount);
// Создаем кастомный предмет с нужным именем
string battery_shortname = "battery.small";
ulong skinid = 3033070172; // Укажите здесь реальный ID скина
GiveItemWithName(player, battery_shortname, battery_name, skinid);
// Закрываем меню после успешного крафта
CloseMenu(player);
ShowMessage(player, "Крафт успешен!");
}
else
{
ulong requiredMvk = mvk_amount - playerMvkAmount;
ulong requiredTechparts = techparts_amount - playerTechpartsAmount;
ulong requiredBatterylarge = batterylarge_amount - playerBatterylargeAmount;
ShowMessage(player, $"У вас не хватает {requiredMvk} МВК и {requiredTechparts} микросхем и {requiredBatterylarge} большой батарейки для крафта.");
}
}
else
{
ShowMessage(player, "Один или оба предмета не найдены (МВК, микросхемы, большой батарейки). Проверьте корректность имён предметов.");
}
}
[ConsoleCommand("craftbolt.craft")]
private void craftbolt(ConsoleSystem.Arg arg)
{
var player = arg.Connection?.player as BasePlayer;
if (player == null) return;
ulong mvk_amount = 30;
string mvk_shortname = "metal.refined"; // Имя предмета МВК
ulong gears_amount = 2;
string gears_shortname = "metalpipe"; // Имя предмета шестеренок
string battery_name = "appbolt"; // Имя кастомного предмета
var mvk = ItemManager.FindItemDefinition(mvk_shortname);
var gears = ItemManager.FindItemDefinition(gears_shortname);
if (mvk != null && gears != null)
{
ulong playerMvkAmount = (ulong)player.inventory.GetAmount(mvk.itemid);
ulong playerGearsAmount = (ulong)player.inventory.GetAmount(gears.itemid);
if (playerMvkAmount >= mvk_amount && playerGearsAmount >= gears_amount)
{
// Выполняем крафт
player.inventory.Take(null, mvk.itemid, (int)mvk_amount);
player.inventory.Take(null, gears.itemid, (int)gears_amount);
// Создаем кастомный предмет с нужным именем
string custom_shortname = "glue";
ulong skinid = 3033070170; // Укажите здесь реальный ID скина
GiveItemWithName(player, custom_shortname, battery_name, skinid);
// Закрываем меню после успешного крафта
CloseMenu(player);
ShowMessage(player, "Крафт успешен!");
}
else
{
ulong requiredMvk = mvk_amount - playerMvkAmount;
ulong requiredGears = gears_amount - playerGearsAmount;
ShowMessage(player, $"У вас не хватает {requiredMvk} МВК и {requiredGears} труб для крафта.");
}
}
else
{
ShowMessage(player, "Один или оба предмета не найдены (МВК, шестеренки). Проверьте корректность имён предметов.");
}
}
[ConsoleCommand("craftcoleno.craft")]
private void craftcoleno(ConsoleSystem.Arg arg)
{
var player = arg.Connection?.player as BasePlayer;
if (player == null) return;
ulong mvk_amount = 50;
string mvk_shortname = "metal.refined"; // Имя предмета МВК
ulong pipe_amount = 5;
string pipe_shortname = "metalpipe"; // Имя предмета шестеренок
ulong gears_amount = 4;
string gears_shortname = "gears"; // Имя предмета шестеренок
string battery_name = "appbolt"; // Имя кастомного предмета
var mvk = ItemManager.FindItemDefinition(mvk_shortname);
var gears = ItemManager.FindItemDefinition(gears_shortname);
var pipe = ItemManager.FindItemDefinition(pipe_shortname);
if (mvk != null && gears != null)
{
ulong playerMvkAmount = (ulong)player.inventory.GetAmount(mvk.itemid);
ulong playerGearsAmount = (ulong)player.inventory.GetAmount(gears.itemid);
ulong playerPipeAmount = (ulong)player.inventory.GetAmount(pipe.itemid);
if (playerMvkAmount >= mvk_amount && playerGearsAmount >= gears_amount && playerPipeAmount >= pipe_amount)
{
// Выполняем крафт
player.inventory.Take(null, mvk.itemid, (int)mvk_amount);
player.inventory.Take(null, gears.itemid, (int)gears_amount);
player.inventory.Take(null, pipe.itemid, (int)pipe_amount);
// Создаем кастомный предмет с нужным именем
string custom_shortname = "paper";
ulong skinid = 3033070172; // Укажите здесь реальный ID скина
GiveItemWithName(player, custom_shortname, battery_name, skinid);
// Закрываем меню после успешного крафта
CloseMenu(player);
ShowMessage(player, "Крафт успешен!");
}
else
{
ulong requiredMvk = mvk_amount - playerMvkAmount;
ulong requiredGears = gears_amount - playerGearsAmount;
ulong requiredPipe = pipe_amount - playerPipeAmount;
ShowMessage(player, $"У вас не хватает {requiredMvk} МВК и {requiredGears} труб для крафта.");
}
}
else
{
ShowMessage(player, "Один или оба предмета не найдены (МВК, шестеренки). Проверьте корректность имён предметов.");
}
}
private Dictionary<string, string> customItems = new Dictionary<string, string>
{
{ "appgear", "battery.small" },
{ "appbolt", "battery.small" },
{ "bur", "battery.small"},
{ "burplus", "battery.small"},
};
[ConsoleCommand("craftbur.craft")]
private void craftbur(ConsoleSystem.Arg arg)
{
var player = arg.Connection?.player as BasePlayer;
if (player == null) return;
ulong mvk_amount = 50;
string mvk_shortname = "metal.refined"; // Имя предмета МВК
ulong pipe_amount = 3;
string pipe_shortname = "sticks"; // Имя предмета шестеренок
ulong gears_amount = 4;
string gears_shortname = "glue"; // Имя предмета шестеренок
string battery_name = "bur"; // Имя кастомного предмета
var mvk_shortname_actual = GetActualItemShortName(mvk_shortname);
var pipe_shortname_actual = GetActualItemShortName(pipe_shortname);
var gears_shortname_actual = GetActualItemShortName(gears_shortname);
var mvk = ItemManager.FindItemDefinition(mvk_shortname_actual);
var pipe = ItemManager.FindItemDefinition(pipe_shortname_actual);
var gears = ItemManager.FindItemDefinition(gears_shortname_actual);
if (mvk != null && gears != null && pipe != null)
{
ulong playerMvkAmount = (ulong)player.inventory.GetAmount(mvk.itemid);
ulong playerGearsAmount = (ulong)player.inventory.GetAmount(pipe.itemid);
ulong playerPipeAmount = (ulong)player.inventory.GetAmount(gears.itemid);
if (playerMvkAmount >= mvk_amount && playerGearsAmount >= gears_amount && playerPipeAmount >= pipe_amount)
{
// Выполняем крафт
player.inventory.Take(null, mvk.itemid, (int)mvk_amount);
player.inventory.Take(null, pipe.itemid, (int)pipe_amount);
player.inventory.Take(null, gears.itemid, (int)gears_amount);
// Создаем кастомный предмет с нужным именем
string custom_shortname = "bleach";
ulong skinid = 3033070172; // Укажите здесь реальный ID скина
GiveItemWithName(player, custom_shortname, battery_name, skinid);
// Закрываем меню после успешного крафта
CloseMenu(player);
ShowMessage(player, "Крафт успешен!");
}
else
{
ulong requiredMvk = mvk_amount - playerMvkAmount;
ulong requiredGears = gears_amount - playerGearsAmount;
ulong requiredPipe = pipe_amount - playerPipeAmount;
ShowMessage(player, $"У вас не хватает {requiredMvk} МВК, {requiredGears} шестеренок и {requiredPipe} труб для крафта.");
}
}
else
{
ShowMessage(player, "Один или несколько предметов не найдены (МВК, шестеренки, трубы). Проверьте корректность имён предметов.");
}
}
private string GetActualItemShortName(string shortname)
{
if (customItems.ContainsKey(shortname))
{
return customItems[shortname];
}
return shortname;
}
[ConsoleCommand("craftburplus.craft")]
private void craftburplus(ConsoleSystem.Arg arg)
{
var player = arg.Connection?.player as BasePlayer;
if (player == null) return;
ulong mvk_amount = 60;
string mvk_shortname = "metal.refined"; // Имя предмета МВК
ulong pipe_amount = 3;
string pipe_shortname = "sticks"; // Имя предмета шестеренок
ulong gears_amount = 4;
string gears_shortname = "glue"; // Имя предмета шестеренок
ulong bur_amount = 1;
string bur_shortname = "bleach"; // Имя предмета шестеренок
string battery_name = "burplus"; // Имя кастомного предмета
var mvk_shortname_actual = GetActualItemShortName(mvk_shortname);
var pipe_shortname_actual = GetActualItemShortName(pipe_shortname);
var gears_shortname_actual = GetActualItemShortName(gears_shortname);
var bur_shortname_actual = GetActualItemShortName(bur_shortname);
var mvk = ItemManager.FindItemDefinition(mvk_shortname_actual);
var pipe = ItemManager.FindItemDefinition(pipe_shortname_actual);
var gears = ItemManager.FindItemDefinition(gears_shortname_actual);
var bur = ItemManager.FindItemDefinition(bur_shortname_actual);
if (mvk != null && gears != null && pipe != null && bur != null)
{
ulong playerMvkAmount = (ulong)player.inventory.GetAmount(mvk.itemid);
ulong playerGearsAmount = (ulong)player.inventory.GetAmount(pipe.itemid);
ulong playerPipeAmount = (ulong)player.inventory.GetAmount(gears.itemid);
ulong playerBurAmount = (ulong)player.inventory.GetAmount(bur.itemid);
if (playerMvkAmount >= mvk_amount && playerGearsAmount >= gears_amount && playerPipeAmount >= pipe_amount && playerBurAmount >= bur_amount)
{
// Выполняем крафт
player.inventory.Take(null, mvk.itemid, (int)mvk_amount);
player.inventory.Take(null, pipe.itemid, (int)pipe_amount);
player.inventory.Take(null, gears.itemid, (int)gears_amount);
player.inventory.Take(null, bur.itemid, (int)bur_amount);
// Создаем кастомный предмет с нужным именем
string custom_shortname = "blood";
ulong skinid = 3033070172; // Укажите здесь реальный ID скина
GiveItemWithName(player, custom_shortname, battery_name, skinid);
// Закрываем меню после успешного крафта
CloseMenu(player);
ShowMessage(player, "Крафт успешен!");
}
else
{
ulong requiredMvk = mvk_amount - playerMvkAmount;
ulong requiredGears = gears_amount - playerGearsAmount;
ulong requiredPipe = pipe_amount - playerPipeAmount;
ulong requiredBur = bur_amount - playerBurAmount;
ShowMessage(player, $"У вас не хватает {requiredMvk} МВК, {requiredGears} шестеренок, {requiredPipe} болтов и {requiredBur} для крафта.");
}
}
else
{
ShowMessage(player, "Один или несколько предметов не найдены (МВК, шестеренки, трубы). Проверьте корректность имён предметов.");
}
}
[ConsoleCommand("craftburpluss.craft")]
private void craftburpluss(ConsoleSystem.Arg arg)
{
var player = arg.Connection?.player as BasePlayer;
if (player == null) return;
ulong mvk_amount = 100;
string mvk_shortname = "metal.refined"; // Имя предмета МВК
ulong pipe_amount = 17;
string pipe_shortname = "sticks"; // Имя предмета шестеренок
ulong gears_amount = 12;
string gears_shortname = "glue"; // Имя предмета шестеренок
ulong burplus_amount = 1;
string burplus_shortname = "blood"; // Имя предмета шестеренок
string battery_name = "burpluss"; // Имя кастомного предмета
var mvk_shortname_actual = GetActualItemShortName(mvk_shortname);
var pipe_shortname_actual = GetActualItemShortName(pipe_shortname);
var gears_shortname_actual = GetActualItemShortName(gears_shortname);
var burplus_shortname_actual = GetActualItemShortName(burplus_shortname);
var mvk = ItemManager.FindItemDefinition(mvk_shortname_actual);
var pipe = ItemManager.FindItemDefinition(pipe_shortname_actual);
var gears = ItemManager.FindItemDefinition(gears_shortname_actual);
var burplus = ItemManager.FindItemDefinition(burplus_shortname_actual);
if (mvk != null && gears != null && pipe != null && burplus != null)
{
ulong playerMvkAmount = (ulong)player.inventory.GetAmount(mvk.itemid);
ulong playerGearsAmount = (ulong)player.inventory.GetAmount(pipe.itemid);
ulong playerPipeAmount = (ulong)player.inventory.GetAmount(gears.itemid);
ulong playerBurplusAmount = (ulong)player.inventory.GetAmount(burplus.itemid);
if (playerMvkAmount >= mvk_amount && playerGearsAmount >= gears_amount && playerPipeAmount >= pipe_amount && playerBurplusAmount >= burplus_amount)
{
// Выполняем крафт
player.inventory.Take(null, mvk.itemid, (int)mvk_amount);
player.inventory.Take(null, pipe.itemid, (int)pipe_amount);
player.inventory.Take(null, gears.itemid, (int)gears_amount);
player.inventory.Take(null, burplus.itemid, (int)burplus_amount);
// Создаем кастомный предмет с нужным именем
string customItem_shortname = "ducttape";
ulong skinid = 3033070172; // Укажите здесь реальный ID скина
GiveItemWithName(player, customItem_shortname, battery_name, skinid);
// Закрываем меню после успешного крафта
CloseMenu(player);
ShowMessage(player, "Крафт успешен!");
}
else
{
ulong requiredMvk = mvk_amount - playerMvkAmount;
ulong requiredGears = gears_amount - playerGearsAmount;
ulong requiredPipe = pipe_amount - playerPipeAmount;
ulong requiredBurplus = burplus_amount - playerBurplusAmount;
ShowMessage(player, $"У вас не хватает {requiredMvk} МВК, {requiredGears} шестеренок, {requiredPipe} болтов и {requiredBurplus} бура+ для крафта.");
}
}
else
{
ShowMessage(player, "Один или несколько предметов не найдены (МВК, шестеренки, трубы). Проверьте корректность имён предметов.");
}
}
[ConsoleCommand("resurseboxx.craft")]
private void resursebox(ConsoleSystem.Arg arg)
{
var player = arg.Connection?.player as BasePlayer;
if (player == null) return;
ulong mvk_amount = 100;
string mvk_shortname = "metal.refined"; // Имя предмета МВК
ulong pipe_amount = 17;
string pipe_shortname = "sticks"; // Имя предмета шестеренок
ulong gears_amount = 12;
string gears_shortname = "glue"; // Имя предмета шестеренок
ulong burplus_amount = 1;
string burplus_shortname = "blood"; // Имя предмета шестеренок
string battery_name = "burpluss"; // Имя кастомного предмета
var mvk_shortname_actual = GetActualItemShortName(mvk_shortname);
var pipe_shortname_actual = GetActualItemShortName(pipe_shortname);
var gears_shortname_actual = GetActualItemShortName(gears_shortname);
var burplus_shortname_actual = GetActualItemShortName(burplus_shortname);
var mvk = ItemManager.FindItemDefinition(mvk_shortname_actual);
var pipe = ItemManager.FindItemDefinition(pipe_shortname_actual);
var gears = ItemManager.FindItemDefinition(gears_shortname_actual);
var burplus = ItemManager.FindItemDefinition(burplus_shortname_actual);
if (mvk != null && gears != null && pipe != null && burplus != null)
{
ulong playerMvkAmount = (ulong)player.inventory.GetAmount(mvk.itemid);
ulong playerGearsAmount = (ulong)player.inventory.GetAmount(pipe.itemid);
ulong playerPipeAmount = (ulong)player.inventory.GetAmount(gears.itemid);
ulong playerBurplusAmount = (ulong)player.inventory.GetAmount(burplus.itemid);
if (playerMvkAmount >= mvk_amount && playerGearsAmount >= gears_amount && playerPipeAmount >= pipe_amount && playerBurplusAmount >= burplus_amount)
{
// Выполняем крафт
player.inventory.Take(null, mvk.itemid, (int)mvk_amount);
player.inventory.Take(null, pipe.itemid, (int)pipe_amount);
player.inventory.Take(null, gears.itemid, (int)gears_amount);
player.inventory.Take(null, burplus.itemid, (int)burplus_amount);
BoxPlugin.Call("resursebox.craft", player);
CloseMenu(player);
ShowMessage(player, "Крафт успешен!");
}
else
{
ulong requiredMvk = mvk_amount - playerMvkAmount;
ulong requiredGears = gears_amount - playerGearsAmount;
ulong requiredPipe = pipe_amount - playerPipeAmount;
ulong requiredBurplus = burplus_amount - playerBurplusAmount;
ShowMessage(player, $"У вас не хватает {requiredMvk} МВК, {requiredGears} шестеренок, {requiredPipe} болтов и {requiredBurplus} бура+ для крафта.");
}
}
else
{
ShowMessage(player, "Один или несколько предметов не найдены (МВК, шестеренки, трубы). Проверьте корректность имён предметов.");
}
}
private void CloseMenu(BasePlayer player)
{
if (activeMenus.ContainsKey(player.userID))
{
CuiHelper.DestroyUi(player, activeMenus[player.userID].Name);
activeMenus.Remove(player.userID);
}
}
private void ShowMessage(BasePlayer player, string message)
{
player.ChatMessage(message);
}
[ChatCommand("menu")]
private void ChatCommandMenu(BasePlayer player, string command, string[] args)
{
OpenMenu(player);
}
[ChatCommand("closemenu")]
private void ChatCommandCloseMenu(BasePlayer player, string command, string[] args)
{
CloseMenu(player);
ShowMessage(player, "Меню закрыто.");
}
void OnPlayerDisconnected(BasePlayer player, string reason)
{
CloseMenu(player);
}
}
}