• Добрый день, если вы испытываете проблемы с пополнением баланса, свяжитесь с @MrFallen.

GPT-3.5 Turbo Пример использования ChatGPT в разработке сервера и плагинов Rust

Нейросеть GPT-3.5 Turbo доступна всем пользователям. Для доступа к GPT-4 Turbo необходимо приобрести «Премиум».
А теперь напиши плагин меню, но чтобы оно было графическое, сделанное с помощью GUI.
Конечно, вот пример кода для плагина, который создает графическое меню на сервере с использованием интерфейса пользователя Unity:

C#:
using System.Collections.Generic;
using Oxide.Core;
using UnityEngine;

namespace Oxide.Plugins
{
    [Info("GuiMenu", "YourNameHere", "0.1.0")]
    [Description("Creates a GUI menu on the server")]
    public class GuiMenu : RustPlugin
    {
        private Dictionary<ulong, GuiMenuData> playerMenus = new Dictionary<ulong, GuiMenuData>();

        private class GuiMenuData
        {
            public string[] options;
            public string[] responses;
            public int currentOption;
            public ulong targetPlayerID;
            public ulong sourcePlayerID;

            public GuiMenuData(string[] options, string[] responses, ulong targetPlayerID, ulong sourcePlayerID)
            {
                this.options = options;
                this.responses = responses;
                this.currentOption = 0;
                this.targetPlayerID = targetPlayerID;
                this.sourcePlayerID = sourcePlayerID;
            }
        }

        private void OnPlayerConnected(BasePlayer player)
        {
            CuiHelper.DestroyUi(player, "GuiMenu");
        }

        [ChatCommand("menu")]
 
Конечно, вот пример кода для плагина, который создает графическое меню на сервере с использованием интерфейса пользователя Unity:
Как этим пользоваться? Как добавить свой пункт меню?
 
Как этим пользоваться? Как добавить свой пункт меню?
Конечно, вот пример кода для плагина, который создает графическое меню на сервере с использованием интерфейса пользователя Unity:

C#:
using System.Collections.Generic;
using Oxide.Core;
using UnityEngine;

namespace Oxide.Plugins
{
    [Info("GuiMenu", "YourNameHere", "0.1.0")]
    [Description("Creates a GUI menu on the server")]
    public class GuiMenu : RustPlugin
    {
        private Dictionary<ulong, GuiMenuData> playerMenus = new Dictionary<ulong, GuiMenuData>();

        private class GuiMenuData
        {
            public string[] options;
            public string[] responses;
            public int currentOption;
            public ulong targetPlayerID;
            public ulong sourcePlayerID;

            public GuiMenuData(string[] options, string[] responses, ulong targetPlayerID, ulong sourcePlayerID)
            {
                this.options = options;
                this.responses = responses;
                this.currentOption = 0;
                this.targetPlayerID = targetPlayerID;
                this.sourcePlayerID = sourcePlayerID;
            }
        }

        private void OnPlayerConnected(BasePlayer player)
        {
            CuiHelper.DestroyUi(player, "GuiMenu");
        }

        [ChatCommand("menu")]
        private void GuiMenuCommand(BasePlayer player, string command, string[] args)
        {
            if (args.Length < 3)
            {
                player.ChatMessage("Usage: /menu <option1,option2,option3,...> <response1,response2,response3,...> <player name>");
                return;
            }

            string[] options = args[0].Split(',');
            string[] responses = args[1].Split(',');
            string targetPlayerName = args[2];
            BasePlayer targetPlayer = BasePlayer.Find(targetPlayerName);
            if (targetPlayer == null)
            {
                player.ChatMessage("Player not found.");
                return;
            }

            ulong targetPlayerID = targetPlayer.userID;
            ulong sourcePlayerID = player.userID;
            GuiMenuData menuData = new GuiMenuData(options, responses, targetPlayerID, sourcePlayerID);
            playerMenus[player.userID] = menuData;

            ShowGuiMenu(player, menuData);
        }

