using Newtonsoft.Json; namespace Oxide.Plugins { [Info("GetToDaChoppa", "MikeHawke", "1.0.6")] [Description("Spawn Minis and scrap helis with a respectable amount of fuel")] class GetToDaChoppa : RustPlugin { private ConfigData configData; class ConfigData { [JsonProperty(PropertyName = "Amount of fuel to spawn with MiniCopters")] public int MiniFuel = 100; [JsonProperty(PropertyName = "Amount of fuel to spawn with Scrap Helicopters")] public int ScrapFuel = 100; } void Init() { if (!LoadConfigVariables()) { Puts("Config file issue detected. Please delete file, or check syntax and fix."); return; } } private bool LoadConfigVariables() { try { configData = Config.ReadObject(); } catch { return false; } SaveConfig(configData); return true; } protected override void LoadDefaultConfig() { Puts("Creating new config file."); configData = new ConfigData(); SaveConfig(configData); } void SaveConfig(ConfigData config) { Config.WriteObject(config, true); } void OnEntitySpawned(Minicopter Mini) { if (Rust.Application.isLoadingSave) return; NextTick(() => { if (Mini != null) { if ((Mini as BaseVehicle).IsSafe()) { int fuelamount = configData.MiniFuel; var Scrap = Mini as Minicopter; if (Scrap != null) fuelamount = configData.ScrapFuel; var Tank = Mini.GetFuelSystem()?.fuelStorageInstance.Get(true); var fuel = Tank.inventory.GetSlot(0); if (fuel == null) return; if (fuel != null) fuel.amount = fuelamount; else Tank.inventory.AddItem(Tank.allowedItem, fuelamount, 0); } } }); } } }