public static void LoadPedFromPedData(PedData pedData) { Ped ped = World.CreatePed(pedData.Hash, pedData.Position); SurvivorPed item = new SurvivorPed(ped); Population.survivorList.Add(item); if (ped != null) { ped.Rotation = pedData.Rotation; pedData.Weapons.ForEach(w => ped.Weapons.Give(w.Hash, w.Ammo, true, true)); pedData.Handle = ped.Handle; ped.Recruit(Game.Player.Character); SetPedTasks(ped, pedData.Task); } }
public static void AddPedData(Ped ped) { PedTasks task = Population.survivorList.Find(a => a.pedEntity == ped).tasks; IEnumerable <WeaponHash> source = from hash in (WeaponHash[])Enum.GetValues(typeof(WeaponHash)) where ped.Weapons.HasWeapon(hash) select hash; WeaponComponent[] componentHashes = (WeaponComponent[])Enum.GetValues(typeof(WeaponComponent)); PedData item = new PedData(ped.Handle, ped.Model.Hash, ped.Rotation, ped.Position, task, source.ToList <WeaponHash>().ConvertAll <UndeadStreets.Weapon>(delegate(WeaponHash hash) { GTA.Weapon weapon = ped.Weapons[hash]; return(new UndeadStreets.Weapon(weapon.Ammo, weapon.Hash, (from h in componentHashes where weapon.IsComponentActive(h) select h).ToArray <WeaponComponent>())); }).ToList <UndeadStreets.Weapon>()); PlayerPedCollection.Add(item); }