示例#1
0
        public PlateChecker(Vehicle vehicleToCheck)
        {
            if (vehicleToCheck.Exists())
            {
                string Flags = "";
                if (vehicleToCheck.IsStolen)
                {
                    Flags        += "STOLEN ";
                    DriverPersona = LSPD_First_Response.Mod.API.Functions.GetPersonaForPed(World.GetAllPeds()[0]);
                    //determine persona to use
                    if (vehicleToCheck.HasDriver && vehicleToCheck.Driver.Exists())
                    {
                        if (LSPD_First_Response.Mod.API.Functions.GetPersonaForPed(vehicleToCheck.Driver).FullName.ToLower() == Functions.GetVehicleOwnerName(vehicleToCheck).ToLower())
                        {
                            DriverPersona = Functions.GetPersonaForPed(World.GetAllPeds()[0]);
                        }
                        else
                        {
                            foreach (Ped p in World.EnumeratePeds())
                            {
                                if (Functions.GetPersonaForPed(p).FullName.ToLower() == Functions.GetVehicleOwnerName(vehicleToCheck).ToLower())
                                {
                                    DriverPersona = Functions.GetPersonaForPed(p);
                                    break;
                                }
                            }
                        }
                    }
                    if (DriverPersona == null)
                    {
                        //create new persona
                        Persona tempPers = Functions.GetPersonaForPed(World.GetAllPeds()[0]);
                        //DriverPersona = new Persona(World.GetAllPeds()[0], tempPers.Gender, tempPers.BirthDay, tempPers.Citations, tempPers.Forename, tempPers.Surname, tempPers.LicenseState, tempPers.TimesStopped, tempPers.Wanted, tempPers.IsAgent, tempPers.IsCop);
                    }
                    AudioFlags.Add("Stolen");
                }
                else
                {
                    //determine persona to use
                    if (vehicleToCheck.HasDriver && vehicleToCheck.Driver.Exists())
                    {
                        if (LSPD_First_Response.Mod.API.Functions.GetPersonaForPed(vehicleToCheck.Driver).FullName.ToLower() == Functions.GetVehicleOwnerName(vehicleToCheck).ToLower())
                        {
                            DriverPersona = LSPD_First_Response.Mod.API.Functions.GetPersonaForPed(vehicleToCheck.Driver);
                        }
                        else
                        {
                            foreach (Ped p in World.EnumeratePeds())
                            {
                                if (Functions.GetPersonaForPed(p).FullName.ToLower() == Functions.GetVehicleOwnerName(vehicleToCheck).ToLower())
                                {
                                    DriverPersona = Functions.GetPersonaForPed(p);
                                    break;
                                }
                            }
                        }
                    }
                    if (DriverPersona == null)
                    {
                        DriverPersona = PersonaHelper.GenerateNewPersona();
                    }
                    //DriverPersona = vehicleToCheck.HasDriver && Albo1125.Common.CommonLibrary.CommonVariables.rnd.Next(100) < 80 ? LSPD_First_Response.Mod.API.Functions.GetPersonaForPed(vehicleToCheck.Driver) : LSPD_First_Response.Mod.API.Functions.GetPersonaForPed(World.GetAllPeds()[0]);
                }
                LSPD_First_Response.Mod.API.Functions.SetVehicleOwnerName(vehicleToCheck, DriverPersona.FullName);
                //determine flags on the vehicle
                if (!PoliceSmartRadio.IsLSPDFRPluginRunning("British Policing Script", new Version("0.9.0.0")))
                {
                    if (Traffic_Policer.API.Functions.GetVehicleRegistrationStatus(vehicleToCheck) == Traffic_Policer.EVehicleDetailsStatus.Expired)
                    {
                        Flags += "EXPIRED REGISTRATION ";
                        AudioFlags.Add("TrafficViolation");
                    }
                    else if (Traffic_Policer.API.Functions.GetVehicleRegistrationStatus(vehicleToCheck) == Traffic_Policer.EVehicleDetailsStatus.None)
                    {
                        Flags += "NO REGISTRATION ";
                        AudioFlags.Add("TrafficViolation");
                    }

                    if (Traffic_Policer.API.Functions.GetVehicleInsuranceStatus(vehicleToCheck) == Traffic_Policer.EVehicleDetailsStatus.Expired)
                    {
                        Flags += "EXPIRED INSURANCE ";
                        AudioFlags.Add("TrafficViolation");
                    }
                    else if (Traffic_Policer.API.Functions.GetVehicleInsuranceStatus(vehicleToCheck) == Traffic_Policer.EVehicleDetailsStatus.None)
                    {
                        Flags += "NO INSURANCE ";
                        AudioFlags.Add("TrafficViolation");
                    }

                    if (DriverPersona.Wanted)
                    {
                        AudioFlags.Add("Warrant");
                        if (rnd.Next(100) < 75)
                        {
                            Flags += "FELONY WARRANT FOR REGISTERED OWNER ";
                        }
                        else
                        {
                            Flags += "BENCH WARRANT FOR REGISTERED OWNER ";
                        }
                    }

                    if (DriverPersona.ELicenseState == ELicenseState.Suspended)
                    {
                        Flags += "OWNER'S LICENCE SUSPENDED ";
                        AudioFlags.Add("TrafficFelony");
                    }
                    else if (DriverPersona.ELicenseState == ELicenseState.Expired)
                    {
                        Flags += "OWNER'S LICENCE EXPIRED ";
                        AudioFlags.Add("TrafficViolation");
                    }
                    else if (DriverPersona.ELicenseState == ELicenseState.None)
                    {
                        Flags += "OWNER'S LICENCE INVALID ";
                        AudioFlags.Add("TrafficViolation");
                    }

                    if (DriverPersona.Birthday.Date == DateTime.Now.Date)
                    {
                        Flags += "~g~OWNER'S BIRTHDAY ";
                    }

                    if (string.IsNullOrWhiteSpace(Flags))
                    {
                        AudioFlags.Add("No1099");
                        this.Flags += "~g~NONE";
                    }
                    else
                    {
                        AudioFlags.Add("ProceedCaution");
                        this.Flags += Flags;
                    }
                }

                //read in strings from the vehicle information
                LicencePlate = vehicleToCheck.LicensePlate;

                vehModel = vehicleToCheck.Model.Name.ToLower();
                vehModel = char.ToUpper(vehModel[0]) + vehModel.Substring(1);
                if (vowels.Contains(vehModel.ToLower()[0]))
                {
                    modelArticle = "an";
                }
                else
                {
                    modelArticle = "a";
                }
                vehicleYear = vehYears.PickRandom();
                AllVehiclesChecked.Add(vehicleToCheck, this);
            }
        }