예제 #1
0
        public async Task buyClothesShopItem(ClassicPlayer player, int shopId, int amount, string clothesName)
        {
            try
            {
                if (player == null || !player.Exists || player.CharacterId <= 0 || !ServerClothesShops.ExistClothesShop(shopId) || amount <= 0 || !ServerClothes.ExistClothes(clothesName))
                {
                    return;
                }
                if (CharactersClothes.ExistCharacterClothes(player.CharacterId, clothesName))
                {
                    HUDHandler.SendNotification(player, 3, 2500, "Dieses Anziehteil besitzt du bereits.");
                    return;
                }

                if (ServerClothes.GetClothesType(clothesName) == "Torso")
                {
                    Characters.SwitchCharacterClothes(player, "Torso", clothesName);
                    return;
                }

                int price = ServerClothesShops.GetClothesPrice(shopId, clothesName) * amount;
                if (!CharactersInventory.ExistCharacterItem(player.CharacterId, "Bargeld", "inventory") || CharactersInventory.GetCharacterItemAmount(player.CharacterId, "Bargeld", "inventory") < price)
                {
                    return;
                }
                CharactersInventory.RemoveCharacterItemAmount(player.CharacterId, "Bargeld", price, "inventory");
                CharactersClothes.CreateCharacterOwnedClothes(player.CharacterId, clothesName);
                Characters.SwitchCharacterClothes(player, ServerClothes.GetClothesType(clothesName), clothesName);
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
예제 #2
0
        public static void openClothesShop(ClassicPlayer player, int id)
        {
            try
            {
                if (player == null || !player.Exists || player.CharacterId <= 0 || !ServerClothesShops.ExistClothesShop(id))
                {
                    return;
                }
                int gender    = Convert.ToInt32(Characters.GetCharacterGender(player.CharacterId));
                var shopItems = ServerClothesShops.ServerClothesShopsItems_.ToList().Where(x => x.shopId == id && (ServerClothes.GetClothesGender(x.clothesName) == gender || ServerClothes.GetClothesGender(x.clothesName) == 2)).Select(x => new
                {
                    itemName = x.clothesName,
                    x.itemPrice,
                    clothesType = ServerClothes.GetClothesType(x.clothesName),
                    clothesDraw = ServerClothes.GetClothesDraw(x.clothesName),
                    clothesTex  = ServerClothes.GetClothesTexture(x.clothesName),
                }).ToList();

                var itemCount  = (int)shopItems.Count;
                var iterations = Math.Floor((decimal)(itemCount / 30));
                var rest       = itemCount % 30;
                for (var i = 0; i < iterations; i++)
                {
                    var skip = i * 30;
                    player.EmitLocked("Client:ClothesShop:sendItemsToClient", JsonConvert.SerializeObject(shopItems.Skip(skip).Take(30).ToList()));
                }
                if (rest != 0)
                {
                    player.EmitLocked("Client:ClothesShop:sendItemsToClient", JsonConvert.SerializeObject(shopItems.Skip((int)iterations * 30).ToList()));
                }

                var torsoItems = ServerClothes.ServerClothes_.ToList().Where(x => x.faction == 0 && x.gender == gender && (x.type == "Torso" || x.type == "Undershirt")).Select(x => new
                {
                    itemName    = x.clothesName,
                    itemPrice   = 0,
                    clothesType = x.type,
                    clothesDraw = x.draw,
                    clothesTex  = x.texture,
                }).ToList();

                var torsoCount      = (int)torsoItems.Count;
                var torsoIterations = Math.Floor((decimal)(torsoCount / 30));
                var torsoRest       = torsoCount % 30;
                for (var i = 0; i < torsoIterations; i++)
                {
                    var torsoSkip = i * 30;
                    player.EmitLocked("Client:ClothesShop:sendItemsToClient", JsonConvert.SerializeObject(torsoItems.Skip(torsoSkip).Take(30).ToList()));
                }
                if (rest != 0)
                {
                    player.EmitLocked("Client:ClothesShop:sendItemsToClient", JsonConvert.SerializeObject(torsoItems.Skip((int)torsoIterations * 30).ToList()));
                }


                player.EmitLocked("Client:ClothesShop:createCEF", id);
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }