private static void ProcessFunctionalItem(IRealmClient client, uint parametr, short slot)
        {
            var item = client.ActiveCharacter.Asda2Inventory.GetShopShopItem(slot);

            if (item == null)
            {
                SendUpdateShopItemInfoResponse(client, UseFunctionalItemError.FunctionalItemDoesNotExist);
                return;
            }
            var status = UseFunctionalItemError.Ok;

            if (item.RequiredLevel > client.ActiveCharacter.Level)
            {
                SendUpdateShopItemInfoResponse(client, UseFunctionalItemError.YorLevelIsNotHightEnoght, item);
                return;
            }
            RealmServer.IOQueue.AddMessage(() =>
            {
                try
                {
                    switch (item.Category)
                    {
                    case Asda2ItemCategory.ExpandWarehouse:
                        if (client.ActiveCharacter.Record.PremiumWarehouseBagsCount >= 8)
                        {
                            status = UseFunctionalItemError.WarehouseHasReachedMaxCapacity;
                        }

                        else
                        {
                            client.ActiveCharacter.Record.PremiumWarehouseBagsCount++;
                            SendWarehouseSlotsExpandedResponse(client, false);
                        }
                        break;

                    /* case Asda2ItemCategory.AvatarWarehouseExpand:
                     *
                     *   if (client.ActiveCharacter.Record.PremiumAvatarWarehouseBagsCount >= 8)
                     *       status = UseFunctionalItemError.WarehouseHasReachedMaxCapacity;
                     *   else
                     *   {
                     *       client.ActiveCharacter.Record.PremiumAvatarWarehouseBagsCount++;
                     *       SendWarehouseSlotsExpandedResponse(client, false);
                     *   }
                     *   break;*/
                    case Asda2ItemCategory.IncExp:
                        client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId);
                        SendShopItemUsedResponse(client, item.ItemId, item.Template.AtackRange);
                        break;

                    case Asda2ItemCategory.IncMoveSpeed:
                        if (item.Record.IsSoulBound && item.Record.AuctionEndTime != DateTime.MinValue &&
                            DateTime.Now > item.Record.AuctionEndTime)
                        {
                            client.ActiveCharacter.Asda2Inventory.RemoveItemFromInventory(item);
                            item.Destroy();
                            client.ActiveCharacter.SendInfoMsg("Vehicle expired.");
                            status = UseFunctionalItemError.TheDurationOfTheShopitemHaExprised;
                        }
                        else
                        {
                            if (!item.IsSoulbound)
                            {
                                Asda2TitleChecker.OnUseVeiche(client.ActiveCharacter);
                            }
                            item.IsSoulbound                       = true;
                            item.Record.AuctionEndTime             = DateTime.Now + TimeSpan.FromDays(item.AttackTime);
                            client.ActiveCharacter.TransportItemId = item.ItemId;
                        }
                        break;

                    case Asda2ItemCategory.IncHp:
                        client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId);
                        SendShopItemUsedResponse(client, item.ItemId, item.Template.AtackRange);
                        break;

                    case Asda2ItemCategory.IncMp:
                        client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId);
                        SendShopItemUsedResponse(client, item.ItemId, item.Template.AtackRange);
                        break;

                    case Asda2ItemCategory.IncAtackSpeed:
                        client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId);
                        SendShopItemUsedResponse(client, item.ItemId, item.Template.AtackRange);
                        break;

                    case Asda2ItemCategory.IncDex:
                        client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId);
                        SendShopItemUsedResponse(client, item.ItemId, item.Template.AtackRange);
                        break;

                    case Asda2ItemCategory.IncDigChance:
                        client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId);
                        SendShopItemUsedResponse(client, item.ItemId, item.Template.AtackRange);
                        break;

                    case Asda2ItemCategory.IncDropChance:
                        client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId);
                        SendShopItemUsedResponse(client, item.ItemId, item.Template.AtackRange);
                        break;

                    case Asda2ItemCategory.IncExpStackable:
                        client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId);
                        SendShopItemUsedResponse(client, item.ItemId, item.Template.AtackRange);
                        break;

                    case Asda2ItemCategory.IncInt:
                        client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId);
                        SendShopItemUsedResponse(client, item.ItemId, item.Template.AtackRange);
                        break;

                    case Asda2ItemCategory.IncLuck:
                        client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId);
                        SendShopItemUsedResponse(client, item.ItemId, item.Template.AtackRange);
                        break;

                    case Asda2ItemCategory.IncMAtk:
                        client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId);
                        SendShopItemUsedResponse(client, item.ItemId, item.Template.AtackRange);
                        break;

                    case Asda2ItemCategory.IncMdef:
                        client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId);
                        SendShopItemUsedResponse(client, item.ItemId, item.Template.AtackRange);
                        break;

                    case Asda2ItemCategory.IncPAtk:
                        client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId);
                        SendShopItemUsedResponse(client, item.ItemId, item.Template.AtackRange);
                        break;

                    case Asda2ItemCategory.IncPDef:
                        client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId);
                        SendShopItemUsedResponse(client, item.ItemId, item.Template.AtackRange);
                        break;

                    case Asda2ItemCategory.IncSpi:
                        client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId);
                        SendShopItemUsedResponse(client, item.ItemId, item.Template.AtackRange);
                        break;

                    case Asda2ItemCategory.IncSta:
                        client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId);
                        SendShopItemUsedResponse(client, item.ItemId, item.Template.AtackRange);
                        break;

                    case Asda2ItemCategory.IncStr:
                        client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId);
                        SendShopItemUsedResponse(client, item.ItemId, item.Template.AtackRange);
                        break;

                    case Asda2ItemCategory.DoublePetExpirience:
                        client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId);
                        SendShopItemUsedResponse(client, item.ItemId, item.Template.AtackRange);
                        break;

                    case Asda2ItemCategory.PetNotEating:
                        client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId);
                        SendShopItemUsedResponse(client, item.ItemId, item.Template.AtackRange);
                        break;

                    case Asda2ItemCategory.ResetAllSkill:
                        ResetSkills(client.ActiveCharacter);
                        Asda2CharacterHandler.SendLearnedSkillsInfo(client.ActiveCharacter);
                        Asda2TitleChecker.OnResetAllSkills(client.ActiveCharacter);
                        break;

                    case Asda2ItemCategory.ExpandInventory:
                        SendPremiumLongBuffInfoResponse(client,
                                                        (byte)client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId, true),
                                                        item.ItemId, (short)item.Template.PackageId);
                        break;

                    case Asda2ItemCategory.RemoveDeathPenaltiesByDays:
                        SendPremiumLongBuffInfoResponse(client,
                                                        (byte)client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId, true),
                                                        item.ItemId, (short)item.Template.PackageId);
                        break;

                    case Asda2ItemCategory.ShopBanner:
                        if (client.ActiveCharacter.Level < 10)
                        {
                            status = UseFunctionalItemError.YorLevelIsNotHightEnoght;
                        }
                        else
                        {
                            SendPremiumLongBuffInfoResponse(client,
                                                            (byte)client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId, true),
                                                            item.ItemId, (short)item.Template.PackageId);
                        }
                        break;

                    case Asda2ItemCategory.PetNotEatingByDays:
                        SendPremiumLongBuffInfoResponse(client,
                                                        (byte)client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId, true),
                                                        item.ItemId, (short)item.Template.PackageId);
                        break;

                    case Asda2ItemCategory.InstantRecover100PrcHPandMP:
                        if (client.ActiveCharacter.Last100PrcRecoveryUsed + 30000 > (uint)Environment.TickCount)
                        {
                            status = UseFunctionalItemError.CoolingTimeRemain;
                        }
                        else
                        {
                            client.ActiveCharacter.Last100PrcRecoveryUsed = (uint)Environment.TickCount;
                            client.ActiveCharacter.HealPercent(100);
                            client.ActiveCharacter.Power = client.ActiveCharacter.MaxPower;
                        }
                        break;

                    case Asda2ItemCategory.InstantRecover100PrcHP:
                        if (client.ActiveCharacter.Last100PrcRecoveryUsed + 30000 > (uint)Environment.TickCount)
                        {
                            status = UseFunctionalItemError.CoolingTimeRemain;
                        }
                        else
                        {
                            client.ActiveCharacter.Last100PrcRecoveryUsed = (uint)Environment.TickCount;
                            client.ActiveCharacter.HealPercent(100);
                        }
                        break;

                    case Asda2ItemCategory.RecoverHp10TimesByPrcOver30Sec:
                        PereodicAction a = null;
                        if (client.ActiveCharacter.PereodicActions.ContainsKey(Asda2PereodicActionType.HpRegenPrc))
                        {
                            a = client.ActiveCharacter.PereodicActions[Asda2PereodicActionType.HpRegenPrc];
                        }
                        if (a != null && a.CallsNum >= 6 && a.Value >= item.Template.ValueOnUse)
                        {
                            status = UseFunctionalItemError.CoolingTimeRemain;
                        }
                        else
                        {
                            if (
                                client.ActiveCharacter.PereodicActions.ContainsKey(
                                    Asda2PereodicActionType.HpRegenPrc))
                            {
                                client.ActiveCharacter.PereodicActions.Remove(Asda2PereodicActionType.HpRegenPrc);
                            }
                            a = new PereodicAction(client.ActiveCharacter, item.Template.ValueOnUse, 10, 5000,
                                                   Asda2PereodicActionType.HpRegenPrc);
                            client.ActiveCharacter.PereodicActions.Add(Asda2PereodicActionType.HpRegenPrc, a);
                        }
                        break;

                    case Asda2ItemCategory.PremiumPotions:
                        SendPremiumLongBuffInfoResponse(client,
                                                        (byte)client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId, true),
                                                        item.ItemId, (short)item.Template.PackageId);
                        break;

                    case Asda2ItemCategory.TeleportToCharacter:
                        if (parametr >= 10 ||
                            client.ActiveCharacter.TeleportPoints[parametr] == null)
                        {
                            status = UseFunctionalItemError.FailedToUse;
                        }
                        else
                        {
                            var point = client.ActiveCharacter.TeleportPoints[parametr];
                            Asda2TitleChecker.OnTeleportingToTelepotPoint(client.ActiveCharacter);
                            client.ActiveCharacter.TeleportTo(point.MapId, new Vector3(point.X, point.Y));
                        }
                        break;
                    // case Asda2ItemCategory.Monstertransformpotion:

                    // break;
                    case Asda2ItemCategory.OpenWarehouse:

                        break;

                    case Asda2ItemCategory.ResetOneSkill:
                        var spell = client.ActiveCharacter.Spells.First(s => s.RealId == parametr);
                        if (spell != null)
                        {
                            var totalcost = 0;
                            totalcost    += spell.Cost;
                            for (int i = spell.Level - 1; i > 0; i--)
                            {
                                var lowSpell = SpellHandler.Get((uint)(spell.RealId + i * 1000));
                                if (lowSpell != null)
                                {
                                    totalcost += lowSpell.Cost;
                                }
                            }
                            var tm = (uint)(totalcost / 2);
                            client.ActiveCharacter.Spells.Remove(spell);
                            client.ActiveCharacter.AddMoney(tm);
                            Asda2CharacterHandler.SendPreResurectResponse(client.ActiveCharacter);
                            SendSkillResetedResponse(client, spell.RealId, (short)spell.Level, tm);
                            Asda2CharacterHandler.SendUpdateStatsOneResponse(client);
                            Asda2CharacterHandler.SendUpdateStatsResponse(client);
                            client.ActiveCharacter.SendMoneyUpdate();
                        }
                        else
                        {
                            status = UseFunctionalItemError.FailedToUse;
                            client.ActiveCharacter.SendInfoMsg("Skill is not learned. Restart client.");
                        }
                        break;

                    default:
                        status = UseFunctionalItemError.NotAunctionalItem;
                        break;
                    }
                }
                catch (AlreadyBuffedExcepton)
                {
                    status = UseFunctionalItemError.AlreadyFeelingTheEffectOfSimilarSkillType;
                }
                if (status == UseFunctionalItemError.Ok && item.Category != Asda2ItemCategory.IncMoveSpeed)
                {
                    item.ModAmount(-1);
                }
                SendUpdateShopItemInfoResponse(client, status, item);
            });
        }
        private static void ProcessFunctionalItem(IRealmClient client, uint parametr, short slot)
        {
            Asda2Item item = client.ActiveCharacter.Asda2Inventory.GetShopShopItem(slot);

            if (item == null)
            {
                FunctionalItemsHandler.SendUpdateShopItemInfoResponse(client,
                                                                      UseFunctionalItemError.FunctionalItemDoesNotExist, (Asda2Item)null);
            }
            else
            {
                UseFunctionalItemError status = UseFunctionalItemError.Ok;
                if ((int)item.RequiredLevel > client.ActiveCharacter.Level)
                {
                    FunctionalItemsHandler.SendUpdateShopItemInfoResponse(client,
                                                                          UseFunctionalItemError.YorLevelIsNotHightEnoght, item);
                }
                else
                {
                    ServerApp <WCell.RealmServer.RealmServer> .IOQueue.AddMessage((Action)(() =>
                    {
                        try
                        {
                            switch (item.Category)
                            {
                            case Asda2ItemCategory.IncPAtk:
                                client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId, false);
                                FunctionalItemsHandler.SendShopItemUsedResponse(client, item.ItemId,
                                                                                (int)item.Template.AtackRange);
                                break;

                            case Asda2ItemCategory.IncMAtk:
                                client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId, false);
                                FunctionalItemsHandler.SendShopItemUsedResponse(client, item.ItemId,
                                                                                (int)item.Template.AtackRange);
                                break;

                            case Asda2ItemCategory.IncPDef:
                                client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId, false);
                                FunctionalItemsHandler.SendShopItemUsedResponse(client, item.ItemId,
                                                                                (int)item.Template.AtackRange);
                                break;

                            case Asda2ItemCategory.IncMdef:
                                client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId, false);
                                FunctionalItemsHandler.SendShopItemUsedResponse(client, item.ItemId,
                                                                                (int)item.Template.AtackRange);
                                break;

                            case Asda2ItemCategory.IncHp:
                                client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId, false);
                                FunctionalItemsHandler.SendShopItemUsedResponse(client, item.ItemId,
                                                                                (int)item.Template.AtackRange);
                                break;

                            case Asda2ItemCategory.IncMp:
                                client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId, false);
                                FunctionalItemsHandler.SendShopItemUsedResponse(client, item.ItemId,
                                                                                (int)item.Template.AtackRange);
                                break;

                            case Asda2ItemCategory.IncStr:
                                client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId, false);
                                FunctionalItemsHandler.SendShopItemUsedResponse(client, item.ItemId,
                                                                                (int)item.Template.AtackRange);
                                break;

                            case Asda2ItemCategory.IncSta:
                                client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId, false);
                                FunctionalItemsHandler.SendShopItemUsedResponse(client, item.ItemId,
                                                                                (int)item.Template.AtackRange);
                                break;

                            case Asda2ItemCategory.IncInt:
                                client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId, false);
                                FunctionalItemsHandler.SendShopItemUsedResponse(client, item.ItemId,
                                                                                (int)item.Template.AtackRange);
                                break;

                            case Asda2ItemCategory.IncSpi:
                                client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId, false);
                                FunctionalItemsHandler.SendShopItemUsedResponse(client, item.ItemId,
                                                                                (int)item.Template.AtackRange);
                                break;

                            case Asda2ItemCategory.IncDex:
                                client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId, false);
                                FunctionalItemsHandler.SendShopItemUsedResponse(client, item.ItemId,
                                                                                (int)item.Template.AtackRange);
                                break;

                            case Asda2ItemCategory.IncLuck:
                                client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId, false);
                                FunctionalItemsHandler.SendShopItemUsedResponse(client, item.ItemId,
                                                                                (int)item.Template.AtackRange);
                                break;

                            case Asda2ItemCategory.IncMoveSpeed:
                                if (client.ActiveCharacter.LastTransportUsedTime +
                                    TimeSpan.FromMilliseconds(30000.0) > DateTime.Now)
                                {
                                    status = UseFunctionalItemError.CoolingTimeRemain;
                                    break;
                                }

                                if (item.Record.IsSoulBound && item.Record.AuctionEndTime != DateTime.MinValue &&
                                    DateTime.Now > item.Record.AuctionEndTime)
                                {
                                    Asda2InventoryHandler.ItemRemovedFromInventoryResponse(client.ActiveCharacter,
                                                                                           item, DeleteOrSellItemStatus.Ok, 0);
                                    item.Destroy();
                                    client.ActiveCharacter.SendInfoMsg("Vehicle expired.");
                                    status = UseFunctionalItemError.TheDurationOfTheShopitemHaExprised;
                                    break;
                                }

                                if (item.Record.AuctionEndTime == DateTime.MinValue)
                                {
                                    item.Record.AuctionEndTime =
                                        DateTime.Now + TimeSpan.FromDays((double)item.AttackTime);
                                }
                                client.ActiveCharacter.LastTransportUsedTime = DateTime.Now;
                                item.IsSoulbound = true;
                                client.ActiveCharacter.TransportItemId = item.ItemId;
                                AchievementProgressRecord progressRecord1 =
                                    client.ActiveCharacter.Achievements.GetOrCreateProgressRecord(85U);
                                switch (++progressRecord1.Counter)
                                {
                                case 1:
                                    client.ActiveCharacter.Map.CallDelayed(500,
                                                                           (Action)(() =>
                                                                                    client.ActiveCharacter.DiscoverTitle(Asda2TitleId.Rapid219)));
                                    break;

                                case 1000:
                                    client.ActiveCharacter.Map.CallDelayed(500,
                                                                           (Action)(() =>
                                                                                    client.ActiveCharacter.GetTitle(Asda2TitleId.Rapid219)));
                                    break;
                                }

                                progressRecord1.SaveAndFlush();
                                break;

                            case Asda2ItemCategory.IncExp:
                                client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId, false);
                                FunctionalItemsHandler.SendShopItemUsedResponse(client, item.ItemId,
                                                                                (int)item.Template.AtackRange);
                                break;

                            case Asda2ItemCategory.IncDropChance:
                                client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId, false);
                                FunctionalItemsHandler.SendShopItemUsedResponse(client, item.ItemId,
                                                                                (int)item.Template.AtackRange);
                                break;

                            case Asda2ItemCategory.IncDigChance:
                                client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId, false);
                                FunctionalItemsHandler.SendShopItemUsedResponse(client, item.ItemId,
                                                                                (int)item.Template.AtackRange);
                                break;

                            case Asda2ItemCategory.IncExpStackable:
                                client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId, false);
                                FunctionalItemsHandler.SendShopItemUsedResponse(client, item.ItemId,
                                                                                (int)item.Template.AtackRange);
                                break;

                            case Asda2ItemCategory.IncAtackSpeed:
                                client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId, false);
                                FunctionalItemsHandler.SendShopItemUsedResponse(client, item.ItemId,
                                                                                (int)item.Template.AtackRange);
                                break;

                            case Asda2ItemCategory.ExpandWarehouse:
                                if (client.ActiveCharacter.Record.PremiumWarehouseBagsCount >= (byte)8)
                                {
                                    status = UseFunctionalItemError.WarehouseHasReachedMaxCapacity;
                                    break;
                                }

                                ++client.ActiveCharacter.Record.PremiumWarehouseBagsCount;
                                FunctionalItemsHandler.SendWarehouseSlotsExpandedResponse(client, false);
                                break;

                            case Asda2ItemCategory.ResetAllSkill:
                                FunctionalItemsHandler.ResetSkills(client.ActiveCharacter);
                                Asda2CharacterHandler.SendLearnedSkillsInfo(client.ActiveCharacter);
                                AchievementProgressRecord progressRecord2 =
                                    client.ActiveCharacter.Achievements.GetOrCreateProgressRecord(84U);
                                switch (++progressRecord2.Counter)
                                {
                                case 3:
                                    client.ActiveCharacter.Map.CallDelayed(500,
                                                                           (Action)(() =>
                                                                                    client.ActiveCharacter.DiscoverTitle(Asda2TitleId
                                                                                                                         .Perfectionist218)));
                                    break;

                                case 5:
                                    client.ActiveCharacter.Map.CallDelayed(500,
                                                                           (Action)(() =>
                                                                                    client.ActiveCharacter.GetTitle(Asda2TitleId.Perfectionist218)));
                                    break;
                                }

                                progressRecord2.SaveAndFlush();
                                break;

                            case Asda2ItemCategory.ResetOneSkill:
                                Spell spell1 =
                                    client.ActiveCharacter.Spells.First <Spell>(
                                        (Func <Spell, bool>)(s => (long)s.RealId == (long)parametr));
                                if (spell1 != null)
                                {
                                    int num1 = 0 + spell1.Cost;
                                    for (int index = spell1.Level - 1; index > 0; --index)
                                    {
                                        Spell spell2 =
                                            SpellHandler.Get((uint)spell1.RealId + (uint)(index * 1000));
                                        if (spell2 != null)
                                        {
                                            num1 += spell2.Cost;
                                        }
                                    }

                                    uint num2 = (uint)(num1 / 2);
                                    client.ActiveCharacter.Spells.Remove(spell1);
                                    client.ActiveCharacter.AddMoney(num2);
                                    Asda2CharacterHandler.SendPreResurectResponse(client.ActiveCharacter);
                                    FunctionalItemsHandler.SendSkillResetedResponse(client, spell1.RealId,
                                                                                    (short)spell1.Level, num2);
                                    Asda2CharacterHandler.SendUpdateStatsOneResponse(client);
                                    Asda2CharacterHandler.SendUpdateStatsResponse(client);
                                    client.ActiveCharacter.SendMoneyUpdate();
                                    AchievementProgressRecord progressRecord3 =
                                        client.ActiveCharacter.Achievements.GetOrCreateProgressRecord(84U);
                                    switch (++progressRecord3.Counter)
                                    {
                                    case 3:
                                        client.ActiveCharacter.Map.CallDelayed(500,
                                                                               (Action)(() =>
                                                                                        client.ActiveCharacter.DiscoverTitle(Asda2TitleId
                                                                                                                             .Perfectionist218)));
                                        break;

                                    case 5:
                                        client.ActiveCharacter.Map.CallDelayed(500,
                                                                               (Action)(() =>
                                                                                        client.ActiveCharacter.GetTitle(Asda2TitleId
                                                                                                                        .Perfectionist218)));
                                        break;
                                    }

                                    progressRecord3.SaveAndFlush();
                                    break;
                                }

                                status = UseFunctionalItemError.FailedToUse;
                                client.ActiveCharacter.SendInfoMsg("Skill is not learned. Restart client.");
                                break;

                            case Asda2ItemCategory.TeleportToCharacter:
                                if (parametr >= 10U || client.ActiveCharacter.TeleportPoints[parametr] == null)
                                {
                                    status = UseFunctionalItemError.FailedToUse;
                                    break;
                                }

                                Asda2TeleportingPointRecord teleportPoint =
                                    client.ActiveCharacter.TeleportPoints[parametr];
                                client.ActiveCharacter.TeleportTo(teleportPoint.MapId,
                                                                  new Vector3((float)teleportPoint.X, (float)teleportPoint.Y));
                                AchievementProgressRecord progressRecord4 =
                                    client.ActiveCharacter.Achievements.GetOrCreateProgressRecord(89U);
                                switch (++progressRecord4.Counter)
                                {
                                case 50:
                                    client.ActiveCharacter.Map.CallDelayed(500,
                                                                           (Action)(() =>
                                                                                    client.ActiveCharacter.DiscoverTitle(Asda2TitleId.Traveler223)));
                                    break;

                                case 100:
                                    client.ActiveCharacter.Map.CallDelayed(500,
                                                                           (Action)(() =>
                                                                                    client.ActiveCharacter.GetTitle(Asda2TitleId.Traveler223)));
                                    break;
                                }

                                progressRecord4.SaveAndFlush();
                                break;

                            case Asda2ItemCategory.InstantRecover100PrcHP:
                                if (client.ActiveCharacter.Last100PrcRecoveryUsed + 30000U >
                                    (uint)Environment.TickCount)
                                {
                                    status = UseFunctionalItemError.CoolingTimeRemain;
                                    break;
                                }

                                client.ActiveCharacter.Last100PrcRecoveryUsed = (uint)Environment.TickCount;
                                client.ActiveCharacter.HealPercent(100, (Unit)null, (SpellEffect)null);
                                break;

                            case Asda2ItemCategory.InstantRecover100PrcHPandMP:
                                if (client.ActiveCharacter.Last100PrcRecoveryUsed + 30000U <
                                    (uint)Environment.TickCount)
                                {
                                    status = UseFunctionalItemError.CoolingTimeRemain;
                                }
                                client.ActiveCharacter.HealPercent(100, (Unit)null, (SpellEffect)null);
                                client.ActiveCharacter.Power = client.ActiveCharacter.MaxPower;
                                client.ActiveCharacter.Last100PrcRecoveryUsed = (uint)Environment.TickCount;
                                break;

                            case Asda2ItemCategory.RecoverHp10TimesByPrcOver30Sec:
                                PereodicAction pereodicAction = (PereodicAction)null;
                                if (client.ActiveCharacter.PereodicActions.ContainsKey(Asda2PereodicActionType
                                                                                       .HpRegenPrc))
                                {
                                    pereodicAction =
                                        client.ActiveCharacter.PereodicActions[Asda2PereodicActionType.HpRegenPrc];
                                }
                                if (pereodicAction != null && pereodicAction.CallsNum >= 10 &&
                                    pereodicAction.Value >= item.Template.ValueOnUse)
                                {
                                    status = UseFunctionalItemError.CoolingTimeRemain;
                                    break;
                                }

                                if (client.ActiveCharacter.PereodicActions.ContainsKey(Asda2PereodicActionType
                                                                                       .HpRegenPrc))
                                {
                                    client.ActiveCharacter.PereodicActions.Remove(
                                        Asda2PereodicActionType.HpRegenPrc);
                                }
                                client.ActiveCharacter.PereodicActions.Add(Asda2PereodicActionType.HpRegenPrc,
                                                                           new PereodicAction(client.ActiveCharacter, item.Template.ValueOnUse, 10, 3000,
                                                                                              Asda2PereodicActionType.HpRegenPrc));
                                break;

                            case Asda2ItemCategory.ShopBanner:
                                if (client.ActiveCharacter.Level < 10)
                                {
                                    status = UseFunctionalItemError.YorLevelIsNotHightEnoght;
                                    break;
                                }

                                FunctionalItemsHandler.SendPremiumLongBuffInfoResponse(client,
                                                                                       (byte)client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId, true),
                                                                                       item.ItemId, (short)item.Template.PackageId);
                                break;

                            case Asda2ItemCategory.OpenWarehouse:
                                break;

                            case Asda2ItemCategory.PremiumPotions:
                                FunctionalItemsHandler.SendPremiumLongBuffInfoResponse(client,
                                                                                       (byte)client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId, true),
                                                                                       item.ItemId, (short)item.Template.PackageId);
                                client.ActiveCharacter.Asda2WingsItemId = (short)item.ItemId;
                                AchievementProgressRecord progressRecord5 =
                                    client.ActiveCharacter.Achievements.GetOrCreateProgressRecord(86U);
                                switch (++progressRecord5.Counter)
                                {
                                case 50:
                                    client.ActiveCharacter.Map.CallDelayed(500,
                                                                           (Action)(() =>
                                                                                    client.ActiveCharacter.DiscoverTitle(Asda2TitleId.Winged220)));
                                    break;

                                case 100:
                                    client.ActiveCharacter.Map.CallDelayed(500,
                                                                           (Action)(() =>
                                                                                    client.ActiveCharacter.GetTitle(Asda2TitleId.Winged220)));
                                    break;
                                }

                                progressRecord5.SaveAndFlush();
                                break;

                            case Asda2ItemCategory.ExpandInventory:
                                FunctionalItemsHandler.SendPremiumLongBuffInfoResponse(client,
                                                                                       (byte)client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId, true),
                                                                                       item.ItemId, (short)item.Template.PackageId);
                                AchievementProgressRecord progressRecord6 =
                                    client.ActiveCharacter.Achievements.GetOrCreateProgressRecord(87U);
                                switch (++progressRecord6.Counter)
                                {
                                case 3:
                                    client.ActiveCharacter.Map.CallDelayed(500,
                                                                           (Action)(() =>
                                                                                    client.ActiveCharacter.DiscoverTitle(Asda2TitleId.Packrat221)));
                                    break;

                                case 5:
                                    client.ActiveCharacter.Map.CallDelayed(500,
                                                                           (Action)(() =>
                                                                                    client.ActiveCharacter.GetTitle(Asda2TitleId.Packrat221)));
                                    break;
                                }

                                progressRecord6.SaveAndFlush();
                                break;

                            case Asda2ItemCategory.PetNotEatingByDays:
                                FunctionalItemsHandler.SendPremiumLongBuffInfoResponse(client,
                                                                                       (byte)client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId, true),
                                                                                       item.ItemId, (short)item.Template.PackageId);
                                client.ActiveCharacter.Map.CallDelayed(500,
                                                                       (Action)(() => client.ActiveCharacter.GetTitle(Asda2TitleId.Treat366)));
                                break;

                            case Asda2ItemCategory.RemoveDeathPenaltiesByDays:
                                FunctionalItemsHandler.SendPremiumLongBuffInfoResponse(client,
                                                                                       (byte)client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId, true),
                                                                                       item.ItemId, (short)item.Template.PackageId);
                                break;

                            default:
                                status = UseFunctionalItemError.NotAunctionalItem;
                                break;
                            }
                        }
                        catch (AlreadyBuffedExcepton ex)
                        {
                            status = UseFunctionalItemError.AlreadyFeelingTheEffectOfSimilarSkillType;
                        }

                        if (status == UseFunctionalItemError.Ok && item.Category != Asda2ItemCategory.IncMoveSpeed)
                        {
                            item.ModAmount(-1);
                        }
                        FunctionalItemsHandler.SendUpdateShopItemInfoResponse(client, status, item);
                    }));
                }
            }
        }