コード例 #1
0
 public static bool IsKeyCombinationDownRightNowComputerCheck(Keys MainKey, Keys ModifierKey)
 {
     if (MainKey != Keys.None)
     {
         return(ExtensionMethods.IsKeyDownRightNowComputerCheck(MainKey) && ((ExtensionMethods.IsKeyDownRightNowComputerCheck(ModifierKey) ||
                                                                              (ModifierKey == Keys.None && !ExtensionMethods.IsKeyDownRightNowComputerCheck(Keys.Shift) && !ExtensionMethods.IsKeyDownRightNowComputerCheck(Keys.Control) &&
                                                                               !ExtensionMethods.IsKeyDownRightNowComputerCheck(Keys.LControlKey) && !ExtensionMethods.IsKeyDownRightNowComputerCheck(Keys.LShiftKey)))));
     }
     else
     {
         return(false);
     }
 }
コード例 #2
0
        internal static void MainLoop()
        {
            Game.LogTrivial("Custom Pullover.Mainloop started");

            Game.LogTrivial("Loading Custom Pullover settings...");
            LoadValuesFromIniFile();

            IsSomeoneFollowing       = false;
            IsSomeoneRunningTheLight = false;

            GameFiber.StartNew(delegate
            {
                while (true)
                {
                    GameFiber.Yield();
                    if (Functions.IsPlayerPerformingPullover())
                    {
                        if (ExtensionMethods.IsKeyDownRightNowComputerCheck(TrafficStopFollowModifierKey) || (TrafficStopFollowModifierKey == Keys.None))
                        {
                            if (ExtensionMethods.IsKeyDownComputerCheck(TrafficStopFollowKey))
                            {
                                if (!IsSomeoneFollowing)
                                {
                                    TrafficStopAssist.FollowMe();
                                }
                                else
                                {
                                    IsSomeoneFollowing = false;
                                }
                            }
                        }
                        if (ExtensionMethods.IsKeyDownRightNowComputerCheck(TrafficStopMimicModifierKey) || (TrafficStopMimicModifierKey == Keys.None))
                        {
                            if (ExtensionMethods.IsKeyDownComputerCheck(TrafficStopMimicKey))
                            {
                                if (!IsSomeoneFollowing)
                                {
                                    TrafficStopAssist.MimicMe();
                                }
                                else
                                {
                                    IsSomeoneFollowing = false;
                                }
                            }
                        }
                        if (ExtensionMethods.IsKeyDownRightNowComputerCheck(CustomPulloverLocationModifierKey) || (CustomPulloverLocationModifierKey == Keys.None))
                        {
                            if (ExtensionMethods.IsKeyDownComputerCheck(CustomPulloverLocationKey))
                            {
                                if (!IsSomeoneFollowing)
                                {
                                    TrafficStopAssist.SetCustomPulloverLocation();
                                }
                                else
                                {
                                    Game.LogTrivial("Already doing custom pullover location.");
                                }
                            }
                        }

                        if (!IsSomeoneRunningTheLight)
                        {
                            TrafficStopAssist.CheckForceRedLightRun();
                        }
                    }
                }
            });

            while (true)
            {
                GameFiber.Yield();
                TrafficStopAssist.CheckForYieldDisable();
                if (AutoVehicleDoorLock)
                {
                    TrafficStopAssist.LockPlayerDoors();
                }

                //VehicleDetails.CheckForTextEntry();
            }
        }
