public void AddCraftingCooking(UIMenu menu) { UIMenuItem cookRawMeat = new UIMenuItem("Cook Raw Meat", "Cook Raw Meat so it can be eaten"); cookRawMeat.SetRightLabel("(" + playerMaterialInventory.Find(material => material.Name == "Raw Meat").Amount + ")"); menu.AddItem(cookRawMeat); craftCampfireMenu.OnItemSelect += delegate(UIMenu sender, UIMenuItem item, int index) { int amount = playerMaterialInventory.Find(material => material.Name == "Raw Meat").Amount; int num2 = playerMaterialInventory.Find(material => material.Name == "Raw Meat").Amount; int maxAmount = playerMaterialInventory.Find(material => material.Name == "Raw Meat").MaxAmount; if (amount <= 0) { UI.Notify("You have no ~b~Raw Meat~w~ to cook"); } else if (num2 == maxAmount) { UI.Notify("Your inventory is full!"); } else { InventoryMaterial local5 = playerMaterialInventory.Find(material => material.Name == "Raw Meat"); local5.Amount--; InventoryItem local7 = playerItemInventory.Find(items => items.Name == "Cooked Meat"); local7.Amount++; cookRawMeat.SetRightLabel("(" + playerMaterialInventory.Find(material => material.Name == "Raw Meat").Amount + ")"); object[] objArray1 = new object[5]; objArray1[0] = "("; objArray1[1] = playerMaterialInventory.Find(material => material.Name == "Raw Meat").Amount; object[] local11 = objArray1; local11[2] = "/"; local11[3] = playerMaterialInventory.Find(material => material.Name == "Raw Meat").MaxAmount; object[] local13 = local11; local13[4] = ")"; materialsSubMenu.MenuItems.Find(material => material.Text == "Raw Meat").SetRightLabel(string.Concat(local13)); object[] objArray2 = new object[5]; objArray2[0] = "("; objArray2[1] = playerItemInventory.Find(items => items.Name == "Cooked Meat").Amount; object[] local16 = objArray2; local16[2] = "/"; local16[3] = playerItemInventory.Find(items => items.Name == "Cooked Meat").MaxAmount; object[] local18 = local16; local18[4] = ")"; itemsSubMenu.MenuItems.Find(items => items.Text == "Cooked Meat").SetRightLabel(string.Concat(local18)); UI.Notify("You've made some ~b~Cooked Meat~w~!"); } }; }
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 closest = World.GetClosest <Prop>(Game.Player.Character.Position, World.GetNearbyProps(Game.Player.Character.Position, 2.5f)); if (closest == 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 (closest == 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; } } Game.Player.CanControlCharacter = !craftCampfireMenu.Visible; Ped ped = World.GetClosest <Ped>(Game.Player.Character.Position, World.GetNearbyPeds(Game.Player.Character, 1.5f)); if (((ped == null) || (!ped.IsDead || !ped.IsHuman)) || this.lootedPeds.Contains(ped)) { if (((ped != null) && (ped.IsDead && !ped.IsHuman)) && !this.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)(-1716189206))) { UI.Notify("You need a knife to harvest ~b~Raw Meat~w~ from dead animals!", true); } else if (Inventory.playerMaterialInventory.Find(material => material.Name == "Raw Meat").Amount == Inventory.playerMaterialInventory.Find(material => material.Name == "Raw Meat").MaxAmount) { UI.Notify("You cannot carry any more ~b~Raw Meat~w~!", true); } else { Game.Player.Character.Weapons.Select((WeaponHash)(-1716189206), true); Game.Player.Character.Task.PlayAnimation("pickup_object", "pickup_low", 8f, 0xbb8, AnimationFlags.None); InventoryMaterial local7 = Inventory.playerMaterialInventory.Find(material => material.Name == "Raw Meat"); local7.Amount++; object[] objArray5 = new object[5]; objArray5[0] = "("; objArray5[1] = Inventory.playerMaterialInventory.Find(item => item.Name == "Raw Meat").Amount; object[] local10 = objArray5; local10[2] = "/"; local10[3] = Inventory.playerMaterialInventory.Find(item => item.Name == "Raw Meat").MaxAmount; object[] local12 = local10; local12[4] = ")"; materialsSubMenu.MenuItems.Find(item => item.Text == "Raw Meat").SetRightLabel(string.Concat(local12)); craftCampfireMenu.MenuItems[0].SetRightLabel("(" + Inventory.playerMaterialInventory.Find(material => material.Name == "Raw Meat").Amount + ")"); object[] objArray6 = new object[5]; objArray6[0] = "You have harvested ~b~Raw Meat ~g~("; objArray6[1] = Inventory.playerMaterialInventory.Find(material => material.Name == "Raw Meat").Amount; object[] local15 = objArray6; local15[2] = "/"; local15[3] = Inventory.playerMaterialInventory.Find(material => material.Name == "Raw Meat").MaxAmount; object[] local17 = local15; local17[4] = ")"; UI.Notify(string.Concat(local17), true); this.lootedPeds.Add(ped); } } } } else { 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 num = RandoMath.CachedRandom.Next(0, 10); if (num < 3) { List <InventoryItem> playerItemInventory = Inventory.playerItemInventory; int num4 = 0; while (true) { if (num4 >= playerItemInventory.Count) { InventoryItem itemFound = RandoMath.GetRandomElementFromList <InventoryItem>(playerItemInventory); if (Inventory.playerItemInventory.Find(item => item.Name == itemFound.Name).Amount == Inventory.playerItemInventory.Find(item => item.Name == itemFound.Name).MaxAmount) { UI.Notify("Found ~b~" + itemFound.Name + "~w~ but inventory is full!", true); } else { InventoryItem local1 = Inventory.playerItemInventory.Find(item => item.Name == itemFound.Name); local1.Amount++; object[] objArray1 = new object[] { "Found ~b~", itemFound.Name, "~g~ (", Inventory.playerItemInventory.Find(item => item.Name == itemFound.Name).Amount, "/", Inventory.playerItemInventory.Find(item => item.Name == itemFound.Name).MaxAmount, ")" }; UI.Notify(string.Concat(objArray1), true); this.lootedPeds.Add(ped); object[] objArray2 = new object[] { "(", Inventory.playerItemInventory.Find(item => item.Name == itemFound.Name).Amount, "/", Inventory.playerItemInventory.Find(item => item.Name == itemFound.Name).MaxAmount, ")" }; itemsSubMenu.MenuItems.Find(item => item.Text == itemFound.Name).SetRightLabel(string.Concat(objArray2)); } break; } if (playerItemInventory[num4].GetType() == typeof(InventoryCraftableFoodItem)) { playerItemInventory.Remove(playerItemInventory[num4]); } num4++; } } else if (num <= 5) { UI.Notify("Found nothing", true); this.lootedPeds.Add(ped); } else { List <InventoryMaterial> playerMaterialInventory = Inventory.playerMaterialInventory; int num8 = 0; while (true) { if (num8 >= playerMaterialInventory.Count) { InventoryItem materialFound = RandoMath.GetRandomElementFromList <InventoryMaterial>(playerMaterialInventory); if (Inventory.playerMaterialInventory.Find(material => material.Name == materialFound.Name).Amount == Inventory.playerMaterialInventory.Find(material => material.Name == materialFound.Name).MaxAmount) { UI.Notify("Found ~b~" + materialFound.Name + "~w~ but inventory is full!", true); } else { InventoryMaterial local2 = Inventory.playerMaterialInventory.Find(material => material.Name == materialFound.Name); local2.Amount++; object[] objArray3 = new object[] { "Found ~b~", materialFound.Name, "~g~ (", Inventory.playerMaterialInventory.Find(material => material.Name == materialFound.Name).Amount, "/", Inventory.playerMaterialInventory.Find(material => material.Name == materialFound.Name).MaxAmount, ")" }; UI.Notify(string.Concat(objArray3), true); this.lootedPeds.Add(ped); object[] objArray4 = new object[] { "(", Inventory.playerMaterialInventory.Find(item => item.Name == materialFound.Name).Amount, "/", Inventory.playerMaterialInventory.Find(item => item.Name == materialFound.Name).MaxAmount, ")" }; materialsSubMenu.MenuItems.Find(item => item.Text == materialFound.Name).SetRightLabel(string.Concat(objArray4)); craftCampfireMenu.MenuItems.Find(item => item.Text == materialFound.Name).SetRightLabel("(" + Inventory.playerMaterialInventory.Find(material => material.Name == "Raw Meat").Amount + ")"); } break; } if ((playerMaterialInventory[num8].GetType() == typeof(InventoryCraftableMaterial)) || (playerMaterialInventory[num8].Name == "Raw Meat")) { playerMaterialInventory.Remove(playerMaterialInventory[num8]); } num8++; } } } } } catch (Exception exception1) { Debug.Log(exception1.ToString()); } } }
public MaterialCraftable(InventoryMaterial material, int requiredAmount) { this.Material = material; this.RequiredAmount = requiredAmount; }