using System; using System.Collections.Generic; using System.Linq; namespace Oxide.Plugins { [Info("AlwaysOn HotAirBalloon", "bsdinis", "0.0.5")] [Description("Prevents Hot Air Balloons from turning themselves off if there are players inside.")] public class AlwaysOnHotAirBalloon : RustPlugin { List habs = new List(); private void OnServerInitialized() { timer.Repeat(29f, 0, () => { foreach (var hab in habs.ToList()) { if (hab == null || !hab.IsOn()) { habs.Remove(hab); continue; } if (hab.IsOn()) { foreach (var player in hab.GetComponentsInChildren()) { if (player == null || !player.IsConnected || player.IsSleeping()) continue; if (hab.GetComponent().IsInvoking(hab.ScheduleOff)) hab.CancelInvoke(new Action(hab.ScheduleOff)); return; } if (!hab.GetComponent().IsInvoking(hab.ScheduleOff)) hab.Invoke(new Action(hab.ScheduleOff), 30f); } } }); } private void OnHotAirBalloonToggle(HotAirBalloon hab) => habs.Add(hab); private void OnEntityKill(HotAirBalloon hab) { if (habs.Contains(hab)) habs.Remove(hab); } private void Unload() { foreach (var hab in habs) { if (hab.IsOn() && !hab.GetComponent().IsInvoking(hab.ScheduleOff)) hab.Invoke(new Action(hab.ScheduleOff), 60f); } } } }