using System; using Oxide.Core; using Oxide.Core.Configuration; using Oxide.Core.Plugins; using UnityEngine; namespace Oxide.Plugins { [Info("MinicopterSpawnPlugin", "Bojack", "1.0.0")] [Description("Spawns a minicopter next to a player if they have enough scrap.")] class MinicopterSpawnPlugin : RustPlugin { private PluginConfig config; private class PluginConfig { public int ScrapPrice { get; set; } = 750; } private void Init() { LoadConfig(); } private void LoadConfig() { config = Config.ReadObject(); SaveConfig(); } private void SaveConfig() { Config.WriteObject(config); } // Handle the 'minicopter' command [ChatCommand("buymini")] private void cmdMinicopter(BasePlayer player, string command, string[] args) { // Check if the player has enough scrap int scrapPrice = config.ScrapPrice; if (player.inventory.GetAmount(-932201673) < scrapPrice) { SendReply(player, $"You need {scrapPrice} scrap to buy a minicopter."); return; } // Deduct scrap price from the player's inventory player.inventory.Take(null, -932201673, scrapPrice); // Spawn a minicopter next to the player var playerPos = player.transform.position; var minicopterPos = playerPos + (player.transform.forward * 3f) + Vector3.up * 1.5f; // Spawn in front of player, slightly higher var minicopter = GameManager.server.CreateEntity("assets/content/vehicles/minicopter/minicopter.entity.prefab", minicopterPos); if (minicopter != null) { minicopter.Spawn(); SendReply(player, "A minicopter has been spawned next to you!"); } } protected override void LoadDefaultConfig() { config = new PluginConfig(); SaveConfig(); } } }