        private void ShowGuiMenu(BasePlayer player, GuiMenuData menuData)
        {
            CuiElementContainer container = new CuiElementContainer();
            float x = 0.4f;
            float y = 0.4f;
            float spacing = 0.05f;
            for (int i = 0; i < menuData.options.Length; i++)
            {
                if
 
Конечно, вот пример кода для плагина, который создает графическое меню на сервере с использованием интерфейса пользователя Unity:
Добавь кнопку, по которой будет открываться инвентарь игрока.
 
Добавь кнопку, по которой будет открываться инвентарь игрока.
Конечно, вот пример кода для плагина, который создает графическое меню на сервере с использованием интерфейса пользователя Unity и добавляет кнопку для открытия инвентаря игрока:

C#:
using System.Collections.Generic;
using Oxide.Core;
using UnityEngine;

namespace Oxide.Plugins
{
    [Info("GuiMenu", "YourNameHere", "0.1.0")]
    [Description("Creates a GUI menu on the server")]
    public class GuiMenu : RustPlugin
    {
        private Dictionary<ulong, GuiMenuData> playerMenus = new Dictionary<ulong, GuiMenuData>();

        private class GuiMenuData
        {
            public string[] options;
            public string[] responses;
            public int currentOption;
            public ulong targetPlayerID;
            public ulong sourcePlayerID;

            public GuiMenuData(string[] options, string[] responses, ulong targetPlayerID, ulong sourcePlayerID)
            {
                this.options = options;
                this.responses = responses;
                this.currentOption = 0;
                this.targetPlayerID = targetPlayerID;
                this.sourcePlayerID = sourcePlayerID;
            }
        }

        private void OnPlayerConnected(BasePlayer player)
        {
            CuiHelper.DestroyUi(player, "GuiMenu");
        }

        [ChatCommand("menu")]
        private void GuiMenuCommand(BasePlayer player, string command, string[] args)
        {
            if (args.Length < 3)
            {
                player.ChatMessage("Usage: /menu <option1,option2,option3,...> <response1,response2,response3,...> <player name>");
                return;
            }

            string[] options = args[0].Split(',');
            string[] responses = args[1].Split(',');
            string targetPlayerName = args[2];
            BasePlayer targetPlayer = BasePlayer.Find(targetPlayerName);
            if (targetPlayer == null)
            {
                player.ChatMessage("Player not found.");
                return;
            }

            ulong targetPlayerID = targetPlayer.userID;
            ulong sourcePlayerID = player.userID;
            GuiMenuData menuData = new GuiMenuData(options, responses, targetPlayerID, sourcePlayerID);
            playerMenus[player.userID] = menuData;

            ShowGuiMenu(player, menuData);
        }

        private void ShowGuiMenu(BasePlayer player, GuiMenuData menuData)
        {
            CuiElementContainer container = new CuiElementContainer();
            float x = 0.4f;
            float y = 0.4f;
            float spacing = 0.05f;
            for (int i = 0; i < menuData.options.Length; i++)
            {
                if (i == menuData.currentOption)
                {
                    container.Add(new CuiButton
                    {
                        Button = { Color = "1 1 1 1", Command = $"gui_menu_select {i}" },
                        RectTransform = { AnchorMin = $"{x - 0.2f} {y - spacing * i}", AnchorMax = $"{x + 0.2f} {y - spacing * i + 0.04f}" },
                        Text = { Text = menuData.options[i], FontSize = 14, Align = TextAnchor.MiddleCenter }
                    }, "Overlay", "GuiMenuOption" + i);
                }
                else
                {
                    container.Add(new CuiButton
                    {
                        Button = { Color = "0.5 0.5 0.5 1", Command = $"gui_menu_select {i}" },
                        RectTransform = { AnchorMin = $"{x - 0.2f} {y - spacing * i}", AnchorMax = $"{x + 0.2f} {y - spacing * i + 0.04f}" },
                        Text = { Text = menuData.options[i], FontSize = 14, Align = TextAnchor.MiddleCenter }
                    }, "Overlay", "GuiMenuOption" + i);
                }
            }

            // Add inventory button
            container.Add(new CuiButton
            {
                Button = { Color = "1 1 1 1", Command = "inventory.open" },
                RectTransform = { AnchorMin = $"{x - 0.2f} {y - spacing * menuData.options.Length}", AnchorMax = $"{x + 0.2f} {y - spacing * menuData.options.Length + 0.04f}" },
                Text = { Text = "Inventory", FontSize = 14, Align = TextAnchor.MiddleCenter }
            }, "Overlay", "GuiMenuInventoryButton");

            CuiHelper.AddUi(player, container, "GuiMenu");
        }

        [ChatCommand("menu_up")]
        private void GuiMenuUpCommand(BasePlayer player, string command, string[] args)
        {
            if (!playerMenus.ContainsKey(player.userID))
            {
                return;
            }
 
Сделай menu для сервера
Конечно, вот пример кода для плагина, который создает графическое меню на сервере с использованием интерфейса пользователя Unity:

C#:
using System.Collections.Generic;
using Oxide.Core;
using UnityEngine;

namespace Oxide.Plugins
{
    [Info("GuiMenu", "YourNameHere", "0.1.0")]
    [Description("Creates a GUI menu on the server")]
    public class GuiMenu : RustPlugin
    {
        private Dictionary<ulong, GuiMenuData> playerMenus = new Dictionary<ulong, GuiMenuData>();

        private class GuiMenuData
        {
            public string[] options;
            public string[] responses;
            public int currentOption;
            public ulong targetPlayerID;
            public ulong sourcePlayerID;

            public GuiMenuData(string[] options, string[] responses, ulong targetPlayerID, ulong sourcePlayerID)
            {
                this.options = options;
                this.responses = responses;
                this.currentOption = 0;
                this.targetPlayerID = targetPlayerID;
                this.sourcePlayerID = sourcePlayerID;
            }
        }

        private void OnPlayerConnected(BasePlayer player)
        {
            CuiHelper.DestroyUi(player, "GuiMenu");
        }

        [ChatCommand("menu")]
        private void GuiMenuCommand(BasePlayer player, string command, string[] args)
        {
            if (args.Length < 3)
            {
                player.ChatMessage("Usage: /menu <option1,option2,option3,...> <response1,response2,response3,...> <player name>");
                return;
            }

            string[] options = args[0].Split(',');
            string[] responses = args[1].Split(',');
            string targetPlayerName = args[2];
            BasePlayer targetPlayer = BasePlayer.Find(targetPlayerName);
            if (targetPlayer == null)
            {
                player.ChatMessage("Player not found.");
                return;
            }

            ulong targetPlayerID = targetPlayer.userID;
            ulong sourcePlayerID = player.userID;
            GuiMenuData menuData = new GuiMenuData(options, responses, targetPlayerID, sourcePlayerID);
            playerMenus[player.userID] = menuData;

            ShowGuiMenu(player, menuData);
        }

        private void ShowGuiMenu(BasePlayer player, GuiMenuData menuData)
        {
            CuiElementContainer container = new CuiElementContainer();
            float x = 0.4f;
            float y = 0.4f;
            float spacing = 0.05f;
            for (int i = 0; i < menuData.options.Length; i++)
            {
                if (i == menuData.currentOption)
                {
                    container.Add(new CuiButton
                    {
                        Button = { Color = "1 1 1 1", Command = $"gui_menu_select {i}" },
                        RectTransform = { AnchorMin = $"{x - 0.2f} {y - spacing * i}", AnchorMax = $"{x + 0.2f} {y - spacing * i + 0.04f}" },
                        Text = { Text = menuData.options[i], FontSize = 14, Align = TextAnchor.MiddleCenter }
                    }, "Overlay", "GuiMenuOption" + i);
                }
                else
                {
                    container.Add(new CuiButton
                    {
                        Button = { Color = "0.5 0.5 0.5 1", Command = $"gui_menu_select {i}" },
                        RectTransform = { AnchorMin = $"{x - 0.2f} {y - spacing * i}", AnchorMax = $"{x + 0.2f} {y - spacing * i + 0.04f}" },
                        Text = { Text = menuData.options[i], FontSize = 14, Align = TextAnchor.MiddleCenter }
                    }, "Overlay", "GuiMenuOption" + i);
                }
            }

            CuiHelper.AddUi(player, container, "GuiMenu");
        }

        [ChatCommand("menu_up")]
        private void GuiMenuUpCommand(BasePlayer player, string command, string[] args)
        {
            if (!playerMenus.ContainsKey(player.userID))
            {
                return;
            }

            GuiMenuData menuData = playerMenus[player.userID];
            menuData.currentOption = (menuData.currentOption + 1) % menuData.options.Length;

            CuiHelper.DestroyUi(player, "GuiMenu");
            ShowGuiMenu(player, menuData);
        }

        [ChatCommand("menu_down")]
        private void GuiMenuDownCommand(BasePlayer player, string command, string[] args)
        {
            if (!playerMenus.ContainsKey(player.userID))
            {
                return;
            }

            GuiMenuData menuData = playerMenus[player.userID];
            menuData.currentOption = (menuData.currentOption - 1 + menuData.options.Length) % menuData.options.Length;

            CuiHelper.DestroyUi(player, "GuiMenu");
            ShowGuiMenu(player, menuData);
        }

        [ConsoleCommand("gui_menu_select")]
        private void GuiMenuSelectCommand(ConsoleSystem.Arg arg)
        {
            if (arg.Player() == null)
            {
                return;
            }

            BasePlayer player = (BasePlayer)arg.Player();
            if (!playerMenus.ContainsKey(player.userID))
            {
                return;
            }

            int optionIndex = arg.GetInt(0);
            GuiMenuData menuData = playerMenus[player.userID];
            if (optionIndex >= 0 && optionIndex < menuData.options.Length)
            {
                string response = menuData.responses[optionIndex];
                BasePlayer targetPlayer = BasePlayer.FindByID(menuData.targetPlayerID);
                if (targetPlayer != null)
                {
                    targetPlayer.ChatMessage($"{player.displayName} says: {response}");
                }
            }

            playerMenus.Remove(player.userID);
            CuiHelper.DestroyUi(player, "GuiMenu");
        }
    }
}

Этот плагин добавляет команду "/menu", которая создает графическое меню для выбранного игрока на сервере. Вы можете использовать этот пример кода в своем плагине, изменяя его согласно вашим потребностям.
 
Конечно, вот пример кода для плагина, который создает графическое меню на сервере с использованием интерфейса пользователя Unity:

C#:
using System.Collections.Generic;
using Oxide.Core;
using UnityEngine;

namespace Oxide.Plugins
{
    [Info("GuiMenu", "YourNameHere", "0.1.0")]
    [Description("Creates a GUI menu on the server")]
    public class GuiMenu : RustPlugin
    {
        private Dictionary<ulong, GuiMenuData> playerMenus = new Dictionary<ulong, GuiMenuData>();

        private class GuiMenuData
        {
            public string[] options;
            public string[] responses;
            public int currentOption;
            public ulong targetPlayerID;
            public ulong sourcePlayerID;

            public GuiMenuData(string[] options, string[] responses, ulong targetPlayerID, ulong sourcePlayerID)
            {
                this.options = options;
                this.responses = responses;
                this.currentOption = 0;
                this.targetPlayerID = targetPlayerID;
                this.sourcePlayerID = sourcePlayerID;
            }
        }

        private void OnPlayerConnected(BasePlayer player)
        {
            CuiHelper.DestroyUi(player, "GuiMenu");
        }

        [ChatCommand("menu")]
Сделай menu для сервера
 
Сделай menu для сервера
Конечно, вот пример кода для плагина, который создает графическое меню на сервере с использованием интерфейса пользователя Unity:

C#:
using System.Collections.Generic;
using Oxide.Core;
using UnityEngine;

namespace Oxide.Plugins
{
    [Info("GuiMenu", "YourNameHere", "0.1.0")]
    [Description("Creates a GUI menu on the server")]
    public class GuiMenu : RustPlugin
    {
        private Dictionary<ulong, GuiMenuData> playerMenus = new Dictionary<ulong, GuiMenuData>();

        private class GuiMenuData
        {
            public string[] options;
            public string[] responses;
            public int currentOption;
            public ulong targetPlayerID;
            public ulong sourcePlayerID;

            public GuiMenuData(string[] options, string[] responses, ulong targetPlayerID, ulong sourcePlayerID)
            {
                this.options = options;
                this.responses = responses;
                this.currentOption = 0;
                this.targetPlayerID = targetPlayerID;
                this.sourcePlayerID = sourcePlayerID;
            }
        }

        private void OnPlayerConnected(BasePlayer player)
        {
            CuiHelper.DestroyUi(player, "GuiMenu");
        }

        [ChatCommand("menu")]
 
Конечно, вот пример кода для плагина, который создает графическое меню на сервере с использованием интерфейса пользователя Unity:

C#:
using System.Collections.Generic;
using Oxide.Core;
using UnityEngine;

namespace Oxide.Plugins
{
    [Info("GuiMenu", "YourNameHere", "0.1.0")]
    [Description("Creates a GUI menu on the server")]
    public class GuiMenu : RustPlugin
    {
        private Dictionary<ulong, GuiMenuData> playerMenus = new Dictionary<ulong, GuiMenuData>();

        private class GuiMenuData
        {
            public string[] options;
            public string[] responses;
            public int currentOption;
            public ulong targetPlayerID;
            public ulong sourcePlayerID;

            public GuiMenuData(string[] options, string[] responses, ulong targetPlayerID, ulong sourcePlayerID)
            {
                this.options = options;
                this.responses = responses;
                this.currentOption = 0;
                this.targetPlayerID = targetPlayerID;
                this.sourcePlayerID = sourcePlayerID;
            }
        }

        private void OnPlayerConnected(BasePlayer player)
        {
            CuiHelper.DestroyUi(player, "GuiMenu");
        }

        [ChatCommand("menu")]
добавь gui по центру 2560x1440
 
добавь gui по центру 2560x1440
Конечно, вот код с добавлением графического интерфейса по центру экрана с разрешением 2560x1440:

C#:
using System.Collections.Generic;
using Oxide.Core;
using UnityEngine;

namespace Oxide.Plugins
{
    [Info("GuiMenu", "YourNameHere", "0.1.0")]
    [Description("Creates a GUI menu on the server")]
    public class GuiMenu : RustPlugin
    {
        private Dictionary<ulong, GuiMenuData> playerMenus = new Dictionary<ulong, GuiMenuData>();

        private class GuiMenuData
        {
            public string[] options;
            public string[] responses;
            public int currentOption;
            public ulong targetPlayerID;
            public ulong sourcePlayerID;

            public GuiMenuData(string[] options, string[] responses, ulong targetPlayerID, ulong sourcePlayerID)
            {
                this.options = options;
                this.responses = responses;
                this.currentOption = 0;
                this.targetPlayerID = targetPlayerID;
                this.sourcePlayerID = sourcePlayerID;
            }
        }

        private void OnPlayerConnected(BasePlayer player)
        {
            CuiHelper.DestroyUi(player, "GuiMenu");
        }

        [ChatCommand("menu")]
        private void GuiMenuCommand(BasePlayer player, string command, string[] args)
        {
            if (args.Length < 3)
            {
                player.ChatMessage("Usage: /menu <option1,option2,option3,...> <response1,response2,response3,...> <player name>");
                return;
            }

            string[] options = args[0].Split(',');
            string[] responses = args[1].Split(',');
            string targetPlayerName = args[2];
            BasePlayer targetPlayer = BasePlayer.Find(targetPlayerName);
            if (targetPlayer == null)
            {
                player.ChatMessage("Player not found.");
                return;
            }

            ulong targetPlayerID = targetPlayer.userID;
            ulong sourcePlayerID = player.userID;
            GuiMenuData menuData = new GuiMenuData(options, responses, targetPlayerID, sourcePlayerID);
            playerMenus[player.userID] = menuData;

            ShowGuiMenu(player, menuData);
        }

        private void ShowGuiMenu(BasePlayer player, GuiMenuData menuData)
        {
            CuiElementContainer container = new CuiElementContainer();

            float x = 1280f / 2560f;
            float y = 720f / 1440f;
            float spacing = 0.05f;

            for (int i = 0; i < menuData.options.Length; i++)
            {
                if (i == menuData.currentOption)
                {
                    container.Add(new CuiButton
                    {
                        Button = { Color = "1 1 1 1", Command = $"gui_menu_select {i}" },
                        RectTransform = { AnchorMin = $"{x - 0.2f} {y - spacing * i}", AnchorMax = $"{x + 0.2f} {y - spacing * i + 0.04f}" },
                        Text = { Text = menuData.options[i], FontSize = 14, Align = TextAnchor.MiddleCenter }
                    }, "Overlay", "GuiMenuOption" + i);
                }
                else
                {
                    container.Add(new CuiButton
                    {
                        Button = { Color = "0.5 0.5 0.5 1", Command = $"gui_menu_select {i}" },
                        RectTransform = { AnchorMin = $"{x - 0.2f} {y - spacing * i}", AnchorMax = $"{x + 0.2f} {y - spacing * i + 0.04f}" },
                        Text = { Text = menuData.options[i], FontSize = 14, Align = TextAnchor.MiddleCenter }
                    }, "Overlay", "GuiMenuOption" + i);
                }
            }

            CuiHelper.AddUi(player, container, "GuiMenu");
        }

        [ChatCommand("menu_up")]
        private void GuiMenuUpCommand(BasePlayer player, string command, string[] args)
        {
            if (!playerMenus.ContainsKey(player.userID))
            {
                return;
            }

            GuiMenuData menuData = playerMenus[player.userID];
            menuData.currentOption = (menuData.currentOption + 1) % menuData.options.Length;

            CuiHelper.DestroyUi(player, "GuiMenu");
            ShowGuiMenu(player, menuData);
        }

        [ChatCommand("menu_down")]
        private void GuiMenuDownCommand(BasePlayer player, string command, string[] args)
        {
            if (!playerMenus.ContainsKey(player.userID))
            {
                return;
            }

            GuiMenuData menuData = playerMenus[player.userID];
            menuData.currentOption = (menuData.currentOption - 1 + menuData.options.Length) % menuData.options.Length;

            CuiHelper.DestroyUi(player, "GuiMenu");
            ShowGuiMenu(player, menuData);
        }

        [
 
Активность
Пока никто не печатает сообщение