コード例 #3
0
        public static void SetCustomPulloverLocation()
        {
            CustomPulloverHandler.IsSomeoneFollowing = true;
            GameFiber.StartNew(delegate
            {
                try
                {
                    if (!Functions.IsPlayerPerformingPullover())
                    {
                        CustomPulloverHandler.IsSomeoneFollowing = false;
                        return;
                    }

                    if (!Game.LocalPlayer.Character.IsInAnyVehicle(false))
                    {
                        CustomPulloverHandler.IsSomeoneFollowing = false;
                        return;
                    }
                    Vehicle playerCar  = Game.LocalPlayer.Character.CurrentVehicle;
                    Vehicle stoppedCar = (Vehicle)World.GetClosestEntity(playerCar.GetOffsetPosition(Vector3.RelativeFront * 8f), 8f, (GetEntitiesFlags.ConsiderGroundVehicles | GetEntitiesFlags.ConsiderBoats | GetEntitiesFlags.ExcludeEmptyVehicles | GetEntitiesFlags.ExcludeEmergencyVehicles));
                    if (stoppedCar == null)
                    {
                        Game.DisplayNotification("Unable to detect the pulled over vehicle. Make sure you're behind the vehicle and try again.");
                        CustomPulloverHandler.IsSomeoneFollowing = false;
                        return;
                    }
                    if (!stoppedCar.IsValid() || (stoppedCar == playerCar))
                    {
                        Game.DisplayNotification("Unable to detect the pulled over vehicle. Make sure you're behind the vehicle and try again.");
                        CustomPulloverHandler.IsSomeoneFollowing = false;
                        return;
                    }
                    if (stoppedCar.Speed > 0.2f && !ExtensionMethods.IsPointOnWater(stoppedCar.Position))
                    {
                        Game.DisplayNotification("The vehicle must be stopped before you can do this.");
                        CustomPulloverHandler.IsSomeoneFollowing = false;
                        return;
                    }
                    string modelName = stoppedCar.Model.Name.ToLower();
                    if (numbers.Contains <string>(modelName.Last().ToString()))
                    {
                        modelName = modelName.Substring(0, modelName.Length - 1);
                    }
                    modelName        = char.ToUpper(modelName[0]) + modelName.Substring(1);
                    Ped pulledDriver = stoppedCar.Driver;
                    if (!pulledDriver.IsPersistent || Functions.GetPulloverSuspect(Functions.GetCurrentPullover()) != pulledDriver)
                    {
                        Game.DisplayNotification("Unable to detect the pulled over vehicle. Make sure you're in front of the vehicle and try again.");
                        CustomPulloverHandler.IsSomeoneFollowing = false;
                        return;
                    }

                    Blip blip = pulledDriver.AttachBlip();
                    blip.Flash(500, -1);
                    blip.Color = System.Drawing.Color.Aqua;
                    playerCar.BlipSiren(true);
                    Vector3 CheckPointPosition = Game.LocalPlayer.Character.GetOffsetPosition(new Vector3(0f, 8f, -1f));
                    CheckPoint         = NativeFunction.Natives.CREATE_CHECKPOINT <int>(46, CheckPointPosition.X, CheckPointPosition.Y, CheckPointPosition.Z, CheckPointPosition.X, CheckPointPosition.Y, CheckPointPosition.Z, 3.5f, 255, 0, 0, 255, 0);;
                    float xOffset      = 0;
                    float yOffset      = 0;
                    float zOffset      = 0;
                    bool SuccessfulSet = false;
                    while (true)
                    {
                        GameFiber.Wait(70);
                        Game.DisplaySubtitle("Set your desired pullover location. Hold ~b~Enter ~s~when done.", 100);
                        CheckPointPosition = Game.LocalPlayer.Character.GetOffsetPosition(new Vector3((float)xOffset + 0.5f, (float)(yOffset + 8), (float)(-1 + zOffset)));
                        if (!CustomPulloverHandler.IsSomeoneFollowing)
                        {
                            break;
                        }
                        if (!Functions.IsPlayerPerformingPullover())
                        {
                            Game.DisplayNotification("You cancelled the ~b~Traffic Stop.");
                            break;
                        }
                        if (!Game.LocalPlayer.Character.IsInVehicle(playerCar, false))
                        {
                            break;
                        }

                        if (ExtensionMethods.IsKeyDownRightNowComputerCheck(IniDefaults.PositionResetKey))
                        {
                            xOffset = 0;
                            yOffset = 0;
                            zOffset = 0;
                        }
                        if (ExtensionMethods.IsKeyDownRightNowComputerCheck(IniDefaults.PositionForwardKey))
                        {
                            yOffset++;
                        }
                        if (ExtensionMethods.IsKeyDownRightNowComputerCheck(IniDefaults.PositionBackwardKey))
                        {
                            yOffset--;
                        }
                        if (ExtensionMethods.IsKeyDownRightNowComputerCheck(IniDefaults.PositionRightKey))
                        {
                            xOffset++;
                        }
                        if (ExtensionMethods.IsKeyDownRightNowComputerCheck(IniDefaults.PositionLeftKey))
                        {
                            xOffset--;
                        }
                        if (ExtensionMethods.IsKeyDownRightNowComputerCheck(IniDefaults.PositionUpKey))
                        {
                            zOffset++;
                        }
                        if (ExtensionMethods.IsKeyDownRightNowComputerCheck(IniDefaults.PositionDownKey))
                        {
                            zOffset--;
                        }
                        if (ExtensionMethods.IsKeyDownRightNowComputerCheck(Keys.Enter))
                        {
                            SuccessfulSet = true;
                            break;
                        }


                        NativeFunction.Natives.DELETE_CHECKPOINT(CheckPoint);
                        CheckPoint = NativeFunction.Natives.CREATE_CHECKPOINT <int>(46, CheckPointPosition.X, CheckPointPosition.Y, CheckPointPosition.Z, CheckPointPosition.X, CheckPointPosition.Y, CheckPointPosition.Z, 3f, 255, 0, 0, 255, 0);
                        NativeFunction.Natives.SET_CHECKPOINT_CYLINDER_HEIGHT(CheckPoint, 2f, 2f, 2f);
                    }
                    NativeFunction.Natives.DELETE_CHECKPOINT(CheckPoint);
                    if (SuccessfulSet)
                    {
                        try
                        {
                            Game.LocalPlayer.Character.Tasks.PlayAnimation("friends@frj@ig_1", "wave_c", 1f, AnimationFlags.SecondaryTask | AnimationFlags.UpperBodyOnly);
                        }
                        catch { }
                        while (true)
                        {
                            GameFiber.Yield();
                            if (Vector3.Distance(pulledDriver.Position, Game.LocalPlayer.Character.Position) > 25f)
                            {
                                Game.DisplaySubtitle("~h~~r~Stay close to the vehicle.", 700);
                            }

                            if (!Functions.IsPlayerPerformingPullover())
                            {
                                Game.DisplayNotification("You cancelled the ~b~Traffic Stop.");
                                break;
                            }
                            if (!Game.LocalPlayer.Character.IsInVehicle(playerCar, false))
                            {
                                break;
                            }
                            if (!CustomPulloverHandler.IsSomeoneFollowing)
                            {
                                break;
                            }
                            Rage.Task drivetask = pulledDriver.Tasks.DriveToPosition(CheckPointPosition, 12f, VehicleDrivingFlags.DriveAroundVehicles | VehicleDrivingFlags.DriveAroundObjects | VehicleDrivingFlags.AllowMedianCrossing | VehicleDrivingFlags.YieldToCrossingPedestrians);
                            GameFiber.Wait(700);
                            if (!drivetask.IsActive)
                            {
                                break;
                            }
                            if (Vector3.Distance(pulledDriver.Position, CheckPointPosition) < 1.5f)
                            {
                                break;
                            }
                        }

                        Game.LogTrivial("Done custom pullover location");
                        if (stoppedCar.Exists())
                        {
                            if (pulledDriver.Exists())
                            {
                                pulledDriver.Tasks.PerformDrivingManeuver(VehicleManeuver.Wait);
                            }
                        }

                        if (blip.Exists())
                        {
                            blip.Delete();
                        }
                    }
                }
                catch (Exception e)
                {
                    NativeFunction.Natives.DELETE_CHECKPOINT(CheckPoint);
                    if (blip.Exists())
                    {
                        blip.Delete();
                    }
                    Game.LogTrivial(e.ToString());
                    Game.LogTrivial("CustomPulloverLocationError handled.");
                }
                finally
                {
                    CustomPulloverHandler.IsSomeoneFollowing = false;
                }
            });
        }