public static void SaveGroup() { List <Ped> group = Game.Player.Character.CurrentPedGroup.ToList(false); if (group.Count > 0) { for (int i = 0; i < PlayerGroup.PlayerPedCollection.Count; i++) { PlayerGroup.PlayerPedCollection.RemoveAt(i); } foreach (Ped ped in group) { PlayerGroup.AddPedData(ped); } try { WriteToBinaryFile("./scripts/CWDM/SaveGame/Group.sav", PlayerGroup.PlayerPedCollection); UI.Notify("~p~Group ~w~saved!"); } catch (Exception x) { Debug.Log(x.ToString()); } } else { UI.Notify("You have no one in your group!"); } }
public static void Recruit(this Ped ped, Ped leader) { if (!(leader == null)) { PedGroup group = leader.CurrentPedGroup; ped.LeaveGroup(); Function.Call(Hash.SET_PED_RAGDOLL_ON_COLLISION, ped.Handle, false); ped.Task.ClearAll(); group.SeparationRange = 2.14748365E+09f; if (!group.Contains(leader)) { group.Add(leader, true); } if (!group.Contains(ped)) { group.Add(ped, false); } ped.IsPersistent = true; ped.RelationshipGroup = leader.RelationshipGroup; ped.NeverLeavesGroup = true; Blip currentBlip = ped.CurrentBlip; if (currentBlip.Type != 0) { currentBlip.Remove(); } Blip blip = ped.AddBlip(); blip.Color = BlipColor.Green; blip.Scale = 0.65f; blip.Name = "Group"; PlayerGroup.SetPedTasks(ped, PedTasks.Follow); } }
public static void SaveWeapons() { for (int i = 0; i < PlayerGroup.PlayerWeapons.Count; i++) { PlayerGroup.PlayerWeapons.RemoveAt(i); } PlayerGroup.SavePlayerWeapons(); try { WriteToBinaryFile("./scripts/CWDM/SaveGame/Weapons.sav", PlayerGroup.PlayerWeapons); UI.Notify("~r~Weapons~w~ saved!"); } catch (Exception x) { Debug.Log(x.ToString()); } }
public void AddMenuApplyToAll(UIMenu menu) { var newitem = new UIMenuItem("Set Task (All)", "Set task for all Group members"); menu.AddItem(newitem); menu.OnItemSelect += (sender, item, index) => { if (item == newitem) { List <Ped> group = Game.Player.Character.CurrentPedGroup.ToList(false); foreach (Ped ped in group) { PlayerGroup.SetPedTasks(ped, taskApply); } UI.Notify("You have given seleted task to all ~p~Group ~w~members"); } mainMenu.Visible = !mainMenu.Visible; }; }
public static void LoadWeapons() { if (File.Exists("./scripts/CWDM/SaveGame/Weapons.sav")) { PlayerGroup.PlayerWeapons = ReadFromBinaryFile <List <Weapon> >("./scripts/CWDM/SaveGame/Weapons.sav"); if (PlayerGroup.PlayerWeapons.Count > 0) { Game.Player.Character.Weapons.RemoveAll(); PlayerGroup.LoadPlayerWeapons(); UI.Notify("~r~Weapons ~w~loaded!"); } else { UI.Notify("~r~Weapons ~w~load failed!"); } } else { UI.Notify("No ~r~Weapons ~w~available to load!"); } }
public static void LoadGroup() { if (File.Exists("./scripts/CWDM/SaveGame/Group.sav")) { PlayerGroup.PlayerPedCollection = ReadFromBinaryFile <PedCollection>("./scripts/CWDM/SaveGame/Group.sav"); if (PlayerGroup.PlayerPedCollection.Count > 0) { List <PedData> pedDatas = PlayerGroup.PlayerPedCollection.ToList(); List <Ped> oldGroup = Game.Player.Character.CurrentPedGroup.ToList(false); foreach (Ped ped in oldGroup) { Blip currentBlip = ped.CurrentBlip; if (currentBlip.Type != 0) { currentBlip.Remove(); } ped.LeaveGroup(); int i = Population.survivorList.FindIndex(match: a => a.pedEntity == ped); Population.survivorList.RemoveAt(i); ped.MarkAsNoLongerNeeded(); ped.Delete(); } foreach (PedData pedData in pedDatas) { PlayerGroup.LoadPedFromPedData(pedData); } UI.Notify("~p~Group ~w~loaded!"); } else { UI.Notify("~p~Group ~w~load failed!"); } } else { UI.Notify("No ~p~Group ~w~available to load!"); } }
public static void SurvivorGroupSpawn(Vector3 pos, GroupType groupType = GroupType.Random, int groupSize = -1, PedTasks pedTasks = PedTasks.Wander) { if (groupType == GroupType.Random) { int rndGroupType = RandoMath.CachedRandom.Next(0, 3); if (rndGroupType == 0) { groupType = GroupType.Friendly; } if (rndGroupType == 1) { groupType = GroupType.Neutral; } if (rndGroupType == 2) { groupType = GroupType.Hostile; } } List <Ped> peds = new List <Ped>(); PedGroup group = new PedGroup(); if (groupSize == -1) { groupSize = RandoMath.CachedRandom.Next(3, 9); } for (int i = 0; i < groupSize; i++) { SurvivorPed sPed = SurvivorSpawn(pos); if (groupType == GroupType.Friendly) { sPed.pedEntity.RelationshipGroup = Relationships.FriendlyGroup; sPed.pedEntity.AddBlip(); sPed.pedEntity.CurrentBlip.Color = BlipColor.Blue; sPed.pedEntity.CurrentBlip.Scale = 0.65f; sPed.pedEntity.CurrentBlip.Name = "Friendly"; } else if (groupType == GroupType.Neutral) { sPed.pedEntity.RelationshipGroup = Relationships.NeutralGroup; sPed.pedEntity.AddBlip(); sPed.pedEntity.CurrentBlip.Color = BlipColor.Yellow; sPed.pedEntity.CurrentBlip.Scale = 0.65f; sPed.pedEntity.CurrentBlip.Name = "Neutral"; } else if (groupType == GroupType.Hostile) { sPed.pedEntity.RelationshipGroup = Relationships.HostileGroup; sPed.pedEntity.AddBlip(); sPed.pedEntity.CurrentBlip.Color = BlipColor.Red; sPed.pedEntity.CurrentBlip.Scale = 0.65f; sPed.pedEntity.CurrentBlip.Name = "Hostile"; } peds.Add(sPed.pedEntity); } foreach (Ped ped in peds) { if (group.MemberCount < 1) { group.Add(ped, true); } else { group.Add(ped, false); } } group.FormationType = 0; List <Ped> groupPeds = group.ToList(true); foreach (Ped ped in groupPeds) { PlayerGroup.SetPedTasks(ped, pedTasks); } }