private static ComputerPlusEntity generateVehicleOwner(string ownerName) { Ped ped = null; while (ped == null) { //Last ditch effort to make C+ happy by just providing any ped as the owner and setting them as the owner ped = FindRandomPed(); if (ped != null && !ped.IsValid()) { ped = null; } } var parts = ownerName.Split(' '); while (parts.Length < 2) { parts = Persona.GetRandomFullName().Split(' '); } int timesStopped = Globals.Random.Next(0, 4); var persona = new Persona(ped, Gender.Random, RandomDay(), Globals.Random.Next(0, timesStopped + 1), parts[0], parts[1], ELicenseState.Valid, timesStopped, false, false, false); Functions.SetPersonaForPed(ped, persona); return(ComputerPlusEntity.CreateFrom(ped)); }
internal ComputerPlusEntity LookupPersona(Ped ped) { if (ped == null || (ped != null && !ped.Exists())) { return(null); } return(insertEntityToRecentSearches(ComputerPlusEntity.CreateFrom(ped))); }
internal ComputerPlusEntity LookupPersona(Ped ped) { if (ped == null) { return(null); } var entity = ComputerPlusEntity.CreateFrom(ped); RecentSearches.Add(entity); return(entity); }
internal ComputerPlusEntity LookupPersona(String name) { List <Ped> peds = World.GetAllPeds().ToList(); peds.RemoveAll(p => !p || !p.Exists()); peds.OrderBy(p => p.DistanceTo(Game.LocalPlayer.Character.Position)); var ped = peds.Where(p => p && Functions.GetPersonaForPed(p).FullName.ToLower().Equals(name, StringComparison.CurrentCultureIgnoreCase)) .FirstOrDefault(); if (ped == null) { return(null); } return(ComputerPlusEntity.CreateFrom(ped)); }
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)); }