Exemple #1
0
 public void ToggleNavigation()
 {
     if (drivingOffroad)
     {
         //offroad driving script should handle that separately
         OffroadPlanning.setNextTarget();
         triedRestartingAutodrive = false;
     }
     else
     {
         MethodInfo inf = kh.GetType().GetMethod("AtToggleAutopilot", BindingFlags.NonPublic | BindingFlags.Instance);
         inf.Invoke(kh, new object[] { new KeyEventArgs(Keys.J) });
     }
 }
Exemple #2
0
        public void ReloadGame()
        {
            if (staticCamera)
            {
                return;
            }

            clearStuckCheckers();

            /*
             * Process p = Process.GetProcessesByName("Grand Theft Auto V").FirstOrDefault();
             * if (p != null)
             * {
             *  IntPtr h = p.MainWindowHandle;
             *  SetForegroundWindow(h);
             *  SendKeys.SendWait("{ESC}");
             *  //Script.Wait(200);
             * }
             */
            // or use CLEAR_AREA_OF_VEHICLES
            Ped player = Game.Player.Character;

            //UINotify("x = " + player.Position.X + "y = " + player.Position.Y + "z = " + player.Position.Z);
            // no need to release the autodrive here
            // delete all surrounding vehicles & the driver's car
//            ClearSurroundingVehicles(player.Position, 1000f);
            player.LastVehicle.Delete();
            // teleport to the spawning position, defined in GameUtils.cs, subject to changes
//            player.Position = GTAConst.OriginalStartPos;
            if (drivingOffroad)
            {
                OffroadPlanning.setNextStart();
                OffroadPlanning.setNextTarget();
            }
            else
            {
                player.Position = GTAConst.HighwayStartPos;
            }
//            ClearSurroundingVehicles(player.Position, 100f);
//            ClearSurroundingVehicles(player.Position, 50f);
            ClearSurroundingVehicles(player.Position, 20f);
            // start a new run
            EnterVehicle();
            //Script.Wait(2000);
            ToggleNavigation();

            lowSpeedTime.clear();
        }
Exemple #3
0
        public void OnTick(object o, EventArgs e)
        {
            if (server.Poll(10, SelectMode.SelectRead) && connection == null)
            {
                connection = server.Accept();
                UINotify("CONNECTED");
                connection.Blocking = false;
            }

            HandlePipeInput();
            if (!enabled)
            {
                return;
            }

            //Array values = Enum.GetValues(typeof(Weather));


            switch (checkStatus())
            {
            case GameStatus.NeedReload:
                Logger.WriteLine("Status is NeedReload");
                StopRun();
                runTask?.Wait();
                runTask = StartRun();
                //StopSession();
                //Autostart();
                UINotify("need reload game");
                Wait(100);
                ReloadGame();
                break;

            case GameStatus.NeedStart:
                Logger.WriteLine("Status is NeedStart");
                //Autostart();
                // use reloading temporarily
                StopRun();

                ReloadGame();
                Wait(100);
                runTask?.Wait();
                runTask = StartRun();
                //Autostart();
                break;

            case GameStatus.NoActionNeeded:
                break;
            }

//            UINotify("runTask.IsCompleted: " + runTask.IsCompleted.ToString());
//            UINotify("postgresTask.IsCompleted: " + postgresTask.IsCompleted.ToString());
            if (!runTask.IsCompleted)
            {
                return;
            }
            if (!postgresTask.IsCompleted)
            {
                return;
            }

            if (drivingOffroad && OffroadPlanning.offroadDrivingStarted)
            {
                OffroadPlanning.checkDrivingToTarget();
                OffroadPlanning.setNextTarget();
            }

//            UINotify("going to save images and save to postgres");

            if (gatheringData)
            {
                try {
                    GamePause(true);
                    gatherData();
                    GamePause(false);
                }
                catch (Exception exception) {
                    GamePause(false);
                    Logger.WriteLine("exception occured, logging and continuing");
                    Logger.WriteLine(exception);
                }
            }

//            if time interval is enabled, checkes game time and sets it to timeFrom, it current time is after timeTo
            if (timeIntervalEnabled)
            {
                var currentTime = World.CurrentDayTime;
                if (currentTime > timeTo)
                {
                    World.CurrentDayTime = timeFrom;
                }
            }
        }