예제 #1
0
 /// <summary>
 /// Sets whether the ped is over the alcohol limit or not.
 /// </summary>
 /// <param name="ped"></param>
 /// <param name="OverTheAlcoholLimit">If true, sets ped as over the limit. If false, sets ped as under the limit.</param>
 public static void SetPedAlcoholLevel(Ped ped, bool OverTheAlcoholLimit)
 {
     if (OverTheAlcoholLimit)
     {
         Breathalyzer.SetPedAlcoholLevels(ped, Breathalyzer.GetRandomOverTheLimitAlcoholLevel());
     }
     else
     {
         Breathalyzer.SetPedAlcoholLevels(ped, Breathalyzer.GetRandomUnderTheLimitAlcoholLevel());
     }
 }
예제 #2
0
 /// <summary>
 /// Returns true if ped is over the alcohol limit.
 /// </summary>
 /// <param name="ped"></param>
 /// <returns></returns>
 public static bool IsPedOverTheAlcoholLimit(Ped ped)
 {
     return(Breathalyzer.IsPedOverTheLimit(ped));
 }
예제 #3
0
 /// <summary>
 /// Returns a random alcohol level that's under the limit. Higher alcohol limits have a lower chance of being returned.
 /// </summary>
 /// <returns></returns>
 public static AlcoholLevels GetRandomUnderTheLimitAlcoholLevel()
 {
     return(Breathalyzer.GetRandomUnderTheLimitAlcoholLevel());
 }
예제 #4
0
 /// <summary>
 /// Sets the alcohol level for the ped. Used by Traffic Policer's Breathalyzer. Automatically converts the AlcoholLevel to an appropriate reading depending on the player's personal alcohol limit.
 /// </summary>
 /// <param name="ped"></param>
 /// <param name="AlcoholLevel"></param>
 public static void SetPedAlcoholLevel(Ped ped, AlcoholLevels AlcoholLevel)
 {
     Breathalyzer.SetPedAlcoholLevels(ped, AlcoholLevel);
 }
        private void SituationDrunk()
        {
            GameFiber.StartNew(delegate
            {
                try
                {
                    Impairment_Tests.Breathalyzer.SetPedAlcoholLevels(driver, Breathalyzer.GetRandomOverTheLimitAlcoholLevel());
                    beforeTrafficStopDrive();
                    //Game.DisplayNotification("3dtextures", "mpgroundlogo_cops", "Traffic Policer", "DUI", "Test the person for illegal substances. If);

                    while (CalloutRunning)
                    {
                        GameFiber.Yield();
                        if (Vector3.Distance(Game.LocalPlayer.Character.Position, car.Position) < 4.5f && !Game.LocalPlayer.Character.IsInAnyVehicle(false))
                        {
                            if (TrafficPolicerHandler.rnd.Next(5) == 0 && Functions.GetActivePursuit() == null)
                            {
                                //Game.DisplayNotification("There's a " + (driver.IsMale ? "man" : "woman") + " on the deck.");
                                Pursuit = Functions.CreatePursuit();

                                Functions.AddPedToPursuit(Pursuit, driver);
                                Functions.SetPursuitIsActiveForPlayer(Pursuit, true);
                                Functions.ForceEndCurrentPullover();
                            }
                            break;
                        }
                        if (Functions.GetActivePursuit() != null)
                        {
                            if (Functions.GetPursuitPeds(Functions.GetActivePursuit()).Contains(driver))
                            {
                                Pursuit        = Functions.GetActivePursuit();
                                PursuitCreated = true;
                                break;
                            }
                        }
                    }
                    while (CalloutRunning)
                    {
                        GameFiber.Yield();
                        if (!driver.Exists())
                        {
                            Game.LogTrivial("Driver doesn't exist.");
                            break;
                        }
                        else if (Functions.IsPedArrested(driver))
                        {
                            break;
                        }
                        else if (driver.IsDead)
                        {
                            break;
                        }
                        else if (PursuitCreated)
                        {
                            if (Functions.GetActivePursuit() == null)
                            {
                                Game.LogTrivial("Active pursuit end..");
                                break;
                            }
                        }
                    }
                    DisplayCodeFourMessage();
                }
                catch (System.Threading.ThreadAbortException e)
                {
                    End();
                }

                catch (Exception e)
                {
                    if (CalloutRunning)
                    {
                        Game.LogTrivial(e.ToString());
                        Game.LogTrivial("Traffic Policer handled the exception successfully.");
                        Game.DisplayNotification("~O~DUI ~s~callout crashed, sorry. Please send me your log file.");
                        Game.DisplayNotification("Full LSPDFR crash prevented ~g~successfully.");
                        End();
                    }
                }
            });
        }