public static void ShowTrafficCitationCreate(TrafficCitation citation, ComputerPlusEntity entity = null, TrafficCitationView.TrafficCitationActionEvent callbackDelegate = null)
        {
            TrafficCitation mCitation = null;

            if (citation == null && entity == null)
            {
                mCitation = Globals.PendingTrafficCitation != null ? Globals.PendingTrafficCitation : new TrafficCitation();
            }
            else if (citation == null && entity.Validate())
            {
                Function.Log("Creating Traffic Citation for ped in vehicle");
                mCitation = TrafficCitation.CreateForPedInVehicle(entity);
                Globals.PendingTrafficCitation = mCitation;
                Function.Log("Created Traffic Citation for ped  " + mCitation.FirstName);
            }
            else if (citation != null && citation == Globals.PendingTrafficCitation && !citation.FullName.Equals(entity.FullName))
            {
                if (entity.Validate())
                {
                    mCitation = TrafficCitation.CreateForPedInVehicle(entity);
                }
                else
                {
                    mCitation = new TrafficCitation();
                }
                Globals.PendingTrafficCitation = mCitation;
            }
            else
            {
                mCitation = citation;
            }
            Globals.Navigation.Push(new TrafficCitationCreateContainer(mCitation, TrafficCitationView.ViewTypes.CREATE, callbackDelegate));
        }
Exemple #2
0
        internal static ComputerPlusEntity LookupVehicle(Vehicle vehicle)
        {
            if (!vehicle)
            {
                return(null);
            }
            var vehiclePersona = ComputerPlusEntity.GetPersonaForVehicle(vehicle);

            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
                    var ped = FindRandomPed();
                    owner = ComputerPlusEntity.CreateFrom(ped);
                }
            }

            if (!owner.Validate())
            {
                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();


                var persona = new Persona(
                    ped,
                    Gender.Random,
                    RandomDay(),
                    3,
                    parts[0],
                    parts[1],
                    ELicenseState.Valid,
                    1,
                    false,
                    false,
                    false
                    );
                Functions.SetPersonaForPed(ped, persona);
            }


            return(ComputerPlusEntity.CloneFrom(owner, vehicle, vehiclePersona));
        }