public void OnTick(object sender, EventArgs e) { if (Main.ModActive) { Ped ped = World.GetClosest(Game.Player.Character.Position, World.GetNearbyPeds(Game.Player.Character, 1.5f)); if (!(ped == null) && !ped.IsDead && ped.IsHuman && ped.RelationshipGroup == Relationships.FriendlyGroup) { Extensions.DisplayHelpTextThisFrame("Press ~INPUT_CONTEXT~ to recruit"); Game.DisableControlThisFrame(2, GTA.Control.Context); if (Game.IsDisabledControlJustPressed(2, GTA.Control.Context)) { try { ped.Recruit(Game.Player.Character); } catch (Exception x) { Debug.Log(x.ToString()); } } } else if (!(ped == null) && !ped.IsDead && ped.IsHuman && ped.RelationshipGroup == Game.Player.Character.RelationshipGroup) { Extensions.DisplayHelpTextThisFrame("Press ~INPUT_CONTEXT~ to manage Group"); Game.DisableControlThisFrame(2, GTA.Control.Context); if (Game.IsDisabledControlJustPressed(2, GTA.Control.Context) && !Main.MasterMenuPool.IsAnyMenuOpen()) { currentGroupPed = ped; mainMenu.Visible = !mainMenu.Visible; } } } }
public void OnTick(object sender, EventArgs e) { if (Game.Player.Character.IsDead) { inventoryMenu.Visible = false; craftCampfireMenu.Visible = false; } if (Main.ModActive) { Game.DisableControlThisFrame(2, GTA.Control.Phone); if (Game.IsDisabledControlJustPressed(2, GTA.Control.Phone) && !Main.MasterMenuPool.IsAnyMenuOpen()) { inventoryMenu.Visible = !inventoryMenu.Visible; } } if (Main.ModActive && !Game.Player.Character.IsInVehicle()) { try { Prop prop = World.GetClosest(Game.Player.Character.Position, World.GetNearbyProps(Game.Player.Character.Position, 2.5f)); if (prop == Character.tent) { Extensions.DisplayHelpTextThisFrame("Press ~INPUT_CONTEXT~ to sleep in Tent"); Game.DisableControlThisFrame(2, GTA.Control.Context); if (Game.IsDisabledControlJustPressed(2, GTA.Control.Context)) { Population.Sleep(Game.Player.Character.Position); } } else if (prop == Character.campFire) { Extensions.DisplayHelpTextThisFrame("Press ~INPUT_CONTEXT~ to craft using Campfire"); Game.DisableControlThisFrame(2, GTA.Control.Context); if (Game.IsDisabledControlJustPressed(2, GTA.Control.Context)) { craftCampfireMenu.Visible = !craftCampfireMenu.Visible; } } if (craftCampfireMenu.Visible) { Game.Player.CanControlCharacter = false; } else { Game.Player.CanControlCharacter = true; } Ped ped = World.GetClosest(Game.Player.Character.Position, World.GetNearbyPeds(Game.Player.Character, 1.5f)); if (!(ped == null) && ped.IsDead && ped.IsHuman && !lootedPeds.Contains(ped)) { Extensions.DisplayHelpTextThisFrame("Press ~INPUT_CONTEXT~ to search corpse"); Game.DisableControlThisFrame(2, GTA.Control.Context); if (Game.IsDisabledControlJustPressed(2, GTA.Control.Context)) { Game.Player.Character.Task.PlayAnimation("pickup_object", "pickup_low"); int itemRnd = RandoMath.CachedRandom.Next(0, 10); if (itemRnd < 3) { List <InventoryItem> itemsToFind = playerItemInventory; for (int i = 0; i < itemsToFind.Count; i++) { if (itemsToFind[i].GetType() == typeof(InventoryCraftableFoodItem)) { itemsToFind.Remove(itemsToFind[i]); } } InventoryItem itemFound = RandoMath.GetRandomElementFromList(itemsToFind); int invCheckAmount = playerItemInventory.Find(item => item.Name == itemFound.Name).Amount; int invCheckMaxAmount = playerItemInventory.Find(item => item.Name == itemFound.Name).MaxAmount; if (invCheckAmount == invCheckMaxAmount) { UI.Notify("Found ~b~" + itemFound.Name + "~w~ but inventory is full!", true); } else { playerItemInventory.Find(item => item.Name == itemFound.Name).Amount++; UI.Notify("Found ~b~" + itemFound.Name + "~g~ (" + playerItemInventory.Find(item => item.Name == itemFound.Name).Amount + "/" + playerItemInventory.Find(item => item.Name == itemFound.Name).MaxAmount + ")", true); lootedPeds.Add(ped); itemsSubMenu.MenuItems.Find(item => item.Text == itemFound.Name).SetRightLabel("(" + playerItemInventory.Find(item => item.Name == itemFound.Name).Amount + "/" + playerItemInventory.Find(item => item.Name == itemFound.Name).MaxAmount + ")"); } } else if (itemRnd > 5) { List <InventoryMaterial> materialsToFind = playerMaterialInventory; for (int i = 0; i < materialsToFind.Count; i++) { if (materialsToFind[i].GetType() == typeof(InventoryCraftableMaterial) || materialsToFind[i].Name == "Raw Meat") { materialsToFind.Remove(materialsToFind[i]); } } InventoryItem materialFound = RandoMath.GetRandomElementFromList(materialsToFind); int invCheckAmount = playerMaterialInventory.Find(material => material.Name == materialFound.Name).Amount; int invCheckMaxAmount = playerMaterialInventory.Find(material => material.Name == materialFound.Name).MaxAmount; if (invCheckAmount == invCheckMaxAmount) { UI.Notify("Found ~b~" + materialFound.Name + "~w~ but inventory is full!", true); } else { playerMaterialInventory.Find(material => material.Name == materialFound.Name).Amount++; UI.Notify("Found ~b~" + materialFound.Name + "~g~ (" + playerMaterialInventory.Find(material => material.Name == materialFound.Name).Amount + "/" + playerMaterialInventory.Find(material => material.Name == materialFound.Name).MaxAmount + ")", true); lootedPeds.Add(ped); materialsSubMenu.MenuItems.Find(item => item.Text == materialFound.Name).SetRightLabel("(" + playerMaterialInventory.Find(item => item.Name == materialFound.Name).Amount + "/" + playerMaterialInventory.Find(item => item.Name == materialFound.Name).MaxAmount + ")"); craftCampfireMenu.MenuItems.Find(item => item.Text == materialFound.Name).SetRightLabel("(" + playerMaterialInventory.Find(material => material.Name == "Raw Meat").Amount + ")"); } } else { UI.Notify("Found nothing", true); lootedPeds.Add(ped); } } } else if (!(ped == null) && ped.IsDead && !ped.IsHuman && !lootedPeds.Contains(ped)) { Extensions.DisplayHelpTextThisFrame("Press ~INPUT_CONTEXT~ to harvest meat from animal corpse"); Game.DisableControlThisFrame(2, GTA.Control.Context); if (Game.IsDisabledControlJustPressed(2, GTA.Control.Context)) { if (Game.Player.Character.Weapons.HasWeapon(WeaponHash.Knife)) { int invCheckAmount = playerMaterialInventory.Find(material => material.Name == "Raw Meat").Amount; int invCheckMaxAmount = playerMaterialInventory.Find(material => material.Name == "Raw Meat").MaxAmount; if (invCheckAmount == invCheckMaxAmount) { UI.Notify("You cannot carry any more ~b~Raw Meat~w~!", true); } else { Game.Player.Character.Weapons.Select(WeaponHash.Knife, true); Game.Player.Character.Task.PlayAnimation("pickup_object", "pickup_low", 8f, 3000, AnimationFlags.None); playerMaterialInventory.Find(material => material.Name == "Raw Meat").Amount++; materialsSubMenu.MenuItems.Find(item => item.Text == "Raw Meat").SetRightLabel("(" + playerMaterialInventory.Find(item => item.Name == "Raw Meat").Amount + "/" + playerMaterialInventory.Find(item => item.Name == "Raw Meat").MaxAmount + ")"); craftCampfireMenu.MenuItems[0].SetRightLabel("(" + playerMaterialInventory.Find(material => material.Name == "Raw Meat").Amount + ")"); UI.Notify("You have harvested ~b~Raw Meat ~g~(" + playerMaterialInventory.Find(material => material.Name == "Raw Meat").Amount + "/" + playerMaterialInventory.Find(material => material.Name == "Raw Meat").MaxAmount + ")", true); lootedPeds.Add(ped); } } else { UI.Notify("You need a knife to harvest ~b~Raw Meat~w~ from dead animals!", true); } } } } catch (Exception x) { Debug.Log(x.ToString()); } } }