示例#1
0
        private async void CruiseAtSpeed(float s)
        {
            while (_cruising)
            {
                Vehicle v = Game.PlayerPed?.CurrentVehicle;

                if (v != null)
                {
                    v.Speed      = s; // try: void SetDriveTaskCruiseSpeed(int /* Ped */ driver, float cruiseSpeed);
                    v.CurrentRPM = _rpm;

                    if (v.Driver == null || v.Driver != Game.PlayerPed || v.IsInWater || v.IsInBurnout || !v.IsEngineRunning ||
                        v.IsInAir || v.HasCollided ||
                        GTASpeedToMPH(v.Speed) <= 25f || GTASpeedToMPH(v.Speed) >= 100f ||
                        HaveAnyTiresBurst(v) ||
                        Game.IsControlPressed(0, Control.VehicleHandbrake) || Game.IsDisabledControlPressed(0, Control.VehicleHandbrake) ||
                        Game.IsControlPressed(0, Control.VehicleBrake) || Game.IsDisabledControlPressed(0, Control.VehicleBrake))
                    { // Disable cruise if any of these.... ^
                        _cruising = false;
                    }

                    if (Game.IsControlPressed(0, Control.VehicleAccelerate) ||
                        Game.IsDisabledControlPressed(0, Control.VehicleAccelerate))
                    { // Accelerating to new speed..
                        AcceleratingToNewSpeed();
                    }
                }
                else
                {
                    return;
                }

                await Delay(0);
            }
        }
示例#2
0
        private async void AcceleratingToNewSpeed()
        {
            _cruising = false;

            while ((Game.IsControlPressed(0, Control.VehicleAccelerate) ||
                    Game.IsDisabledControlPressed(0, Control.VehicleAccelerate)) &&
                   Game.PlayerPed.CurrentVehicle != null)
            {
                await Delay(500); // Wait for client to stop accelerating.
            }

            if (Game.PlayerPed.CurrentVehicle != null)
            {
                _cruising = true;
                CruiseAtSpeed(Game.PlayerPed.CurrentVehicle.Speed); // Cruise at new speed.
            }
        }
示例#3
0
        private async void CruiseAtSpeed(float s)
        {
            while (_cruising)
            {
                if (Game.PlayerPed.CurrentVehicle == null)
                { // Current veh no longer exists, no longer in a veh, stop cruising.
                    _cruising = false;
                    break;
                }
                else
                { // Set speed of veh to the cruise speed infinently.
                    Vehicle v = Game.PlayerPed.CurrentVehicle;

                    v.Speed      = s;
                    v.CurrentRPM = 0.5f;

                    if (v.IsInWater || v.IsInBurnout || !v.IsEngineRunning || v.Driver == null ||
                        v.Driver != Game.PlayerPed ||
                        v.IsInAir || v.HasCollided ||
                        GTASpeedToMPH(v.Speed) <= 25f || GTASpeedToMPH(v.Speed) >= 100f ||
                        HaveAnyTiresBurst(v) ||
                        Game.IsControlPressed(0, Control.VehicleHandbrake) ||
                        Game.IsControlPressed(0, Control.VehicleBrake))
                    { // Disable cruise if any of these.... ^
                        _cruising = false;
                    }

                    if (Game.IsControlPressed(0, Control.VehicleAccelerate) ||
                        Game.IsDisabledControlPressed(0, Control.VehicleAccelerate))
                    { // Accelerating to new speed..
                        AcceleratingToNewSpeed();
                    }
                }

                await Delay(0);
            }
        }
