Exemplo n.º 1
0
        private async Task Process()
        {
            Vehicle v = Game.PlayerPed?.CurrentVehicle;

            if (v != null)
            {
                Game.DisableControlThisFrame(0, _cruiseKey);

                if ((Game.IsDisabledControlJustReleased(0, _cruiseKey) || Game.IsControlJustReleased(0, _cruiseKey)) &&
                    v.CurrentGear != 0 && !_vehClassesWithoutCruiseControl.Contains(v.ClassType)) // current gear of 0 is reverse.
                {
                    _cruising = !_cruising;

                    if (_cruising)
                    {
                        CruiseAtSpeed(v.Speed);
                        _rpm = v.CurrentRPM;
                    }
                }
            }
            else if (_cruising)
            {
                _cruising = false;
            }
            else
            { // Not in a veh, check periodically.
                await Delay(100);
            }
        }
Exemplo n.º 2
0
        /*
         *
         * List<VehicleClass> vehClassesWithoutCruiseControl = new List<VehicleClass>
         * {
         *  VehicleClass.Cycles,
         *  VehicleClass.Motorcycles,
         *  VehicleClass.Planes,
         *  VehicleClass.Helicopters,
         *  VehicleClass.Boats,
         *  VehicleClass.Trains
         * };
         *
         */

        private async Task Process()
        {
            if (Game.PlayerPed.CurrentVehicle != null)
            { // In a veh.
                Vehicle v = Game.PlayerPed.CurrentVehicle;

                Game.DisableControlThisFrame(0, _cruiseKey);

                if ((Game.IsDisabledControlJustReleased(0, _cruiseKey) || Game.IsControlJustReleased(0, _cruiseKey)) &&
                    Game.CurrentInputMode == InputMode.MouseAndKeyboard && v.CurrentGear != 0) //vehClassesWithoutCruiseControl.IndexOf(_vehClass) != -1
                {                                                                              // Cruise key just released using mouse&keyboard, NOT gamepad.
                    _cruising = !_cruising;                                                    // toggle cruising mode.

                    if (_cruising)
                    {
                        CruiseAtSpeed(v.Speed);
                    }
                }
            }
            else
            { // Not in a veh, check periodically.
                await Delay(1000);
            }
        }