public static float GetHouseStorageItemWeight(int houseId) { float invWeight = 0f; try { if (houseId <= 0) { return(invWeight); } var item = ServerHousesStorage_.Where(i => i.houseId == houseId); foreach (Server_Houses_Storage i in item) { string iName = ServerItems.ReturnNormalItemName(i.itemName); var serverItem = ServerItems.ServerItems_.FirstOrDefault(si => si.itemName == iName); if (serverItem != null) { invWeight += serverItem.itemWeight * i.itemAmount; } } } catch (Exception e) { Alt.Log($"{e}"); } return(invWeight); }
public static bool IsItemActive(IPlayer player, string itemName) { try { if (player == null || !player.Exists) { return(false); } int charId = User.GetPlayerOnline(player); if (charId <= 0 || itemName == "") { return(false); } itemName = ServerItems.ReturnNormalItemName(itemName); if (Characters.GetCharacterBackpack(charId) == itemName) { return(true); } else if ((string)Characters.GetCharacterWeapon(player, "PrimaryWeapon") == itemName || (string)Characters.GetCharacterWeapon(player, "SecondaryWeapon") == itemName || (string)Characters.GetCharacterWeapon(player, "SecondaryWeapon2") == itemName || (string)Characters.GetCharacterWeapon(player, "FistWeapon") == itemName) { return(true); } else if (itemName == "Smartphone" && Characters.IsCharacterPhoneEquipped(charId)) { return(true); } return(false); } catch (Exception e) { Alt.Log($"{e}"); } return(false); }
public static float GetCharacterItemWeight(int charId, string itemLocation) { try { if (charId <= 0 || string.IsNullOrWhiteSpace(itemLocation)) { return(0f); } var item = CharactersInventory_.ToList().Where(i => i.charId == charId && i.itemLocation == itemLocation); float invWeight = 0f; foreach (var i in item.Where(x => x != null && x.charId == charId)) { string iName = ServerItems.ReturnNormalItemName(i.itemName); var serverItem = ServerItems.ServerItems_.ToList().FirstOrDefault(si => si.itemName == iName); if (serverItem == null) { continue; } invWeight += serverItem.itemWeight * i.itemAmount; } return(invWeight); } catch (Exception e) { Alt.Log($"{e}"); } return(0f); }
public static float GetHotelStorageItemWeight(int apartmentId) { var item = ServerHotelsStorage_.Where(i => i.apartmentId == apartmentId); float invWeight = 0f; foreach (Server_Hotels_Storage i in item) { string iName = ServerItems.ReturnNormalItemName(i.itemName); var serverItem = ServerItems.ServerItems_.FirstOrDefault(si => si.itemName == iName); if (serverItem != null) { invWeight += serverItem.itemWeight * i.amount; } } return(invWeight); }
public static string GetShopSellItems(int charId, int shopId) { if (charId == 0 || shopId == 0) { return(""); } var items = ServerShopsItems_.Where(x => x.shopId == shopId && (CharactersInventory.ExistCharacterItem(charId, x.itemName, "inventory") == true || CharactersInventory.ExistCharacterItem(charId, x.itemName, "backpack") == true)).Select(x => new { itemname = x.itemName, itemprice = x.itemPrice, itempic = ServerItems.ReturnItemPicSRC(x.itemName), itemmaxamount = CharactersInventory.GetCharacterItemAmount(charId, x.itemName, "inventory") + CharactersInventory.GetCharacterItemAmount(charId, x.itemName, "backpack"), }).ToList(); return(JsonConvert.SerializeObject(items)); }
public static string GetCharacterInventory(int charId) { var items = CharactersInventory_.ToList().Where(x => x.charId == charId).Select(x => new { itemName = x.itemName, itemAmount = x.itemAmount, itemPicName = ServerItems.ReturnItemPicSRC(x.itemName), itemWeight = ServerItems.GetItemWeight(x.itemName), itemLocation = x.itemLocation, isItemDroppable = ServerItems.IsItemDroppable(ServerItems.ReturnNormalItemName(x.itemName)), isItemUseable = ServerItems.IsItemUseable(ServerItems.ReturnNormalItemName(x.itemName)), isItemGiveable = ServerItems.IsItemGiveable(ServerItems.ReturnNormalItemName(x.itemName)), }).ToList(); return(JsonConvert.SerializeObject(items)); }
public static string GetServerHotelStorageItems(int apartmentId) { if (apartmentId <= 0) { return("[]"); } var items = ServerHotelsStorage_.Where(x => x.apartmentId == apartmentId).Select(x => new { x.id, x.apartmentId, x.itemName, x.amount, itemPicName = ServerItems.ReturnItemPicSRC(x.itemName), }).ToList(); return(JsonConvert.SerializeObject(items)); }
public static string GetShopShopItems(int shopId) { if (shopId == 0) { return(""); } var items = ServerShopsItems_.Where(x => x.shopId == shopId).Select(x => new { itemname = x.itemName, itemprice = x.itemPrice, itempic = ServerItems.ReturnItemPicSRC(x.itemName), itemmaxamount = x.itemAmount, }).ToList(); return(JsonConvert.SerializeObject(items)); }
public static string GetServerHouseStorageItems(int houseId) { if (houseId <= 0) { return("[]"); } var items = ServerHousesStorage_.Where(x => x.houseId == houseId).Select(x => new { x.id, x.houseId, x.itemName, amount = x.itemAmount, itemPicName = ServerItems.ReturnItemPicSRC(x.itemName), }).ToList(); return(JsonConvert.SerializeObject(items)); }
public static string GetServerFactionStorageItems(int factionId, int charId) { if (factionId <= 0 || charId <= 0) { return("[]"); } var items = ServerFactionStorageItems_.Where(x => x.factionId == factionId && x.charId == charId).Select(x => new { x.id, x.charId, x.factionId, x.itemName, x.amount, itemPicName = ServerItems.ReturnItemPicSRC(x.itemName), }).ToList(); return(JsonConvert.SerializeObject(items)); }