Ejemplo n.º 1
0
 private static async Task ProcessMainMenu()
 {
     if (UiMenu != null)
     {
         if (UiMenu.Visible)
         {
             Game.DisableControlThisFrame(0, (Control)157);
             Game.DisableControlThisFrame(0, (Control)158);
         }
     }
     else
     {
         await Delay(10);
     }
 }
Ejemplo n.º 2
0
        private async Task HandleControls()
        {
            if (_p != null)
            {
                Game.DisableControlThisFrame(0, _crControl);

                if (Game.IsControlJustPressed(0, _crControl))
                {
                    ToggleCrouch();
                }
            }
            else
            {
                _p = Game.PlayerPed;
            }
        }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 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();
                    }
                }
            }
        }
 private static async Task SetTick()
 {
     Game.DisableControlThisFrame(0, Control.NextCamera);
 }
Ejemplo n.º 6
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);
            }
        }