public static void Add(int houseID, int furnID, nItem item) { HouseFurniture furniture = HouseFurnitures[houseID][furnID]; var type = SafesType[furniture.Name]; var items = FurnituresItems[houseID][furnID]; if (nInventory.ClothesItems.Contains(item.Type) || nInventory.WeaponsItems.Contains(item.Type) || item.Type == ItemType.CarKey) { items.Add(item); } else { var count = item.Count; for (int i = 0; i < items.Count; i++) { if (i >= items.Count) { break; } if (items[i].Type == item.Type && items[i].Count < nInventory.ItemsStacks[item.Type]) { var temp = nInventory.ItemsStacks[item.Type] - items[i].Count; if (count < temp) { temp = count; } items[i].Count += temp; count -= temp; } } while (count > 0) { if (count >= nInventory.ItemsStacks[item.Type]) { items.Add(new nItem(item.Type, nInventory.ItemsStacks[item.Type], item.Data)); count -= nInventory.ItemsStacks[item.Type]; } else { items.Add(new nItem(item.Type, count, item.Data)); count = 0; } } } FurnituresItems[houseID][furnID] = items; foreach (var p in NAPI.Pools.GetAllPlayers()) { if (p == null || !Main.Players.ContainsKey(p)) { continue; } if ((p.HasData("OPENOUT_TYPE") && p.GetData("OPENOUT_TYPE") == type) && (Main.Players[p].InsideHouseID != -1 && Main.Players[p].InsideHouseID == houseID) && (p.HasData("OpennedSafe") && p.GetData("OpennedSafe") == furnID)) { GUI.Dashboard.OpenOut(p, items, furniture.Name, type); } } }
public static int TryAdd(int houseID, int furnID, nItem item) { HouseFurniture furniture = HouseFurnitures[houseID][furnID]; var items = FurnituresItems[houseID][furnID]; var tail = 0; if (nInventory.ClothesItems.Contains(item.Type) || item.Type == ItemType.CarKey) { if (items.Count >= 25) { return(-1); } } else { var count = 0; foreach (var i in items) { if (i.Type == item.Type) { count += nInventory.ItemsStacks[i.Type] - i.Count; } } var slots = 25; var maxCapacity = (slots - items.Count) * nInventory.ItemsStacks[item.Type] + count; if (item.Count > maxCapacity) { tail = item.Count - maxCapacity; } } return(tail); }
public void Loot(Client player) { if (player.HasData("HEIST_DRILL")) { Notify.Send(player, NotifyType.Error, NotifyPosition.BottomCenter, $"У Вас уже есть сумка", 3000); return; } if (SafeLoot == 0) { Notify.Send(player, NotifyType.Error, NotifyPosition.BottomCenter, $"В сейфе больше нет денег", 3000); return; } var money = (SafeLoot >= SafeMain.MaxMoneyInBag) ? SafeMain.MaxMoneyInBag : SafeLoot; if (player.HasData("HAND_MONEY")) { var item = nInventory.Find(Main.Players[player].UUID, ItemType.BagWithMoney); var lefts = (item == null) ? 0 : Convert.ToInt32(item.Data.ToString()); if (lefts == SafeMain.MaxMoneyInBag) { Notify.Send(player, NotifyType.Error, NotifyPosition.BottomCenter, $"Ваша сумка полностью забита деньгами", 3000); return; } if (money + lefts > SafeMain.MaxMoneyInBag) { money = (SafeMain.MaxMoneyInBag - lefts); } lefts += money; item.Data = $"{lefts}"; Notify.Send(player, NotifyType.Success, NotifyPosition.BottomCenter, $"Теперь в Вашей сумке {lefts}$", 3000); } else { var item = new nItem(ItemType.BagWithMoney, 1, $"{money}"); nInventory.Items[Main.Players[player].UUID].Add(item); Notify.Send(player, NotifyType.Success, NotifyPosition.BottomCenter, $"Вы взяли сумку с {money}$", 3000); } Dashboard.sendItems(player); player.SetClothes(5, 45, 0); player.SetData("HAND_MONEY", true); SafeLoot -= money; return; }
public static void Remove(int houseID, int furnID, nItem item) { HouseFurniture furniture = HouseFurnitures[houseID][furnID]; var safeType = SafesType[furniture.Name]; var items = FurnituresItems[houseID][furnID]; if (nInventory.ClothesItems.Contains(item.Type) || nInventory.WeaponsItems.Contains(item.Type) || item.Type == ItemType.CarKey) { items.Remove(item); } else { for (int i = items.Count - 1; i >= 0; i--) { if (i >= items.Count) { continue; } if (items[i].Type != item.Type) { continue; } if (items[i].Count <= item.Count) { item.Count -= items[i].Count; items.RemoveAt(i); } else { items[i].Count -= item.Count; item.Count = 0; break; } } } FurnituresItems[houseID][furnID] = items; foreach (var p in NAPI.Pools.GetAllPlayers()) { if (p == null || !Main.Players.ContainsKey(p)) { continue; } if ((p.HasData("OPENOUT_TYPE") && p.GetData("OPENOUT_TYPE") == safeType) && (Main.Players[p].InsideHouseID != -1 && Main.Players[p].InsideHouseID == houseID) && (p.HasData("OpennedSafe") && p.GetData("OpennedSafe") == furnID)) { GUI.Dashboard.OpenOut(p, items, furniture.Name, safeType); } } }
public static void loadMaterialsTimer(Client player) { NAPI.Task.Run(() => { try { if (!player.HasData("vehicleMats")) { return; } if (!player.IsInVehicle) { return; } Vehicle vehicle = player.GetData("vehicleMats"); var itemCount = VehicleInventory.GetCountOfType(player.Vehicle, ItemType.Material); if (player.GetData("whereLoad") == "WAR" && !Fractions.MatsWar.isWar) { player.SetData("INTERACTIONCHECK", 0); //Main.StopT(player.GetData("loadMatsTimer"), "loadMaterialsTimer"); player.ResetData("loadMatsTimer"); Notify.Send(player, NotifyType.Error, NotifyPosition.BottomCenter, $"Корабль уже уехал", 3000); return; } if (itemCount >= Fractions.Stocks.maxMats[vehicle.DisplayName]) { Notify.Send(player, NotifyType.Error, NotifyPosition.BottomCenter, $"В машине максимальное кол-во материала", 3000); //Main.StopT(player.GetData("loadMatsTimer"), "loadMaterialsTimer_1"); player.ResetData("loadMatsTimer"); return; } var data = new nItem(ItemType.Material); if (player.GetData("whereLoad") == "WAR") { var count = Fractions.Stocks.maxMats[vehicle.DisplayName] - itemCount; if (count >= Fractions.MatsWar.matsLeft) { data.Count = itemCount + Fractions.MatsWar.matsLeft; Fractions.MatsWar.matsLeft = 0; Fractions.MatsWar.endWar(); } else { data.Count = count; Fractions.MatsWar.matsLeft -= count; } } else { data.Count = Fractions.Stocks.maxMats[vehicle.DisplayName] - itemCount; } VehicleInventory.Add(vehicle, data); NAPI.Data.ResetEntityData(vehicle, "loaderMats"); //Main.StopT(player.GetData("loadMatsTimer"), "loadMaterialsTimer_2"); player.ResetData("loadMatsTimer"); Notify.Send(player, NotifyType.Success, NotifyPosition.BottomCenter, $"Вы загрузили материалы в машину", 3000); } catch (Exception e) { Log.Write("LoadMatsTimer: " + e.Message, nLog.Type.Error); } }); }