示例#4
0
        // Handles cutting | saw storage and grab | saw pickup and drop
        private async Task OnTick()
        {
            await Task.FromResult(0);

            if (ScriptReady)
            {
                if (CurrentSaw == null)
                {
                    Vehicle truck = GetVehicleInArea();

                    // Grabbing saw from vehicle
                    if (truck != null)
                    {
                        var CheckedVehicle = CheckCastedVehicle(truck);
                        if (CheckedVehicle != null)
                        {
                            World.DrawMarker(MarkerType.HorizontalCircleSkinny, truck.GetOffsetPosition(CheckedVehicle.MarkerPos), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(1f, 1f, 1f), System.Drawing.Color.FromArgb(255, 0, 0), false, false, true, null, null, false);
                            if (World.GetDistance(LocalPlayer.Character.Position, truck.GetOffsetPosition(CheckedVehicle.MarkerPos)) <= 1.2f)
                            {
                                Screen.DisplayHelpTextThisFrame($"~INPUT_PICKUP~ Retrieve Saw");
                                if (Game.IsControlJustPressed(1, Control.Pickup))
                                {
                                    await RetrieveSaw();
                                }
                            }
                        }
                    }

                    // Pickup Saw From Ground
                    var LocalPedPos        = LocalPlayer.Character.Position;
                    var closestSaw         = API.GetClosestObjectOfType(LocalPedPos.X, LocalPedPos.Y, LocalPedPos.Z, 5f, (uint)API.GetHashKey(SawModel), false, true, true);
                    var closestSawPos      = API.GetEntityCoords(closestSaw, false);
                    var closestSawDistance = World.GetDistance(LocalPedPos, API.GetEntityCoords(closestSaw, false));

                    if (closestSaw != 0 && !LocalPlayer.Character.IsInVehicle() && API.GetEntityAttachedTo(closestSaw) == 0)
                    {
                        World.DrawMarker(MarkerType.HorizontalCircleSkinny, closestSawPos, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(1f, 1f, 1f), System.Drawing.Color.FromArgb(255, 0, 0), false, false, true, null, null, false);
                        if (closestSawDistance <= 1.2f)
                        {
                            Screen.DisplayHelpTextThisFrame($"~INPUT_PICKUP~ Pickup Saw");
                            if (Game.IsControlJustPressed(1, Control.Pickup))
                            {
                                await PickupSaw(closestSaw);
                            }
                        }
                    }
                }
                else
                {
                    Game.DisableControlThisFrame(1, Control.Attack);
                    Game.DisableControlThisFrame(1, Control.Attack2);
                    Game.DisableControlThisFrame(1, Control.Jump);
                    Game.DisableControlThisFrame(1, Control.Aim);
                    Game.DisableControlThisFrame(1, Control.Enter);
                    if (LocalPlayer.Character.Weapons.Current.Hash != WeaponHash.Unarmed)
                    {
                        API.SetCurrentPedWeapon(LocalPlayer.Character.Handle, (uint)WeaponHash.Unarmed, true);
                    }

                    Vehicle truck   = GetVehicleInArea();
                    Vehicle vehicle = GetVehicleFromCast();

                    // Storing saw to vehicle
                    if (truck != null)
                    {
                        var CheckedVehicle = CheckCastedVehicle(truck);
                        if (CheckedVehicle != null)
                        {
                            World.DrawMarker(MarkerType.HorizontalCircleSkinny, truck.GetOffsetPosition(CheckedVehicle.MarkerPos), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(1f, 1f, 1f), System.Drawing.Color.FromArgb(255, 0, 0), false, false, true, null, null, false);
                            if (World.GetDistance(LocalPlayer.Character.Position, truck.GetOffsetPosition(CheckedVehicle.MarkerPos)) <= 1.2f)
                            {
                                Screen.DisplayHelpTextThisFrame($"~INPUT_PICKUP~ Store Saw");
                                if (Game.IsControlJustPressed(1, Control.Pickup))
                                {
                                    StoreSaw();
                                }
                            }
                        }
                    }
                    else
                    {
                        // Dropping Saw
                        if (Game.IsControlJustPressed(1, Control.Detonate))
                        {
                            await DropSaw();
                        }
                    }

                    // Cutting Logic
                    if (KeyHolding && GetClosestDoorBone(vehicleBeingCut) != (VehicleDoorIndex)(-1) && !vehicleBeingCut.Doors[GetClosestDoorBone(vehicleBeingCut)].IsBroken)
                    {
                        if (Game.IsDisabledControlPressed(1, Control.Attack))
                        {
                            if (Game.GameTime > KeyHoldStartTime)
                            {
                                KeyHolding       = false;
                                KeyHoldStartTime = 0;
                                TriggerServerEvent("ExtractionSaw:StopSawCutSync", CurrentSawNetHandle);
                                VehicleDoorIndex doorIndex = GetClosestDoorBone(vehicle);
                                CutDoor(vehicleBeingCut, doorIndex);
                            }
                            BarTimerBar bar = new BarTimerBar("Cutting Door");
                            bar.Percentage = 1f - (float)(((KeyHoldStartTime - Game.GameTime) / 1000) * 0.1m) - 0.1f;
                            bar.Draw(0);
                        }
                        else
                        {
                            KeyHoldStartTime = 0;
                            KeyHolding       = false;
                            TriggerServerEvent("ExtractionSaw:StopSawCutSync", CurrentSawNetHandle);
                        }
                    }
                    else
                    {
                        if (Game.IsDisabledControlPressed(1, Control.Attack) && GetClosestDoorBone(vehicle) != (VehicleDoorIndex)(-1))
                        {
                            KeyHoldStartTime = Game.GameTime + (CutTimer * 1000);
                            vehicleBeingCut  = vehicle;
                            KeyHolding       = true;
                        }
                    }

                    // Saw Particle Syncing
                    if (KeyHolding)
                    {
                        LoopParticles();
                    }
                }
            }
        }
