diff --git a/VehicleCollisions/Scenes/CarPetrolLeak.cs b/VehicleCollisions/Scenes/CarPetrolLeak.cs index 0bcec38..75f5c6d 100644 --- a/VehicleCollisions/Scenes/CarPetrolLeak.cs +++ b/VehicleCollisions/Scenes/CarPetrolLeak.cs @@ -54,7 +54,10 @@ public CarPetrolLeak() public string[] Notifications() { return new string[] - { }; + { + "We've received a call a cars petrol tank is leaking.", + "Deal with the leaking tank, tow away the car and cleanup the scene.s" + }; } public Vector3 Coordinates => new Vector3(RandomCoordinates.X, RandomCoordinates.Y, RandomCoordinates.Z); diff --git a/VehicleCollisions/Scenes/MilitaryTransportEngineFailure.cs b/VehicleCollisions/Scenes/MilitaryTransportEngineFailure.cs index cf54c3c..7cfa4be 100644 --- a/VehicleCollisions/Scenes/MilitaryTransportEngineFailure.cs +++ b/VehicleCollisions/Scenes/MilitaryTransportEngineFailure.cs @@ -209,7 +209,7 @@ public async Task RunAdditionalTasks() } } - public async void TheTruckCouldNotBeFixedAndCaughtOnFire() + private async void TheTruckCouldNotBeFixedAndCaughtOnFire() { ShowSubtitle("[Military officer] SHIT! Wrong cable! Put out the fire or run!", 10000); @@ -219,7 +219,7 @@ public async void TheTruckCouldNotBeFixedAndCaughtOnFire() SpawnedCivilianPeds[0].Task.FleeFrom(SpawnedCrashedCars[0].Driver); } - public async void MechanicGetsOverWhelmedByFumes() + private async void MechanicGetsOverWhelmedByFumes() { ShowSubtitle("[Military officer] Ooof... These fumes are not good, I do not feel well..", 10000); @@ -228,7 +228,7 @@ public async void MechanicGetsOverWhelmedByFumes() SetEntityHealth(SpawnedCivilianPeds[0].Handle, 0); } - public async void MilitaryGetsAttacked() + private async void MilitaryGetsAttacked() { ShowNotification("[Dispatch] We've received a call a suspicious vehicle is heading towards your location."); ShowNotification("[Dispatch] We marked the vehicle on your map, check out the vehicle."); @@ -268,7 +268,7 @@ await _vehicleCollisions._SpawnVehicle(BadGuyVehicles[Utilities.Between(0, BadGu SpawnedCivilianPeds[0].AlwaysKeepTask = true; } - public async void TheTruckIsFixedAndCanDriveAway() + private async void TheTruckIsFixedAndCanDriveAway() { ShowSubtitle("[Military officer] Alright, all good! Thanks for guarding us.", 10000); diff --git a/VehicleCollisions/Scenes/SceneFactory.cs b/VehicleCollisions/Scenes/SceneFactory.cs index 5f96395..91b07b6 100644 --- a/VehicleCollisions/Scenes/SceneFactory.cs +++ b/VehicleCollisions/Scenes/SceneFactory.cs @@ -8,8 +8,7 @@ public class SceneFactory public SceneFactory() { - _sceneNumber = 14; - //_sceneNumber = Utilities.Between(1, 14); + _sceneNumber = Utilities.Between(1, 14); } public IScene GetScene(VehicleCollisions vehicleCollisions) diff --git a/VehicleCollisions/Scenes/SevereCrashWithMilitaryConvoy.cs b/VehicleCollisions/Scenes/SevereCrashWithMilitaryConvoy.cs index cc9204d..a378204 100644 --- a/VehicleCollisions/Scenes/SevereCrashWithMilitaryConvoy.cs +++ b/VehicleCollisions/Scenes/SevereCrashWithMilitaryConvoy.cs @@ -8,8 +8,6 @@ namespace VehicleCollisions.Scenes { internal class SevereCrashWithMilitaryConvoy : IScene { - private Ped[] SpawnedCivilianPeds; - private Vehicle[] SpawnedCrashedCars; public bool HasAdditionalTasks => false; public string Title => "Severe crash with military convoy"; @@ -29,7 +27,7 @@ public string[] Notifications() } // Define the coordinates of the main accident - public Vector3 Coordinates => new Vector3(-1777, -677, -10); + public Vector3 Coordinates => new Vector3(-1769.41f, -668.4f, 10.4f); // Define the on-scene police cars (if any) public EmergencyCar[] EmergencyCars => new[] @@ -47,7 +45,7 @@ public string[] Notifications() .GiveWeapon(WeaponHash.Flare) }; - public ObjectModel[] ObjectModels => new[] + public ObjectModel[] ObjectModels => new ObjectModel[] { new ObjectModel(new Vector3(-1778.23f, -659.09f, 10f), 939377219), new ObjectModel(new Vector3(-1775.35f, -658.70f, 10f), 939377219), @@ -100,20 +98,13 @@ public void Accept() public void Start(Ped[] CivilianPeds = null, Vehicle[] CrashedCars = null) { - SpawnedCivilianPeds = CivilianPeds; - SpawnedCrashedCars = CrashedCars; - ShowSubtitle("[Officer] I am trying to block the road here for you, I have not evaluated the situation yet", 10000); } public void Finish() { - if (SpawnedCivilianPeds != null && SpawnedCivilianPeds != null) - { - SpawnedCivilianPeds[0].Task.EnterVehicle(SpawnedCrashedCars[2]); - SpawnedCivilianPeds[1].Task.EnterVehicle(SpawnedCrashedCars[3]); - } + } public Task RunAdditionalTasks() diff --git a/VehicleCollisions/VehicleCollisions.cs b/VehicleCollisions/VehicleCollisions.cs index d092213..36a27b1 100644 --- a/VehicleCollisions/VehicleCollisions.cs +++ b/VehicleCollisions/VehicleCollisions.cs @@ -2,6 +2,7 @@ using System.Threading.Tasks; using CitizenFX.Core; using FivePD.API; +using VehicleCollisions.Entities; using VehicleCollisions.Scenes; using static CitizenFX.Core.Native.API; using static CitizenFX.Core.UI.Screen; @@ -9,7 +10,7 @@ namespace VehicleCollisions { - [CalloutProperties("Vehicle Collisions", "Dennis Smink", "1.1")] + [CalloutProperties("Vehicle Collisions", "Dennis Smink", "1.1.1")] public class VehicleCollisions : Callout { private readonly IScene _scene; @@ -36,20 +37,55 @@ public override async Task OnAccept() // When user accepts, continue InitBlip(); - // Spawn the on-scene emergency cars (if any) - await SpawnOnSceneEmergencyCars(); + try + { + // Spawn the on-scene emergency cars (if any) + await SpawnOnSceneEmergencyCars(); + } + catch (Exception exception) + { + Debug.WriteLine($"[Vehicle Collisions] Unable to spawn emergency cars for scene: {exception}"); + } - // Spawn the on-scene emergency peds - await SpawnOnSceneEmergencyPeds(); + try + { + // Spawn the on-scene emergency peds + await SpawnOnSceneEmergencyPeds(); + } + catch (Exception exception) + { + Debug.WriteLine($"[Vehicle Collisions] Unable to spawn emergency peds for scene: {exception}"); + } - // Spawn the scene objects - await SpawnObjects(); + try + { + // Spawn the scene objects + await SpawnObjects(); + } + catch (Exception exception) + { + Debug.WriteLine($"[Vehicle Collisions] Unable to spawn objects for scene: {exception}"); + } - // Spawn crashed cars - await SpawnCrashedCars(); + try + { + // Spawn crashed cars + await SpawnCrashedCars(); + } + catch (Exception exception) + { + Debug.WriteLine($"[Vehicle Collisions] Unable to spawn crashed cars for scene: {exception}"); + } - // Spawn the civilians for the cars - await SpawnCivilians(); + try + { + // Spawn the civilians for the cars + await SpawnCivilians(); + } + catch (Exception exception) + { + Debug.WriteLine($"[Vehicle Collisions] Unable to spawn civilian peds for scene: {exception}"); + } // Run the notifications RunNotifications(); @@ -65,10 +101,17 @@ public override void OnStart(Ped player) // Run the scene start method _scene.Start(_civilianPeds, _crashedCars); - if (_scene.HasAdditionalTasks) Tick += _scene.RunAdditionalTasks; + try + { + if (_scene.HasAdditionalTasks) Tick += _scene.RunAdditionalTasks; + } + catch (Exception exception) + { + Debug.WriteLine("[Vehicle Collisions] We we're unable to run the Tick"); + } } - public async Task SpawnOnSceneEmergencyCars() + private async Task SpawnOnSceneEmergencyCars() { _emergencyCars = new Vehicle[_scene.EmergencyCars.Length]; for (var i = 0; i < _scene.EmergencyCars.Length; i++) @@ -84,19 +127,19 @@ public async Task SpawnOnSceneEmergencyCars() } } - public async Task SpawnOnSceneEmergencyPeds() + private async Task SpawnOnSceneEmergencyPeds() { _emergencyPeds = new Ped[_scene.EmergencyPeds.Length]; for (var i = 0; i < _scene.EmergencyPeds.Length; i++) { - var emergencyPed = _scene.EmergencyPeds[i]; + EmergencyPed emergencyPed = _scene.EmergencyPeds[i]; _emergencyPeds[i] = await SpawnPed(emergencyPed.Model, emergencyPed.Location); _emergencyPeds[i].AlwaysKeepTask = true; _emergencyPeds[i].BlockPermanentEvents = true; - + _emergencyPeds[i].Weapons.Give(emergencyPed.Weapon, 1, true, true); - + SetEntityHeading(_emergencyPeds[i].Handle, emergencyPed.Heading); if (emergencyPed.AnimationLib != null) @@ -104,13 +147,15 @@ public async Task SpawnOnSceneEmergencyPeds() RequestAnimDict(emergencyPed.AnimationLib); _emergencyPeds[i].Task.PlayAnimation(emergencyPed.AnimationLib, emergencyPed.AnimationName); } - + if (emergencyPed.Scenario != null) + { TaskStartScenarioInPlace(_emergencyPeds[i].Handle, emergencyPed.Scenario, 0, true); + } } } - public async Task SpawnObjects() + private async Task SpawnObjects() { _spawnedObjects = new int[_scene.ObjectModels.Length]; @@ -138,7 +183,7 @@ public async Task SpawnObjects() } } - public async Task SpawnCrashedCars() + private async Task SpawnCrashedCars() { _crashedCars = new Vehicle[_scene.CrashedCars.Length]; for (var i = 0; i < _scene.CrashedCars.Length; i++) @@ -264,6 +309,7 @@ public async Task SpawnCrashedCars() // If we have any drivers for the crashed car, spawn these if (crashedCar.Peds != null) + { foreach (var vehiclePed in crashedCar.Peds) { if (vehiclePed.ShouldRandomSpawn && Utilities.RandomBool()) continue; @@ -283,6 +329,7 @@ public async Task SpawnCrashedCars() driver.AttachedBlip.Color = BlipColor.Green; } } + } // Attach trailer if (crashedCar.AttachedTrailer != null) @@ -305,7 +352,7 @@ public async Task SpawnCrashedCars() } } - public async Task SpawnCivilians() + private async Task SpawnCivilians() { _civilianPeds = new Ped[_scene.CivilianPeds.Length]; for (var i = 0; i < _scene.CivilianPeds.Length; i++) @@ -360,12 +407,13 @@ public override void OnCancelBefore() if (spawnedCar != null && spawnedCar.AttachedBlip != null) spawnedCar.AttachedBlip?.Delete(); // Remove ped blip - foreach (var passenger in spawnedCar.Occupants) - { - if (passenger == null) continue; + if (spawnedCar != null) + foreach (var passenger in spawnedCar.Occupants) + { + if (passenger == null) continue; - passenger.AttachedBlip?.Delete(); - } + passenger.AttachedBlip?.Delete(); + } } } catch (Exception) @@ -384,7 +432,7 @@ public override void OnCancelBefore() spawnedCivilian.AttachedBlip?.Delete(); } - if (!spawnedCivilian.IsVisible) spawnedCivilian.Delete(); + if (spawnedCivilian != null && !spawnedCivilian.IsVisible) spawnedCivilian.Delete(); } } catch (Exception) diff --git a/VehicleCollisions/VehicleCollisions.csproj b/VehicleCollisions/VehicleCollisions.csproj index cec6ec5..a5ee660 100644 --- a/VehicleCollisions/VehicleCollisions.csproj +++ b/VehicleCollisions/VehicleCollisions.csproj @@ -11,6 +11,7 @@ VehicleIncidents.net v4.7.2 512 + latest AnyCPU diff --git a/VehicleCollisions/obj/Debug/VehicleCollisions.csproj.FileListAbsolute.txt b/VehicleCollisions/obj/Debug/VehicleCollisions.csproj.FileListAbsolute.txt index bb145e3..e016651 100644 --- a/VehicleCollisions/obj/Debug/VehicleCollisions.csproj.FileListAbsolute.txt +++ b/VehicleCollisions/obj/Debug/VehicleCollisions.csproj.FileListAbsolute.txt @@ -1,9 +1,9 @@ -C:\Users\Dennis\RiderProjects\VehicleCollisions\VehicleCollisions\bin\Debug\VehicleIncidents.net.dll -C:\Users\Dennis\RiderProjects\VehicleCollisions\VehicleCollisions\bin\Debug\VehicleIncidents.net.pdb C:\Users\Dennis\RiderProjects\VehicleCollisions\VehicleCollisions\bin\Debug\CitizenFX.Core.dll C:\Users\Dennis\RiderProjects\VehicleCollisions\VehicleCollisions\obj\Debug\VehicleCollisions.csprojAssemblyReference.cache C:\Users\Dennis\RiderProjects\VehicleCollisions\VehicleCollisions\obj\Debug\VehicleCollisions.csproj.CoreCompileInputs.cache C:\Users\Dennis\RiderProjects\VehicleCollisions\VehicleCollisions\obj\Debug\VehicleCollisions.csproj.CopyComplete +C:\Users\Dennis\RiderProjects\VehicleCollisions\VehicleCollisions\bin\Debug\FivePD.net.dll +C:\Users\Dennis\RiderProjects\VehicleCollisions\VehicleCollisions\bin\Debug\VehicleIncidents.net.dll +C:\Users\Dennis\RiderProjects\VehicleCollisions\VehicleCollisions\bin\Debug\VehicleIncidents.net.pdb C:\Users\Dennis\RiderProjects\VehicleCollisions\VehicleCollisions\obj\Debug\VehicleIncidents.net.dll C:\Users\Dennis\RiderProjects\VehicleCollisions\VehicleCollisions\obj\Debug\VehicleIncidents.net.pdb -C:\Users\Dennis\RiderProjects\VehicleCollisions\VehicleCollisions\bin\Debug\FivePD.net.dll diff --git a/VehicleCollisions/obj/Debug/VehicleIncidents.net.dll b/VehicleCollisions/obj/Debug/VehicleIncidents.net.dll index 9672b98..e6c0963 100644 Binary files a/VehicleCollisions/obj/Debug/VehicleIncidents.net.dll and b/VehicleCollisions/obj/Debug/VehicleIncidents.net.dll differ diff --git a/VehicleCollisions/obj/Debug/VehicleIncidents.net.pdb b/VehicleCollisions/obj/Debug/VehicleIncidents.net.pdb index 3e73d35..ea20d87 100644 Binary files a/VehicleCollisions/obj/Debug/VehicleIncidents.net.pdb and b/VehicleCollisions/obj/Debug/VehicleIncidents.net.pdb differ