public static VehiclePersona GetPersonaForVehicle(Vehicle vehicle)
 {
     if (PersonaType == PersonaTypes.BPS)
     {
         var records = British_Policing_Script.API.Functions.GetVehicleRecords(vehicle);
         return(new VehiclePersona(records));
     }
     else
     {
         var vehiclePersona = new VehiclePersona();
         if (Function.IsTrafficPolicerRunning())
         {
             vehiclePersona.HasInsurance = TrafficPolicerFunction.GetVehicleInsuranceStatus(vehicle) == EVehicleStatus.Valid ? true : false;
             vehiclePersona.IsRegistered = TrafficPolicerFunction.GetVehicleRegistrationStatus(vehicle) == EVehicleStatus.Valid ? true : false;
         }
         return(vehiclePersona);
     }
 }
 public static VehiclePersona GetPersonaForVehicle(Vehicle vehicle)
 {
     if (PersonaType == PersonaTypes.BPS)
     {
         return BritishPolicingFunctions.CreateVehiclePersona(vehicle);
     }
     else
     {
         var vehiclePersona = new VehiclePersona();
         if (Function.IsTrafficPolicerRunning())
         {
             vehiclePersona.HasInsurance = TrafficPolicerFunction.GetVehicleInsuranceStatus(vehicle) == EVehicleStatus.Valid ? true : false;
             vehiclePersona.IsRegistered = TrafficPolicerFunction.GetVehicleRegistrationStatus(vehicle) == EVehicleStatus.Valid ? true : false;
         }
         else
         {
             vehiclePersona.HasInsurance = false;
             vehiclePersona.IsRegistered = false;
         }
         return vehiclePersona;
     }
 }
        private void BindData()
        {
            if (DetailedEntity.Entity.Ped == null || !DetailedEntity.Entity.Ped.IsValid())
            {
                return;
            }
            if (!BindNeeded)
            {
                return;
            }
            BindNeeded = false;
            if (DetailedEntity.Entity.IsLicenseValid)
            {
                labeled_license_status.Component.Text = "Valid";
            }
            else
            {
                labeled_license_status.Component.Warn(DetailedEntity.Entity.LicenseStateString);
            }


            if (DetailedEntity.Entity.IsAgent)
            {
                labeled_owner_alert.Component.Warn("Individual is a federal agent");
                labeled_owner_alert.Show();
            }
            else if (DetailedEntity.Entity.IsCop)
            {
                labeled_owner_alert.Component.Warn("Individual is a police officer");
                labeled_owner_alert.Show();
            }
            else
            {
                labeled_owner_alert.Hide();
            }

            if (!String.IsNullOrWhiteSpace(DetailedEntity.Entity.VehicleAlert))
            {
                labeled_alpr.Component.SetText(DetailedEntity.Entity.VehicleAlert);
                labeled_alpr.Show();
            }
            else
            {
                labeled_alpr.Hide();
            }

            cb_action.AddItem("Select One", "Placeholder", QuickActions.PLACEHOLDER);
            cb_action.AddItem("Blip (30 sec)", "Blip", QuickActions.BLIP_VEHICLE);
            cb_action.AddItem("Create Traffic Citation", "TrafficCitation", QuickActions.CREATE_TRAFFIC_CITATION);
            cb_action.AddItem("Create Arrest Report", "ArrestReport", QuickActions.CREATE_ARREST_REPORT_FOR_DRIVER);

            labeled_age.Component.Text          = DetailedEntity.Entity.AgeString;
            labeled_first_name.Component.Text   = DetailedEntity.Entity.FirstName;
            labeled_last_name.Component.Text    = DetailedEntity.Entity.LastName;
            labeled_home_address.Component.Text = Owner.GetHomeAddress();
            labeled_dob.Component.Text          = DetailedEntity.Entity.DOBString;
            if (DetailedEntity.Entity.IsWanted)
            {
                labeled_wanted_status.Component.Warn("Wanted");
            }
            else
            {
                labeled_wanted_status.Component.SetText("None");
            }
            labeled_times_stopped.Component.Text = DetailedEntity.Entity.TimesStopped.ToString();

            labeled_vehicle_model.Component.Text   = Vehicle.Model.Name;
            labeled_vehicle_license.Component.Text = Vehicle.LicensePlate;
            if (ComputerPlusEntity.PersonaType == PersonaTypes.BPS)
            {
                if (BritishPolicingFunctions.IsVehicleRegistered(DetailedEntity.Entity.RawVehiclePersona))
                {
                    labeled_vehicle_registration_status.Component.SetText("No");
                }
                else
                {
                    labeled_vehicle_registration_status.Component.Warn("Yes");
                }
                Function.LogDebug("set labeled_vehicle_registration_status");

                if (BritishPolicingFunctions.IsVehicleInsured(DetailedEntity.Entity.RawVehiclePersona))
                {
                    labeled_vehicle_insurance_status.Component.SetText("Yes");
                }
                else
                {
                    labeled_vehicle_insurance_status.Component.Warn("No");
                }
                Function.LogDebug("set labeled_vehicle_insurance_status");

                if (BritishPolicingFunctions.DoesVehicleHaveMOT(DetailedEntity.Entity.RawVehiclePersona))
                {
                    labeled_vehicle_extra_1.Component.SetText("Yes");
                }
                else
                {
                    labeled_vehicle_extra_1.Component.Warn("No");
                }
                Function.LogDebug("set labeled_vehicle_extra_1");

                if (BritishPolicingFunctions.DoesVehicleHaveSORN(DetailedEntity.Entity.RawVehiclePersona))
                {
                    labeled_vehicle_extra_2.Component.SetText("Yes");
                }
                else
                {
                    labeled_vehicle_extra_2.Component.Warn("No");
                }
                Function.LogDebug("set labeled_vehicle_extra_2");

                if (BritishPolicingFunctions.IsPedInsuredToDriveVehicle(DetailedEntity.Entity.RawPedPersona, DetailedEntity.Entity.RawVehiclePersona))
                {
                    labeled_ped_extra_1.Component.SetText("Yes");
                }
                else
                {
                    labeled_ped_extra_1.Component.Warn("No");
                }

                Function.LogDebug("set labeled_ped_extra_1");
            }
            else if (Function.IsTrafficPolicerRunning())
            {
                var insuranceStatus = TrafficPolicerFunction.GetVehicleInsuranceStatus(Vehicle);
                if (insuranceStatus == EVehicleStatus.Valid)
                {
                    labeled_vehicle_insurance_status.Component.SetText("Valid");
                }
                else if (insuranceStatus == EVehicleStatus.Expired)
                {
                    labeled_vehicle_insurance_status.Component.Warn("Expired");
                }
                else
                {
                    labeled_vehicle_insurance_status.Component.Warn("None");
                }

                var registrationStatus = TrafficPolicerFunction.GetVehicleRegistrationStatus(Vehicle);
                if (registrationStatus == EVehicleStatus.Valid)
                {
                    labeled_vehicle_registration_status.Component.SetText("Valid");
                }
                else if (registrationStatus == EVehicleStatus.Expired)
                {
                    labeled_vehicle_registration_status.Component.Warn("Expired");
                }
                else
                {
                    labeled_vehicle_registration_status.Component.Warn("None");
                }
            }
            else
            {
                labeled_vehicle_insurance_status.Hide();
                labeled_vehicle_registration_status.Hide();
            }
        }