示例#5
0
        private async Task OnTick()
        {
            if (NoClipEnabled)
            {
                var noclipEntity = IsPedInAnyVehicle(PlayerPedId(), false) ? GetVehiclePedIsUsing(PlayerPedId()) : PlayerPedId();

                FreezeEntityPosition(noclipEntity, true);
                SetEntityInvincible(noclipEntity, true);

                Game.DisableControlThisFrame(0, Control.MoveUpOnly);
                Game.DisableControlThisFrame(0, Control.MoveUp);
                Game.DisableControlThisFrame(0, Control.MoveUpDown);
                Game.DisableControlThisFrame(0, Control.MoveDown);
                Game.DisableControlThisFrame(0, Control.MoveDownOnly);
                Game.DisableControlThisFrame(0, Control.MoveLeft);
                Game.DisableControlThisFrame(0, Control.MoveLeftOnly);
                Game.DisableControlThisFrame(0, Control.MoveLeftRight);
                Game.DisableControlThisFrame(0, Control.MoveRight);
                Game.DisableControlThisFrame(0, Control.MoveRightOnly);
                Game.DisableControlThisFrame(0, Control.Cover);
                Game.DisableControlThisFrame(0, Control.MultiplayerInfo);
                Game.DisableControlThisFrame(0, (Control)47);

                //var xoff = 0.0f;
                var yoff = 0.0f;
                var zoff = 0.0f;

                if (Game.CurrentInputMode == InputMode.MouseAndKeyboard)
                {
                    if (Game.IsControlJustPressed(0, Control.Sprint))
                    {
                        CurrentSpeed++;
                        if (CurrentSpeed == Speeds.Count)
                        {
                            CurrentSpeed = 0;
                        }
                    }

                    if (Game.IsDisabledControlPressed(0, Control.MoveUpOnly))
                    {
                        yoff = 0.5f;
                    }
                    if (Game.IsDisabledControlPressed(0, Control.MoveDownOnly))
                    {
                        yoff = -0.5f;
                    }
                    if (Game.IsDisabledControlPressed(0, Control.MoveLeftOnly))
                    {
                        SetEntityHeading(PlayerPedId(), GetEntityHeading(PlayerPedId()) + 3f);
                    }
                    if (Game.IsDisabledControlPressed(0, Control.MoveRightOnly))
                    {
                        SetEntityHeading(PlayerPedId(), GetEntityHeading(PlayerPedId()) - 3f);
                    }
                    if (Game.IsDisabledControlPressed(0, Control.Cover))
                    {
                        zoff = 0.21f;
                    }
                    if (Game.IsDisabledControlPressed(0, Control.MultiplayerInfo))
                    {
                        zoff = -0.21f;
                    }
                    if (Game.IsDisabledControlPressed(0, (Control)47))
                    {
                        NoClipEnabled = false;
                    }
                }

                var newPos = GetOffsetFromEntityInWorldCoords(noclipEntity, 0f, yoff * (CurrentSpeed + 0.5f),
                                                              zoff * (CurrentSpeed + 0.5f));

                var heading = GetEntityHeading(noclipEntity);
                SetEntityVelocity(noclipEntity, 0f, 0f, 0f);
                SetEntityRotation(noclipEntity, 0f, 0f, 0f, 0, false);
                SetEntityHeading(noclipEntity, heading);

                //if (!((yoff > -0.01f && yoff < 0.01f) && (zoff > -0.01f && zoff < 0.01f)))
                {
                    SetEntityCollision(noclipEntity, false, false);
                    SetEntityCoordsNoOffset(noclipEntity, newPos.X, newPos.Y, newPos.Z, true, true, true);
                }

                FreezeEntityPosition(noclipEntity, false);
                SetEntityInvincible(noclipEntity, false);
                SetEntityCollision(noclipEntity, true, true);
            }
            else
            {
                await Delay(100);
            }
        }