public void Delete(decimal recordId) { List <VehicleRecordsProperties> vrProperties = _modelContext.VehicleRecordsProperties .Where(e => e.VrId == recordId) .ToList(); if (vrProperties != null) { foreach (VehicleRecordsProperties vr in vrProperties) { _modelContext.VehicleRecordsProperties.Remove(vr); } } _modelContext.SaveChanges(); var VRPRecords = _modelContext.VehicleRecordsProperties .Where(e => e.VrId == recordId) .ToList(); if (VRPRecords.Count == 0) { VehicleRecords deleteVehicleRecord = _modelContext.VehicleRecords.Find(recordId); _modelContext.VehicleRecords.Remove(deleteVehicleRecord); _modelContext.SaveChanges(); } }
public BritishPersona(Ped _ped, LicenceTypes _LicenceType, LicenceStatuses _LicenceStatus, int _PenaltyPoints, bool _CarryingLicence) : this(_ped) { if (!_ped.Exists()) { AllBritishPersona.Remove(this); return; } foreach (BritishPersona pers in AllBritishPersona.ToArray()) { if (pers.ped == _ped && pers != this) { AllBritishPersona.Remove(pers); } } ped = _ped; if (ped.Exists()) { _LSPDFRPersona = LSPD_First_Response.Mod.API.Functions.GetPersonaForPed(ped); if (ped.IsInAnyVehicle(false)) { VehicleRecords.VerifyVehicleRecordsExist(ped.CurrentVehicle); } foreach (BritishPersona pers in AllBritishPersona.ToArray()) { if (pers.ped == ped && pers != this) { AllBritishPersona.Remove(pers); } } } LicenceType = _LicenceType; LicenceStatus = _LicenceStatus; PenaltyPoints = _PenaltyPoints; CarryingLicence = _CarryingLicence; }
private void CalloutHandler() { CalloutRunning = true; GameFiber.StartNew(delegate { try { Suspect.Tasks.CruiseWithVehicle(20f, VehicleDrivingFlags.DriveAroundVehicles | VehicleDrivingFlags.DriveAroundObjects | VehicleDrivingFlags.AllowMedianCrossing | VehicleDrivingFlags.YieldToCrossingPedestrians); SuspectBritishPersona = BritishPersona.GetBritishPersona(Suspect); SuspectCarRecords = VehicleRecords.GetVehicleRecords(SuspectCar); SetANPRHitDetails(HitType); Game.DisplayNotification("~b~Control: ~o~ANPR Hit is on a ~b~" + SuspectCarRecords.CarColour + "~b~ " + SuspectCarRecords.ModelName + "~s~, plate ~b~" + SuspectCarRecords.LicencePlate + "."); GameFiber.Wait(4000); GameFiber.Wait(2000); Game.DisplayHelp("Locate and stop the suspect's vehicle."); HandleSearchForVehicleWithANPR(); BeforeTrafficStopDrive(); while (CalloutRunning) { GameFiber.Yield(); if (!Functions.IsPlayerPerformingPullover() && !PursuitCreated) { GameFiber.Wait(1000); if (Functions.GetActivePursuit() == null) { break; } else { PursuitCreated = true; Pursuit = Functions.GetActivePursuit(); } } if (PursuitCreated && !Functions.IsPursuitStillRunning(Pursuit)) { break; } } DisplayCodeFourMessage(); } catch (System.Threading.ThreadAbortException e) { End(); } catch (Exception e) { if (CalloutRunning) { Game.LogTrivial(e.ToString()); Game.LogTrivial("British Policing Script handled the exception successfully."); Game.DisplayNotification("~O~ANPRHIT~s~ callout crashed, sorry. Please send me your log file."); Game.DisplayNotification("Full LSPDFR crash prevented ~g~successfully."); End(); } } }); }
public bool IsInsuredToDriveVehicle(VehicleRecords vehrecs) { if (FullyCompInsured || VehiclesInsuredToDrive.Contains(vehrecs)) { return(true); } else { return(false); } }
public NamedRecordSet GetOrCreateVehicleRecord(string vehicleName) { var vehicleRecord = VehicleRecords.FirstOrDefault(x => x.Name == vehicleName); if (vehicleRecord == null) { vehicleRecord = new NamedRecordSet() { Name = vehicleName, }; VehicleRecords.Add(vehicleRecord); } return(vehicleRecord); }
public IActionResult Create(VehiclesModel vehicles, IFormCollection formCollection) { IActionResult returnpath = View(vehicles); VehicleMakemodelMapping mapping = new VehicleMakemodelMapping(); //var _modelContext = new VehiclesContext(); try { Validation(vehicles); decimal VmakeId = Convert.ToDecimal(HttpContext.Request.Form["VmakeId"]); decimal VmodelId = Convert.ToDecimal(HttpContext.Request.Form["VmodelId"]); mapping = _vehicleService.GetMakeModelIDList(mapping, VmakeId, VmodelId); if (ModelState.IsValid) { if (mapping != null) { var record = new VehicleRecords() { VmmpId = mapping.VmmpId }; _modelContext.VehicleRecords.Add(record); _modelContext.SaveChanges(); decimal id = record.VrId; if (id != 0) { _vehicleService.InsertIntoVehicleRecordProperties(vehicles, id); } } returnpath = RedirectToAction("Index"); } else { ViewBag.ListOfVehicles = _vehicleService.LoadVehicleTypeList(); returnpath = View(vehicles); } } catch (Exception ex) { _logger.LogError(" Exception on creating new record: " + ex); } return(returnpath); }
internal static VehiclePersona CreateVehiclePersona(Vehicle veh) { VehicleRecords records = Functions.GetVehicleRecords(veh); VehiclePersona vehiclePersona = new VehiclePersona(); vehiclePersona.HasInsurance = records.Insured; vehiclePersona.IsRegistered = null; vehiclePersona.Color = records.CarColour; vehiclePersona.Alert = new System.Text.RegularExpressions.Regex(@"~\w~").Replace(records.DetermineFlags(), String.Empty); vehiclePersona.HasValidEmissions = records.HasMOT; vehiclePersona.IsOffroadOnly = records.HasSORN; vehiclePersona.IsTaxed = records.IsTaxed; vehiclePersona.RawPersona = records; return(vehiclePersona); }
public void SetIsInsuredToDriveVehicle(VehicleRecords vehrecs, bool Insured) { if (Insured) { if (!VehiclesInsuredToDrive.Contains(vehrecs)) { VehiclesInsuredToDrive.Add(vehrecs); } } else { if (VehiclesInsuredToDrive.Contains(vehrecs)) { VehiclesInsuredToDrive.Remove(vehrecs); } } }
/// <summary> /// Constructor that sets values based off the LSPDFR API /// </summary> /// <param name="_ped"></param> public BritishPersona(Ped _ped) : this(LSPD_First_Response.Mod.API.Functions.GetPersonaForPed(_ped)) { if (!_ped.Exists()) { Game.LogTrivial("PED DOESNT EXIST"); AllBritishPersona.Remove(this); return; } foreach (BritishPersona pers in AllBritishPersona.ToArray()) { if (pers.ped == _ped && pers != this) { AllBritishPersona.Remove(pers); } } ped = _ped; if (ped.Exists()) { _LSPDFRPersona = LSPD_First_Response.Mod.API.Functions.GetPersonaForPed(ped); if (ped.IsInAnyVehicle(false)) { VehicleRecords.VerifyVehicleRecordsExist(ped.CurrentVehicle); } foreach (BritishPersona pers in AllBritishPersona.ToArray()) { if (pers.ped == ped && pers != this) { AllBritishPersona.Remove(pers); } } } int roll = Main.rnd.Next(10); if (roll < 6) { LicenceType = LicenceTypes.Full; } else { //If ped is driving a vehicle with a passenger if (_ped.IsInAnyVehicle(false)) { if (_ped.CurrentVehicle.Driver == _ped) { if (!_ped.CurrentVehicle.IsSeatFree(0)) { if (Main.rnd.Next(4) < 3) { LicenceType = LicenceTypes.Provisional; } else { LicenceType = LicenceTypes.None; } } } } else { roll = Main.rnd.Next(4); if (roll < 2) { LicenceType = LicenceTypes.Provisional; } else { LicenceType = LicenceTypes.None; } } } FullyCompInsured = Main.rnd.Next(8) == 0; int Citations = LSPDFRPersona.Citations; PenaltyPoints = Citations * 3; if (LSPDFRPersona.ELicenseState == ELicenseState.Valid) { LicenceStatus = LicenceStatuses.Valid; } else if (LSPDFRPersona.ELicenseState == ELicenseState.Suspended) { if (Main.rnd.Next(6) < 4) { LicenceStatus = LicenceStatuses.Disqualified; } else { LicenceStatus = LicenceStatuses.Revoked; } } else if (LSPDFRPersona.ELicenseState == ELicenseState.Expired) { LicenceStatus = LicenceStatuses.Expired; } else { LicenceStatus = LicenceStatuses.Valid; } if (LicenceStatus == LicenceStatuses.Disqualified || LicenceStatus == LicenceStatuses.Revoked || LicenceType == LicenceTypes.None) { CarryingLicence = false; } else { CarryingLicence = Main.rnd.Next(6) < 4; } }
public bool HasSpecificInsuranceForVehicle(VehicleRecords vehrecs) { return(VehiclesInsuredToDrive.Contains(vehrecs)); }
private void CalloutHandler() { CalloutRunning = true; GameFiber.StartNew(delegate { try { SuspectCar = new Vehicle(GroundVehiclesToSelectFrom[EntryPoint.rnd.Next(GroundVehiclesToSelectFrom.Length)], sp, sp); SuspectCar.IsPersistent = true; Suspect = SuspectCar.CreateRandomDriver(); Suspect.MakeMissionPed(); SuspectBritishPersona = BritishPersona.GetBritishPersona(Suspect); SuspectCarRecords = VehicleRecords.GetVehicleRecords(SuspectCar); SuspectCarRecords.RegisteredOwner = BritishPersona.GetRandomBritishPersona(); SuspectCarRecords.AddCustomFlag("~r~WANTED FOR TWOC "); Suspect.Tasks.CruiseWithVehicle(20f, VehicleDrivingFlags.DriveAroundVehicles | VehicleDrivingFlags.DriveAroundObjects | VehicleDrivingFlags.AllowMedianCrossing | VehicleDrivingFlags.YieldToCrossingPedestrians); GameFiber.Wait(2000); Game.DisplayNotification("~b~Control: ~s~TWOC report's on a ~b~" + SuspectCarRecords.CarColour + "~b~ " + SuspectCarRecords.ModelName + "~s~. Licence plate: ~b~" + SuspectCarRecords.LicencePlate + "."); GameFiber.Wait(4000); Game.DisplayNotification("Vehicle has just been taken from ~b~" + World.GetStreetName(SuspectCar.Position) + "~s~. ~b~" + SuspectCarRecords.LicencePlate + "~s~ added to ~o~ANPR system."); GameFiber.Wait(2000); Game.DisplayHelp("Locate and stop the suspect's vehicle."); HandleSearchForVehicleWithANPR(); while (CalloutRunning) { GameFiber.Yield(); if (!Game.LocalPlayer.Character.IsInAnyVehicle(false)) { break; } if (Functions.IsPlayerPerformingPullover()) { if (Functions.GetPulloverSuspect(Functions.GetCurrentPullover()) == Suspect) { break; } } } if (Functions.IsPlayerPerformingPullover()) { GameFiber.Wait(4000); } if (SuspectBlip.Exists()) { SuspectBlip.Delete(); } if ((EntryPoint.rnd.Next(11) <= 6) || (!Game.LocalPlayer.Character.IsInAnyVehicle(false))) { Pursuit = Functions.CreatePursuit(); Functions.AddPedToPursuit(Pursuit, Suspect); Functions.SetPursuitIsActiveForPlayer(Pursuit, true); if (Functions.IsPlayerPerformingPullover()) { Functions.ForceEndCurrentPullover(); } Functions.PlayScannerAudioUsingPosition("WE_HAVE CRIME_RESIST_ARREST IN_OR_ON_POSITION", Game.LocalPlayer.Character.Position); Game.DisplayNotification("Control, the vehicle is ~r~making off.~b~ Giving chase."); while (Functions.IsPursuitStillRunning(Pursuit)) { GameFiber.Yield(); if (!CalloutRunning) { break; } } } else { while (CalloutRunning) { GameFiber.Yield(); if (!Game.LocalPlayer.Character.IsInAnyVehicle(false)) { GameFiber.Wait(1000); if (EntryPoint.rnd.Next(5) == 0) { Pursuit = Functions.CreatePursuit(); Functions.AddPedToPursuit(Pursuit, Suspect); Functions.SetPursuitIsActiveForPlayer(Pursuit, true); if (Functions.IsPlayerPerformingPullover()) { Functions.ForceEndCurrentPullover(); } Functions.PlayScannerAudioUsingPosition("WE_HAVE CRIME_RESIST_ARREST IN_OR_ON_POSITION", Game.LocalPlayer.Character.Position); Game.DisplayNotification("Control, the vehicle is ~r~making off.~b~ Giving chase."); } break; } } while (CalloutRunning) { GameFiber.Yield(); if (Suspect.Exists()) { if (Functions.IsPedArrested(Suspect)) { break; } if (Suspect.IsDead) { break; } } else { break; } } } if (Suspect.Exists()) { if (Functions.IsPedArrested(Suspect)) { msg = "Control, suspect is ~g~under arrest. ~s~Show me state 2, over."; int HoursUnpaidWork = (int)Math.Round(((float)EntryPoint.rnd.Next(100, 200)) / 5.0f) * 5; int Costs = (int)Math.Round(((float)EntryPoint.rnd.Next(86)) / 5.0f) * 5; string sentence = " Community order made with " + HoursUnpaidWork.ToString() + " hours unpaid work. Disqualified from driving for " + EntryPoint.rnd.Next(4, 13).ToString() + " months. " + Costs.ToString() + " pounds in costs."; CourtSystem.CreateNewCourtCase(SuspectBritishPersona, "taking a vehicle without the owner's consent", 100, sentence); } else if (Suspect.IsDead) { msg = "Control, suspect is ~r~dead. ~s~Show me state 2, over"; } } else { msg = "Control, the suspects ~r~have escaped. ~s~Show me state 2, over"; } DisplayCodeFourMessage(); } catch (System.Threading.ThreadAbortException e) { End(); } catch (Exception e) { if (CalloutRunning) { Game.LogTrivial(e.ToString()); Game.LogTrivial("British Policing Script handled the exception successfully."); Game.DisplayNotification("~O~TWOC~s~ callout crashed, sorry. Please send me your log file."); Game.DisplayNotification("Full LSPDFR crash prevented ~g~successfully."); End(); } } }); }
/// <summary> /// Returns the VehicleRecords for the vehicle. /// </summary> /// <param name="veh"></param> /// <returns></returns> public static VehicleRecords GetVehicleRecords(Vehicle veh) { return(VehicleRecords.GetVehicleRecords(veh)); }