Exemple #4
0
        internal static ComputerPlusEntity LookupVehicle(Vehicle vehicle)
        {
            if (!vehicle)
            {
                return(null);
            }
            var vehiclePersona = new VehiclePersona();

            if (Function.IsTrafficPolicerRunning())
            {
                vehiclePersona.HasInsurance = TrafficPolicerFunction.GetVehicleInsuranceStatus(vehicle) == EVehicleStatus.Valid ? true : false;
                vehiclePersona.IsRegistered = TrafficPolicerFunction.GetVehicleRegistrationStatus(vehicle) == EVehicleStatus.Valid ? true : false;
            }

            var ownerName = Functions.GetVehicleOwnerName(vehicle);

            var driver = vehicle.HasDriver ? vehicle.Driver : null;
            ComputerPlusEntity owner = ComputerPedController.Instance.LookupPersona(ownerName);

            if (owner == null && driver != null)
            {
                owner = ComputerPedController.Instance.LookupPersona(driver);
            }
            else
            {
                while (owner == null)
                {
                    //Last ditch effort to make C+ happy by just providing any ped as the owner and setting them as the owner
                    Function.Log(String.Format("LookupVehicle owner was null.. driver may no longer exist", ownerName));
                    var ped = FindRandomPed();
                    owner = new ComputerPlusEntity(ped, Functions.GetPersonaForPed(ped));
                }
            }

            if (!owner.Validate())
            {
                Function.Log(String.Format("LookupVehicle owner was null, performing fixup on {0}", ownerName));

                var parts = ownerName.Split(' ');
                while (parts.Length < 2)
                {
                    parts = LSPD_First_Response.Engine.Scripting.Entities.Persona.GetRandomFullName().Split(' ');
                }
                Functions.SetVehicleOwnerName(vehicle, String.Format("{0} {1}", parts[0], parts[1]));
                //Work some magic to fix the fact that the ped hasn't been spawned in game
                //@TODO parse ped model name for age group and randomize other props

                var ped = FindRandomPed();


                Function.Log("Found a new ped for fixup");
                var persona = new Persona(
                    ped,
                    Gender.Random,
                    RandomDay(),
                    3,
                    parts[0],
                    parts[1],
                    ELicenseState.Valid,
                    1,
                    false,
                    false,
                    false
                    );
                Functions.SetPersonaForPed(ped, persona);
            }


            return(new ComputerPlusEntity(owner.Ped, owner.PedPersona, vehicle, vehiclePersona));
        }
        private void BindData()
        {
            if (!BindNeeded)
            {
                return;
            }
            BindNeeded = false;
            if (DetailedEntity.Entity.IsLicenseValid)
            {
                labeled_license_status.Component.Text = "Valid";
            }
            else
            {
                labeled_license_status.Component.Warn(DetailedEntity.Entity.LicenseStateString);
            }


            if (DetailedEntity.Entity.IsAgent)
            {
                labeled_owner_alert.Component.Warn("Individual is a federal agent");
                labeled_owner_alert.Show();
            }
            else if (DetailedEntity.Entity.IsCop)
            {
                labeled_owner_alert.Component.Warn("Individual is a police officer");
                labeled_owner_alert.Show();
            }
            else
            {
                labeled_owner_alert.Hide();
            }

            if (!String.IsNullOrWhiteSpace(DetailedEntity.Entity.VehicleAlert))
            {
                labeled_alpr.Component.SetText(DetailedEntity.Entity.VehicleAlert);
                labeled_alpr.Show();
            }
            else
            {
                labeled_alpr.Hide();
            }

            cb_action.AddItem("Select One", "Placeholder", QuickActions.PLACEHOLDER);
            cb_action.AddItem("Blip (30 sec)", "Blip", QuickActions.BLIP_VEHICLE);
            cb_action.AddItem("Create Traffic Citation", "TrafficCitation", QuickActions.CREATE_TRAFFIC_CITATION);
            cb_action.AddItem("Create Arrest Report", "ArrestReport", QuickActions.CREATE_ARREST_REPORT_FOR_DRIVER);


            labeled_age.Component.Text          = DetailedEntity.Entity.AgeString;
            labeled_first_name.Component.Text   = DetailedEntity.Entity.FirstName;
            labeled_last_name.Component.Text    = DetailedEntity.Entity.LastName;
            labeled_home_address.Component.Text = Owner.GetHomeAddress();
            labeled_dob.Component.Text          = DetailedEntity.Entity.DOBString;
            if (DetailedEntity.Entity.IsWanted)
            {
                labeled_wanted_status.Component.Warn("Wanted");
            }
            else
            {
                labeled_wanted_status.Component.SetText("None");
            }
            labeled_times_stopped.Component.Text = DetailedEntity.Entity.TimesStopped.ToString();

            labeled_vehicle_model.Component.Text   = Vehicle.Model.Name;
            labeled_vehicle_license.Component.Text = Vehicle.LicensePlate;
            if (ComputerPlusEntity.PersonaType == PersonaTypes.BPS)
            {
                Function.LogDebug(String.Format("Null check is {0} is type {1}", DetailedEntity.Entity.RawPedPersona == null, DetailedEntity.Entity.RawPedPersona is British_Policing_Script.BritishPersona));
                var driverPersona  = (British_Policing_Script.BritishPersona)DetailedEntity.Entity.RawPedPersona;
                var vehiclePersona = (British_Policing_Script.VehicleRecords)DetailedEntity.Entity.RawVehiclePersona;
                Function.LogDebug("Got vehicle persona");
                Function.LogDebug(String.Format("vehiclePersona null {0}| labeled_vehicle_registration_status null {1} | labeled_vehicle_registration_status.Component null {2}", vehiclePersona == null, labeled_vehicle_registration_status, labeled_vehicle_registration_status.Component));
                if (vehiclePersona.IsTaxed)
                {
                    labeled_vehicle_registration_status.Component.SetText("No");
                }
                else
                {
                    labeled_vehicle_registration_status.Component.Warn("Yes");
                }
                Function.LogDebug("set labeled_vehicle_registration_status");


                if (vehiclePersona.Insured)
                {
                    labeled_vehicle_insurance_status.Component.SetText("Yes");
                }
                else
                {
                    labeled_vehicle_insurance_status.Component.Warn("No");
                }
                Function.LogDebug("set labeled_vehicle_insurance_status");

                if (vehiclePersona.HasMOT)
                {
                    labeled_vehicle_extra_1.Component.SetText("Yes");
                }
                else
                {
                    labeled_vehicle_extra_1.Component.Warn("No");
                }
                Function.LogDebug("set labeled_vehicle_extra_1");

                if (vehiclePersona.HasSORN)
                {
                    labeled_vehicle_extra_2.Component.SetText("Yes");
                }
                else
                {
                    labeled_vehicle_extra_2.Component.Warn("No");
                }
                Function.LogDebug("set labeled_vehicle_extra_2");

                if (driverPersona.IsInsuredToDriveVehicle(vehiclePersona))
                {
                    labeled_ped_extra_1.Component.SetText("Yes");
                }
                else
                {
                    labeled_ped_extra_1.Component.Warn("No");
                }

                Function.LogDebug("set labeled_ped_extra_1");
            }
            else if (Function.IsTrafficPolicerRunning())
            {
                if (TrafficPolicerFunction.GetVehicleInsuranceStatus(Vehicle) == EVehicleStatus.Valid)
                {
                    labeled_vehicle_insurance_status.Component.SetText("Valid");
                }
                else
                {
                    labeled_vehicle_insurance_status.Component.Warn("Expired");
                }

                if (TrafficPolicerFunction.GetVehicleRegistrationStatus(Vehicle) == EVehicleStatus.Valid)
                {
                    labeled_vehicle_registration_status.Component.SetText("Valid");
                }
                else
                {
                    labeled_vehicle_registration_status.Component.Warn("Expired");
                }
            }
            else
            {
                labeled_vehicle_insurance_status.Hide();
                labeled_vehicle_registration_status.Hide();
            }
        }
