public static void LoadPedFromPedData(PedData pedData) { Ped ped = World.CreatePed(pedData.Hash, pedData.Position); SurvivorPed survivorPed = new SurvivorPed(ped); Population.survivorList.Add(survivorPed); if (!(ped == null)) { ped.Rotation = pedData.Rotation; pedData.Weapons.ForEach(delegate(Weapon 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) { SurvivorPed survivorPed = Population.survivorList.Find(match: a => a.pedEntity == ped); PedTasks pedTasks = survivorPed.tasks; IEnumerable <WeaponHash> hashes = from hash in (WeaponHash[])Enum.GetValues(typeof(WeaponHash)) where ped.Weapons.HasWeapon(hash) select hash; WeaponComponent[] componentHashes = (WeaponComponent[])Enum.GetValues(typeof(WeaponComponent)); List <Weapon> weapons = hashes.ToList().ConvertAll(delegate(WeaponHash hash) { GTA.Weapon weapon = ped.Weapons[hash]; WeaponComponent[] components = (from h in componentHashes where weapon.IsComponentActive(h) select h).ToArray(); return(new Weapon(weapon.Ammo, weapon.Hash, components)); }).ToList(); PedData pedData = new PedData(ped.Handle, ped.Model.Hash, ped.Rotation, ped.Position, pedTasks, weapons); PlayerPedCollection.Add(pedData); }