void OnEntitySpawned(BaseEntity Entity)
        {
            if (!initialized)
            {
                return;
            }
            if (Entity == null)
            {
                return;
            }

            if (Entity is CH47Helicopter)
            {
                CH47Helicopter ch47 = (CH47Helicopter)Entity;

                if (!IsInLivableArea(ch47.transform.position))
                {
                    Log($"CH47 spawned out liveable area", logType: LogType.WARNING);
                    Log($"{ch47.transform.position.x}|{ch47.transform.position.y}|{ch47.transform.position.z}", logType: LogType.WARNING);
                    timer.Once(1f, () => { ch47.Kill(); });
                    Vector3 newPostition = GetFixedPosition(ch47.transform.position);
                    timer.Once(2f, () => { SpawnCH47Helicopter(newPostition); });
                }
                else
                {
                    Log($"CH47 spawned in liveable area properly", logType: LogType.INFO);
                    Log($"{ch47.transform.position.x}|{ch47.transform.position.y}|{ch47.transform.position.z}", logType: LogType.INFO);
                }
            }
        }
 void LogCurrentPosition(CH47Helicopter ch47)
 {
     if (ch47 == null || ch47.IsDestroyed)
     {
         return;
     }
     Log($"Current position: {ch47.transform.position.x}|{ch47.transform.position.y}|{ch47.transform.position.z} ", logType: LogType.INFO);
 }
Example #3
0
        private bool CanShowPanel(CH47Helicopter heli)
        {
            object result = Interface.Call("MagicPanelCanShow", Name, heli);

            if (result is bool)
            {
                return((bool)result);
            }

            return(true);
        }
Example #4
0
////////////////////// ON KILL - chat owner /////////////////////

        void OnEntityKill(BaseNetworkable entity)
        {
            if (entity == null)
            {
                return;
            }
            if (entity.net.ID == null)
            {
                return;
            }
            CH47Helicopter check = entity as CH47Helicopter;

            if (check == null)
            {
                return;
            }
            if (storedData.playerch47 == null)
            {
                return;
            }
            ulong todelete = new ulong();

            if (storedData.playerch47.ContainsValue(entity.net.ID) == false)
            {
                if (debug == true)
                {
                    Puts($"KILLED CH47 not from myCH47");
                }
                normalch47kill = true;
                timer.Once(6f, () =>
                {
                    normalch47kill = false;
                });
            }
            foreach (var item in storedData.playerch47)
            {
                if (item.Value == entity.net.ID)
                {
                    ChatPlayerOnline(item.Key, "killed");
                    foreach (BasePlayer player in BasePlayer.activePlayerList.ToList())
                    {
                        if (player.userID == item.Key)
                        {
                            baseplayerch47.Remove(player);
                        }
                    }
                    todelete = item.Key;
                }
            }
            if (todelete != null)
            {
                storedData.playerch47.Remove(todelete);
            }
        }
Example #5
0
        private void OnEntitySpawned(CH47Helicopter heli)
        {
            NextTick(() =>
            {
                if (!CanShowPanel(heli))
                {
                    return;
                }

                _activeCh47.Add(heli);
                CheckCh47();
            });
        }
Example #6
0
        void ChinookHover(BasePlayer player, CH47Helicopter chinook)
        {
            if (!helicopterHovering.ContainsKey(chinook.GetInstanceID()))
            {
                helicopterHovering.Add(chinook.GetInstanceID(), false);
            }

            Rigidbody rb = chinook.GetComponent <Rigidbody>();

            if (rb == null)
            {
                PrintWarning(lang.GetMessage("RigidbodyNull", this, null));

                PrintToChat(player, lang.GetMessage("ErrorFound", this, player.UserIDString));

                return;
            }

            if (!helicopterHovering[chinook.GetInstanceID()])
            {
                helicopterHovering[chinook.GetInstanceID()] = true;

                rb.constraints = RigidbodyConstraints.FreezePositionY;

                if (!_config.Hovering.enableRotationOnHover)
                {
                    rb.freezeRotation = true;
                }

                PrintToChat(player, lang.GetMessage("HelicopterEnabled", this, player.UserIDString));
            }
            else
            {
                helicopterHovering[chinook.GetInstanceID()] = false;

                rb.constraints = RigidbodyConstraints.None;

                rb.freezeRotation = false;

                PrintToChat(player, lang.GetMessage("HelicopterDisabled", this, player.UserIDString));
            }
        }
Example #7
0
 public void BeginEvent(CH47Helicopter chinook)
 {
     Instance.Puts($"Beginning chinook event, heli at @ {chinook.transform.position}");
     ChinookHelicopters.Add(chinook);
 }
Example #8
0
        void Hover(BasePlayer player)
        {
            if (permission.UserHasPermission(player.UserIDString, canHover) && player.GetMountedVehicle() != null)
            {
                BaseVehicle playerVehicle = player.GetMountedVehicle();

                if (_config.Permission.passengerToggle || !_config.Permission.passengerToggle && playerVehicle.GetDriver() == player)
                {
                    if (player.isMounted && playerVehicle.ShortPrefabName == "minicopter.entity" ||
                        playerVehicle.ShortPrefabName == "scraptransporthelicopter" && _config.Permission.scrapheliCanHover ||
                        playerVehicle.ShortPrefabName == "ch47.entity" && _config.Permission.chinookCanHover)
                    {
                        MiniCopter minicopter = playerVehicle as MiniCopter;

                        //Chinook
                        if (minicopter == null && playerVehicle.ShortPrefabName == "ch47.entity")
                        {
                            CH47Helicopter chinook = playerVehicle as CH47Helicopter;

                            if (chinook != null)
                            {
                                if (_config.Permission.enableHoverWithTwoOccupants)
                                {
                                    ChinookHover(player, chinook);
                                    return;
                                }
                                else
                                {
                                    if (chinook.NumMounted() >= 2)
                                    {
                                        PrintToChat(player, lang.GetMessage("CantHoverTwoOccupants", this, player.UserIDString));

                                        return;
                                    }
                                }
                            }
                        }

                        if (minicopter != null)
                        {
                            if (minicopter.IsEngineOn() && minicopter.isMobile || minicopter.isMobile && minicopter.GetDriver() != player)
                            {
                                if (_config.Permission.enableHoverWithTwoOccupants)
                                {
                                    ToggleHover(player, minicopter);
                                }
                                else
                                {
                                    if (minicopter.NumMounted() >= 2)
                                    {
                                        PrintToChat(player, lang.GetMessage("CantHoverTwoOccupants", this, player.UserIDString));

                                        return;
                                    }
                                }
                            }
                            else
                            {
                                PrintToChat(player, lang.GetMessage("NotFlying", this, player.UserIDString));
                            }
                        }
                        else
                        {
                            PrintWarning(lang.GetMessage("HelicopterNull", this, player.UserIDString));

                            PrintToChat(player, lang.GetMessage("ErrorFound", this, player.UserIDString));

                            return;
                        }
                    }
                    else
                    {
                        if (!player.isMounted)
                        {
                            PrintToChat(lang.GetMessage("NotMounted", this, player.UserIDString));
                        }

                        if (playerVehicle is MiniCopter == false)
                        {
                            PrintToChat(player, lang.GetMessage("NotInHelicopter", this, player.UserIDString));
                        }
                    }
                }
            }
            else if (player.GetMountedVehicle() == null)
            {
                PrintToChat(player, lang.GetMessage("NotInHelicopter", this, player.UserIDString));
            }
            else
            {
                PrintToChat(player, lang.GetMessage("NoPermission", this, player.UserIDString));
            }
        }