Exemple #6
0
        private void BindData()
        {
            switch (OwnerPersona.LicenseState)
            {
            case ELicenseState.Expired:
                text_license_status.Warn("Expired");
                break;

            case ELicenseState.None:
                text_license_status.Text = "None";
                break;

            case ELicenseState.Suspended:
                text_license_status.Warn("Suspended");
                break;

            case ELicenseState.Valid:
                text_license_status.Text = "Valid";
                break;
            }

            if (OwnerPersona.IsAgent)
            {
                text_license_status.Warn("Individual is a federal agent");
                lbl_alert.Show();
            }
            else if (OwnerPersona.IsCop)
            {
                text_license_status.Warn("Individual is a police officer");
                lbl_alert.Show();
            }

            if (!String.IsNullOrWhiteSpace(VehiclePersona.Alert))
            {
                lbl_vehicle_alert.Text = VehiclePersona.Alert;
                lbl_vehicle_alert.Show();
                lbl_vehicle_alert_label.Show();
            }
            else
            {
                lbl_vehicle_alert_label.Hide();
                lbl_vehicle_alert.Hide();
            }

            cb_action.AddItem("Select One", "Placeholder");
            cb_action.AddItem("Blip (30 sec)", "Blip");

            var age = (DateTime.Today - OwnerPersona.BirthDay).Days / 365.25m;

            text_age.Text          = ((int)age).ToString();
            text_first_name.Text   = OwnerPersona.Forename;
            text_last_name.Text    = OwnerPersona.Surname;
            text_home_address.Text = Owner.GetHomeAddress();
            text_dob.Text          = OwnerPersona.BirthDay.ToString("MM/dd/yyyy");
            text_dob.SetToolTipText("MM/dd/yyyy");
            if (OwnerPersona.Wanted)
            {
                text_wanted_status.Warn("Wanted");
            }
            else
            {
                text_wanted_status.SetText("None");
            }
            text_times_stopped.Text = OwnerPersona.TimesStopped.ToString();

            text_vehicle_model.Text   = Vehicle.Model.Name;
            text_vehicle_license.Text = Vehicle.LicensePlate;
            if (Function.IsTrafficPolicerRunning())
            {
                if (TrafficPolicerFunction.GetVehicleInsuranceStatus(Vehicle) == EVehicleStatus.Valid)
                {
                    text_vehicle_insurance_status.SetText("Valid");
                }
                else
                {
                    text_vehicle_insurance_status.Warn("Expired");
                }

                if (TrafficPolicerFunction.GetVehicleRegistrationStatus(Vehicle) == EVehicleStatus.Valid)
                {
                    text_vehicle_registration_status.SetText("Valid");
                }
                else
                {
                    text_vehicle_registration_status.Warn("Expired");
                }
            }
            else
            {
                text_vehicle_insurance_status.Hide();
                text_vehicle_registration_status.Hide();
                lbl_insurance_status.Hide();
                lbl_registration_status.Hide();
            }
        }