1. Hello everyone, tell me please, what I'm doing wrong, I want to check whether the helicopter is active at the moment or not.
    Code:
    var heli = (BaseHelicopter)GameManager.server.CreateEntity("assets/prefabs/npc/patrol helicopter/patrolhelicopter.prefab", new Vector3(), new Quaternion(), true);            if (heli.IsActive)
                {
                    SendReply(player, GetMessage("Helicopter already active"));
                    return;
                }
    When I try to call at least one helicopter, IsActive does not let me do it.
     
  2. Code:
    BaseHelicopter heli = (BaseHelicopter)GameManager.server.CreateEntity("assets/prefabs/npc/patrol helicopter/patrolhelicopter.prefab", new Vector3(), new Quaternion(), true);
    if (heli != null)
    {
        SendReply(player, GetMessage("Helicopter already active"));
        return;
    }
     
  3. Absolutely not that
     
  4. What your code should do?

    If you need to control the heli entity, make global Hash or global List and add heli to this list when heli was created, remove heli from Hash or List when entity was destroyed.

    The you can check heli by this list.
     
  5. Well, look, I made the plugin when I drop the supply, the helicopter arrives to patrol this area.
    Now I do not understand what I'm doing wrong, because I had a similar code in another place

    Code:
    private void OnExplosiveDropped(BasePlayer player, BaseEntity entity)
            {
                var item = player.GetActiveItem();
                if (player == null || item == null)
                    return;            if (!_supplys.Contains(item.uid))
                    return;            _supplys.Remove(item.uid);
                SaveData();            InvokeHandler.CancelInvoke(entity.GetComponent<MonoBehaviour>(), new Action((entity as SupplySignal).Explode));            var heli = (BaseHelicopter)GameManager.server.CreateEntity("assets/prefabs/npc/patrol helicopter/patrolhelicopter.prefab", new Vector3(), new Quaternion(), true);            if (heli.IsActive)
                {
                    SendReply(player, GetMessage("Helicopter already active"));
                    return;
                }            CallHeli(entity.GetDropPosition() + new Vector3(0, 20f, 0));            SendReply(player, GetMessage("Use supply"));
            }
     
  6. Code:
    using System;
    using System.Linq;
    using System.Data;
    using System.Reflection;
    using System.Collections.Generic;
    using Oxide.Core;
    using Oxide.Game.Rust;
    using Oxide.Game.Rust.Cui;
    using Oxide.Core.Plugins;
    using Oxide.Core.Libraries;
    using Oxide.Core.Configuration;
    using Rust;
    using UnityEngine;
    using Newtonsoft.Json;namespace Oxide.Plugins {
        [Info("...", "...", "0.0.1")]
        [Description("...")]
        class SomePluginName : RustPlugin {
            
            // Hash (list) item
            class HelicopterItem {
                public BaseHelicopter Heli;
                public BasePlayer Player;
            }        // Global hash (list)
            Hash<BaseHelicopter, HelicopterItem> FHelicopters = new Hash<BaseHelicopter, HelicopterItem>();        private void OnExplosiveDropped(BasePlayer player, BaseEntity entity) {
                var item = player.GetActiveItem();
                if(player == null || item == null) return;
                if(!_supplys.Contains(item.uid)) return;
                _supplys.Remove(item.uid);
                SaveData();            InvokeHandler.CancelInvoke(entity.GetComponent<MonoBehaviour>(), new Action((entity as SupplySignal).Explode));            // (CHECK) If heli present in list, do not create heli more then one...
                // Send reply to player and return
                HelicopterItem LTmpValue;
                if(FHelicopters.TryGetValue(entity as BaseHelicopter, out LTmpValue) != false) {
                    SendReply(player, GetMessage("Helicopter already active"));
                    return;
                }            // Create and add heli to list
                var heli = (BaseHelicopter)GameManager.server.CreateEntity("assets/prefabs/npc/patrol helicopter/patrolhelicopter.prefab", new Vector3(), new Quaternion(), true);
                HelicopterItem LNewValue = new HelicopterItem();
                LNewValue.Heli = heli as BaseHelicopter;
                LNewValue.Player = player;
                FHelicopters[heli as BaseHelicopter] = LNewValue;            // ...            CallHeli(entity.GetDropPosition() + new Vector3(0, 20f, 0));
                SendReply(player, GetMessage("Use supply"));
            }
            
            // Remove heli from list
            void OnEntityKill(BaseNetworkable AEntity) {
                if(AEntity == null) return;
                if(!(AEntity is BaseHelicopter)) return;            // Search heli in list, stop if not in list
                HelicopterItem LTmpValue;
                if(FHelicopters.TryGetValue(AEntity as BaseHelicopter, out LTmpValue) == false) return;            // Remove heli from list
                FHelicopters.Remove(AEntity as BaseHelicopter);
            }
        }
    }
    Something like this...
     
  7. Thanks for the help, figured out.