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

Нейросеть GPT-3.5 Turbo доступна всем пользователям. Для доступа к GPT-4 Turbo необходимо приобрести «Премиум».
Конечно, вот код с добавлением графического интерфейса по центру экрана с разрешением 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);
        }

        [
Жив
 
Напиши плагин на временную блокировку движений в начале вайпа
Конечно, я могу помочь с написанием плагина для блокировки движений в начале вайпа. Вот пример кода на C#, который можно использовать для этой цели:

C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Oxide.Core;
using Oxide.Core.Libraries.Covalence;

namespace Oxide.Plugins
{
    [Info("Wipe Movement Lock", "YourNameHere", "1.0.0")]
    [Description("Prevents players from moving for a set amount of time at the start of the wipe.")]
    public class WipeMovementLock : RustPlugin
    {
        private readonly TimeSpan lockDuration = TimeSpan.FromMinutes(5);
        private readonly Dictionary<ulong, DateTime> movementLocks = new Dictionary<ulong, DateTime>();

        private void OnPlayerMovement(BasePlayer player, PlayerMovement movement)
        {
            if (movementLocks.ContainsKey(player.userID) && DateTime.Now - movementLocks[player.userID] < lockDuration)
            {
                movement.SetVelocity(Vector3.zero);
                movementLocks[player.userID] = DateTime.Now;
            }
        }

        [ChatCommand("lockmovement")]
        private void LockMovementCommand(IPlayer player, string command, string[] args)
        {
            if (!player.IsAdmin)
            {
                player.Reply("You do not have permission to use this command.");
                return;
            }

            if (args.Length != 1 || !int.TryParse(args[0], out int durationMinutes))
            {
                player.Reply($"Usage: /{command} <duration in minutes>");
                return;
            }

            lockDuration = TimeSpan.FromMinutes(durationMinutes);
            movementLocks.Clear();

            Puts($"Movement locked for {lockDuration.TotalMinutes} minutes.");
            foreach (BasePlayer onlinePlayer in BasePlayer.activePlayerList)
            {
                movementLocks[onlinePlayer.userID] = DateTime.Now;
            }
        }

        [ChatCommand("unlockmovement")]
        private void UnlockMovementCommand(IPlayer player, string command, string[] args)
        {
            if (!player.IsAdmin)
            {
                player.Reply("You do not have permission to use this command.");
                return;
            }

            movementLocks.Clear();
            Puts("Movement unlocked.");
        }
    }
}

Этот плагин запрещает игрокам двигаться на определенное время в начале вайпа. Если игрок попытается двигаться, он будет остановлен, и его скорость будет установлена в 0. По умолчанию блокировка длится 5 минут, но вы можете изменить это значение, используя команду "/lockmovement duration" в игре. Команда "/unlockmovement" отменяет блокировку движения и позволяет игрокам свободно передвигаться.
 
Конечно, я могу помочь с написанием плагина для блокировки движений в начале вайпа. Вот пример кода на C#, который можно использовать для этой цели:

C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Oxide.Core;
using Oxide.Core.Libraries.Covalence;

namespace Oxide.Plugins
{
    [Info("Wipe Movement Lock", "YourNameHere", "1.0.0")]
    [Description("Prevents players from moving for a set amount of time at the start of the wipe.")]
    public class WipeMovementLock : RustPlugin
    {
        private readonly TimeSpan lockDuration = TimeSpan.FromMinutes(5);
        private readonly Dictionary<ulong, DateTime> movementLocks = new Dictionary<ulong, DateTime>();

        private void OnPlayerMovement(BasePlayer player, PlayerMovement movement)
        {
            if (movementLocks.ContainsKey(player.userID) && DateTime.Now - movementLocks[player.userID] < lockDuration)
            {
                movement.SetVelocity(Vector3.zero);
                movementLocks[player.userID] = DateTime.Now;
            }
        }

        [ChatCommand("lockmovement")]
        private void LockMovementCommand(IPlayer player, string command, string[] args)
        {
            if (!player.IsAdmin)
            {
                player.Reply("You do not have permission to use this command.");
                return;
            }

            if (args.Length != 1 || !int.TryParse(args[0], out int durationMinutes))
            {
                player.Reply($"Usage: /{command} <duration in minutes>");
                return;
            }

            lockDuration = TimeSpan.FromMinutes(durationMinutes);
            movementLocks.Clear();

            Puts($"Movement locked for {lockDuration.TotalMinutes} minutes.");
            foreach (BasePlayer onlinePlayer in BasePlayer.activePlayerList)
            {
                movementLocks[onlinePlayer.userID] = DateTime.Now;
            }
        }

        [ChatCommand("unlockmovement")]
        private void UnlockMovementCommand(IPlayer player, string command, string[] args)
        {
            if (!player.IsAdmin)
            {
                player.Reply("You do not have permission to use this command.");
                return;
            }

            movementLocks.Clear();
            Puts("Movement unlocked.");
        }
    }
}
Хука OnPlayerMovement не существует, исправь
 
Хука OnPlayerMovement не существует, исправь
Ой, моя ошибка! Спасибо за исправление. Вместо OnPlayerMovement нужно использовать OnPlayerTick для блокировки движения в начале вайпа. Вот исправленный код:

C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Oxide.Core;
using Oxide.Core.Libraries.Covalence;

namespace Oxide.Plugins
{
    [Info("Wipe Movement Lock", "YourNameHere", "1.0.0")]
    [Description("Prevents players from moving for a set amount of time at the start of the wipe.")]
    public class WipeMovementLock : RustPlugin
    {
        private readonly TimeSpan lockDuration = TimeSpan.FromMinutes(5);
        private readonly Dictionary<ulong, DateTime> movementLocks = new Dictionary<ulong, DateTime>();

        private void OnPlayerTick(BasePlayer player)
        {
            if (movementLocks.ContainsKey(player.userID) && DateTime.Now - movementLocks[player.userID] < lockDuration)
            {
                player.Move(Vector3.zero);
                movementLocks[player.userID] = DateTime.Now;
            }
        }

        [ChatCommand("lockmovement")]
        private void LockMovementCommand(IPlayer player, string command, string[] args)
        {
            if (!player.IsAdmin)
            {
                player.Reply("You do not have permission to use this command.");
                return;
            }

            if (args.Length != 1 || !int.TryParse(args[0], out int durationMinutes))
            {
                player.Reply($"Usage: /{command} <duration in minutes>");
                return;
            }

            lockDuration = TimeSpan.FromMinutes(durationMinutes);
            movementLocks.Clear();

            Puts($"Movement locked for {lockDuration.TotalMinutes} minutes.");
            foreach (BasePlayer onlinePlayer in BasePlayer.activePlayerList)
            {
                movementLocks[onlinePlayer.userID] = DateTime.Now;
            }
        }

        [ChatCommand("unlockmovement")]
        private void UnlockMovementCommand(IPlayer player, string command, string[] args)
        {
            if (!player.IsAdmin)
            {
                player.Reply("You do not have permission to use this command.");
                return;
            }

            movementLocks.Clear();
            Puts("Movement unlocked.");
        }
    }
}

Исправления заключаются в замене OnPlayerMovement на OnPlayerTick и movement.SetVelocity(Vector3.zero) на player.Move(Vector3.zero). Эти изменения позволят блокировать движения в начале вайпа.
 
напиши плагин что бы показывал через команду сколько прошло времени от вайпа
Конечно, я могу помочь с написанием плагина, который будет показывать, сколько времени прошло с момента последнего вайпа через команду. Вот пример кода на C#, который можно использовать для этой цели:

C#:
using System;
using Oxide.Core;
using Oxide.Core.Libraries.Covalence;

namespace Oxide.Plugins
{
    [Info("Wipe Timer", "YourNameHere", "1.0.0")]
    [Description("Shows how much time has passed since the last wipe.")]
    public class WipeTimer : RustPlugin
    {
        private DateTime lastWipeTime;

        [ChatCommand("wipetime")]
        private void WipeTimeCommand(IPlayer player, string command, string[] args)
        {
            TimeSpan timeSinceWipe = DateTime.Now - lastWipeTime;
            string timeSinceWipeString = $"{timeSinceWipe.Days}d {timeSinceWipe.Hours}h {timeSinceWipe.Minutes}m {timeSinceWipe.Seconds}s";
            player.Reply($"Time since last wipe: {timeSinceWipeString}");
        }

        private void OnServerInitialized()
        {
            lastWipeTime = DateTime.Now;
            Puts("Wipe timer initialized.");
        }

        private void OnWipeCompleted()
        {
            lastWipeTime = DateTime.Now;
            Puts("Wipe time updated.");
        }
    }
}

Этот плагин реагирует на OnServerInitialized() и OnWipeCompleted() события, чтобы определить время, прошедшее с последнего вайпа. Команда "/wipetime" показывает, сколько времени прошло с момента последнего вайпа. При инициализации сервера и завершении вайпа плагин обновляет время последнего вайпа.
 
Этот плагин запрещает игрокам двигаться на определенное время в начале вайпа.
Сделай плагин, который блокирует использование пистолета глок на 2 часа после вайпа в Rust.
 
Придумай идею для плагина
Как насчет плагина, который позволяет игрокам устанавливать точки телепортации на определенную зону карты? Например, игрок может установить точку телепортации в своем доме или в другом месте, которое ему нравится, а затем использовать эту точку, чтобы быстро перемещаться по карте. Это может быть полезным для игроков, которые хотят быстро перемещаться по карте, чтобы избежать длительных поездок в поисках нужных ресурсов или других игроков.
 
Сделай плагин, который блокирует использование пистолета глок на 2 часа после вайпа в Rust.
Конечно, я могу помочь с написанием плагина, который блокирует использование пистолета глок на 2 часа после вайпа в Rust. Вот пример кода на C#, который можно использовать для этой цели:

C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Oxide.Core;
using Oxide.Core.Libraries.Covalence;

namespace Oxide.Plugins
{
    [Info("Glock Lock", "YourNameHere", "1.0.0")]
    [Description("Prevents players from using the Glock pistol for a set amount of time after wipe.")]
    public class GlockLock : RustPlugin
    {
        private readonly TimeSpan lockDuration = TimeSpan.FromHours(2);
        private readonly Dictionary<ulong, DateTime> glockLocks = new Dictionary<ulong, DateTime>();

        private void OnItemDeployed(Deployer deployer, BaseEntity deployedEntity)
        {
            if (deployedEntity is BaseProjectile projectile && projectile.ShortPrefabName == "pistol.semiauto")
            {
                if (glockLocks.ContainsKey(deployer.OwnerID) && DateTime.Now - glockLocks[deployer.OwnerID] < lockDuration)
                {
                    projectile.Kill();
                    Puts($"Blocked Glock use by {deployer.OwnerID}.");
                }
                else
                {
                    glockLocks[deployer.OwnerID] = DateTime.Now;
                }
            }
        }

        [ChatCommand("glocklock")]
        private void GlockLockCommand(IPlayer player, string command, string[] args)
        {
            if (!player.IsAdmin)
            {
                player.Reply("You do not have permission to use this command.");
                return;
            }

            if (args.Length != 1 || !int.TryParse(args[0], out int durationHours))
            {
                player.Reply($"Usage: /{command} <duration in hours>");
                return;
            }

            lockDuration = TimeSpan.FromHours(durationHours);
            glockLocks.Clear();

            Puts($"Glock locked for {lockDuration.TotalHours} hours.");
        }

        [ChatCommand("glockunlock")]
        private void GlockUnlockCommand(IPlayer player, string command, string[] args)
        {
            if (!player.IsAdmin)
            {
                player.Reply("You do not have permission to use this command.");
                return;
            }

            glockLocks.Clear();
            Puts("Glock unlocked.");
        }
    }
}

Этот плагин блокирует использование Glock пистолета в течение 2 часов после вайпа. Если игрок попытается использовать этот пистолет в блокировочный период, он будет убит. По умолчанию блокировка длится 2 часа, но вы можете изменить это значение, используя команду "/glocklock duration" в игре. Команда "/glockunlock" отменяет блокировку Glock пистолета и позволяет игрокам свободно использовать этот предмет.
 
Активность
Пока никто не печатает сообщение