Ejemplo n.º 1
0
        public static bool TryCreatePlayerStrobedVehicle()
        {
            Vehicle[] possibleVehs = { playerPed.CurrentVehicle, playerPed.LastVehicle, playerPed.VehicleTryingToEnter };
            for (int i = 0; i < possibleVehs.Length; i++)
            {
                Vehicle v = possibleVehs[i];
                if (v && v.HasSiren && !Settings.ExcludedVehicleModels.Any(m => v.Model == m))
                {
                    PlayerStrobedVehicle = new PlayerStrobedVehicle(v, Settings.Patterns);
                    return(true);
                }
            }
            possibleVehs = null;

            return(false);
        }
Ejemplo n.º 2
0
        private static void OnUnload(bool b)
        {
            if (StrobedVehicles != null)
            {
                foreach (StrobedVehicle v in StrobedVehicles)
                {
                    v?.Dispose();
                }
                StrobedVehicles.Clear();
                StrobedVehicles = null;
            }

            PlayerStrobedVehicle?.Dispose();
            PlayerStrobedVehicle = null;

            Settings.SwitchSound?.Dispose();
        }
Ejemplo n.º 3
0
        private static void Main()
        {
            while (Game.IsLoading)
            {
                GameFiber.Sleep(250);
            }

            while (true)
            {
                GameFiber.Yield();

                GameTime  = Game.GameTime;
                playerPed = Game.LocalPlayer.Character;
                playerPos = playerPed.Position;

                if (Settings.AIEnabled)
                {
                    if ((DateTime.UtcNow - lastVehiclesCheckTime).TotalSeconds > 1.5)
                    {
                        Entity[] vehs = World.GetEntities(playerPos, ActionRadius, GetEntitiesFlags.ConsiderAllVehicles);

                        for (int i = 0; i < vehs.Length; i++)
                        {
                            Vehicle v = (Vehicle)vehs[i];
                            if (CanBeStrobedVehicle(v))
                            {
                                StrobedVehicles.Add(new StrobedVehicle(v, Settings.Patterns[Random.Next(Settings.Patterns.Length)]));
                            }
                        }
                        lastVehiclesCheckTime = DateTime.UtcNow;
                    }


                    for (int i = StrobedVehicles.Count - 1; i >= 0; i--)
                    {
                        StrobedVehicle v = StrobedVehicles[i];
                        if (v == null || !v.Vehicle || v.Vehicle == playerPed.CurrentVehicle || Vector3.DistanceSquared(v.Vehicle.Position, playerPos) > ActionRadiusSqr)
                        {
                            if (v != null)
                            {
                                v.Dispose();
                            }
                            StrobedVehicles.RemoveAt(i);
                            continue;
                        }

                        v.Update();
                    }
                }


                if (Settings.PlayerEnabled)
                {
                    if (PlayerStrobedVehicle == null)
                    {
                        TryCreatePlayerStrobedVehicle();
                    }
                    else if (!PlayerStrobedVehicle.Vehicle)
                    {
                        PlayerStrobedVehicle.Dispose();
                        PlayerStrobedVehicle = null;
                    }
                    else if (playerPed.IsInAnyVehicle(false) && PlayerStrobedVehicle.Vehicle != playerPed.CurrentVehicle)
                    {
                        PlayerStrobedVehicle.Dispose();
                        PlayerStrobedVehicle = null;
                        TryCreatePlayerStrobedVehicle();
                    }

                    PlayerStrobedVehicle?.Update();
                }
            }
        }
Ejemplo n.º 4
0
        private static void OnUnload(bool b)
        {
            if (StrobedVehicles != null)
            {
                foreach (StrobedVehicle v in StrobedVehicles)
                {
                    v?.Dispose();
                }
                StrobedVehicles.Clear();
                StrobedVehicles = null;
            }

            PlayerStrobedVehicle?.Dispose();
            PlayerStrobedVehicle = null;

            Settings.SwitchSound?.Dispose();
        }
Ejemplo n.º 5
0
        private static void Main()
        {
            while (Game.IsLoading)
                GameFiber.Sleep(250);
            
            while (true)
            {
                GameFiber.Yield();

                GameTime = Game.GameTime;
                playerPed = Game.LocalPlayer.Character;
                playerPos = playerPed.Position;

                if (Settings.AIEnabled)
                {
                    if ((DateTime.UtcNow - lastVehiclesCheckTime).TotalSeconds > 1.5)
                    {
                        Entity[] vehs = World.GetEntities(playerPos, ActionRadius, GetEntitiesFlags.ConsiderAllVehicles);

                        for (int i = 0; i < vehs.Length; i++)
                        {
                            Vehicle v = (Vehicle)vehs[i];
                            if (CanBeStrobedVehicle(v))
                            {
                                StrobedVehicles.Add(new StrobedVehicle(v, Settings.Patterns[Random.Next(Settings.Patterns.Length)]));
                            }
                        }
                        lastVehiclesCheckTime = DateTime.UtcNow;
                    }

                    
                    for (int i = StrobedVehicles.Count - 1; i >= 0; i--)
                    {
                        StrobedVehicle v = StrobedVehicles[i];
                        if (v == null || !v.Vehicle || v.Vehicle == playerPed.CurrentVehicle || Vector3.DistanceSquared(v.Vehicle.Position, playerPos) > ActionRadiusSqr)
                        {
                            if (v != null)
                                v.Dispose();
                            StrobedVehicles.RemoveAt(i);
                            continue;
                        }

                        v.Update();
                    }
                }


                if (Settings.PlayerEnabled)
                {
                    if (PlayerStrobedVehicle == null)
                    {
                        TryCreatePlayerStrobedVehicle();
                    }
                    else if (!PlayerStrobedVehicle.Vehicle)
                    {
                        PlayerStrobedVehicle.Dispose();
                        PlayerStrobedVehicle = null;
                    }
                    else if (playerPed.IsInAnyVehicle(false) && PlayerStrobedVehicle.Vehicle != playerPed.CurrentVehicle)
                    {
                        PlayerStrobedVehicle.Dispose();
                        PlayerStrobedVehicle = null;
                        TryCreatePlayerStrobedVehicle();
                    }

                    PlayerStrobedVehicle?.Update();
                }
            }
        }
Ejemplo n.º 6
0
        public static bool TryCreatePlayerStrobedVehicle()
        {
            Vehicle[] possibleVehs = { playerPed.CurrentVehicle, playerPed.LastVehicle, playerPed.VehicleTryingToEnter };
            for (int i = 0; i < possibleVehs.Length; i++)
            {
                Vehicle v = possibleVehs[i];
                if (v && v.HasSiren && !Settings.ExcludedVehicleModels.Any(m => v.Model == m))
                {
                    PlayerStrobedVehicle = new PlayerStrobedVehicle(v, Settings.Patterns);
                    return true;
                }
            }
            possibleVehs = null;

            return false;
        }