public override void Handle(NecClient client, NecPacket packet)
        {
            uint myTargetId = packet.data.ReadUInt32();
            int  error      = packet.data.ReadInt32();

            NecClient targetClient = server.clients.GetByCharacterInstanceId(myTargetId);

            IBuffer res = BufferProvider.Provide();

            res.WriteInt32(error);
            router.Send(client, (ushort)AreaPacketId.recv_trade_reply_r, res, ServerType.Area);

            RecvTradeNotifyReplied notifyReplied = new RecvTradeNotifyReplied(error);

            router.Send(notifyReplied, targetClient);

            if (error == 0) //Success condition
            {
                RecvEventStart eventStart = new RecvEventStart(0, 0);
                router.Send(eventStart, client, targetClient);

                client.character.eventSelectExecCode = (int)myTargetId;
                server.clients.GetByCharacterInstanceId(myTargetId).character.eventSelectExecCode = (int)client.character.instanceId;
            }
        }
        public override void Handle(NecClient client, NecPacket packet)
        {
            byte
                toStoreType =
                packet.Data
                .ReadByte();         // [0 = adventure bag. 1 = character equipment], [then unknown byte], [then slot], [then unknown]
            byte  toBagId       = packet.Data.ReadByte();
            short fromSlot      = packet.Data.ReadInt16();
            byte  fromStoreType = packet.Data.ReadByte();
            byte  fromBagId     = packet.Data.ReadByte();
            short toSlot        = packet.Data.ReadInt16();

            Logger.Debug($"fromStoreType byte [{fromStoreType}]");
            Logger.Debug($"fromBagId byte [{fromBagId}]");
            Logger.Debug($"fromSlot byte [{fromSlot}]");
            Logger.Debug($"toStoreType byte [{toStoreType}]");
            Logger.Debug($"toBagId byte [{toBagId}]");
            Logger.Debug($"toSlot [{toSlot}]");

            int itemCount = packet.Data.ReadByte(); //last byte is stack count?

            Logger.Debug($"itemCount [{itemCount}]");
            IBuffer res = BufferProvider.Provide();

            res.WriteInt32(0); //error check. 0 to work

            /*
             *  ITEMUSE	GENERIC	Unable to use this item right now
             *  ITEMUSE	-201	Store location is incorrect
             *  ITEMUSE	-204	Item amount is incorrect
             *  ITEMUSE	-205	The target to use this item is incorrect
             *  ITEMUSE	-206	Unable to use due to delay time
             *  ITEMUSE	-207	No space available in inventory
             *  ITEMUSE	-208	Unable to use this item since it is cursed
             *  ITEMUSE	-209	Unable to use this item since it is broken
             *  ITEMUSE	-210	You do not meet the requirements to equip this item
             *  ITEMUSE	-211	Unable to use this item
             *  ITEMUSE	-212	You are not in the right status to use this item
             *  ITEMUSE	-230	Unable to use since it is on cool down.
             *  ITEMUSE	-2601	You've already received this scrap
             *  ITEMUSE	-2708	Cannot be used outside of town
             *  ITEMUSE	-3001	Unable to move items when you have a shop open
             *
             */

            Router.Send(client, (ushort)AreaPacketId.recv_item_move_r, res, ServerType.Area);

            InventoryItem fromInvItem = client.Character.GetInventoryItem(fromStoreType, fromBagId, fromSlot);
            InventoryItem toInvItem   = client.Character.GetInventoryItem(toStoreType, toBagId, toSlot);

            if (toInvItem != null && (fromInvItem.StorageItem != toInvItem.StorageItem))
            {
                RecvNormalSystemMessage unlikeItems = new RecvNormalSystemMessage("You can only stack like items!");
                _server.Router.Send(unlikeItems, client);
                return;
            }

            if (toInvItem != null && (toInvItem.StorageCount >= 255))
            {
                RecvNormalSystemMessage unlikeItems =
                    new RecvNormalSystemMessage("The move would place too many items in destination slot!");
                _server.Router.Send(unlikeItems, client);
                return;
            }

            if (fromInvItem.StorageCount > 1)
            {
                if (client.Character.currentEvent != null)
                {
                    Logger.Error(
                        $"Trying to start new event with another outstanding event active! Outstanding event type [{client.Character.currentEvent.EventType}]");
                    client.Character.currentEvent = null;
                }

                MoveItem moveItem = _server.Instances.CreateInstance <MoveItem>();
                moveItem.toStoreType          = toStoreType;
                moveItem.toBagId              = toBagId;
                moveItem.toSlot               = toSlot;
                moveItem.fromStoreType        = fromStoreType;
                moveItem.fromBagId            = moveItem.fromBagId;
                moveItem.fromSlot             = fromSlot;
                moveItem.itemCount            = (byte)itemCount;
                moveItem.item                 = fromInvItem.StorageItem;
                client.Character.currentEvent = moveItem;
                RecvEventStart eventStart = new RecvEventStart(0, 0);
                Router.Send(eventStart, client);
                RecvEventRequestInt getCount = new RecvEventRequestInt("Select number to move.", 1,
                                                                       fromInvItem.StorageCount, fromInvItem.StorageCount);
                Router.Send(getCount, client);
            }
            else
            {
                if (toInvItem == null)
                {
                    fromInvItem.StorageType = toStoreType;
                    fromInvItem.StorageId   = toBagId;
                    fromInvItem.StorageSlot = toSlot;
                    client.Character.UpdateInventoryItem(fromInvItem);
                    RecvItemUpdatePlace changePlace =
                        new RecvItemUpdatePlace(fromInvItem.InstanceId, toStoreType, toBagId, toSlot);
                    _server.Router.Send(changePlace, client);
                    client.Character.UpdateInventoryItem(fromInvItem);
                }
                else
                {
                    toInvItem.StorageCount += 1;
                    RecvItemUpdateNum updateNum = new RecvItemUpdateNum(toInvItem.InstanceId, toInvItem.StorageCount);
                    _server.Router.Send(updateNum, client);
                    RecvItemRemove removeitem = new RecvItemRemove(fromInvItem.InstanceId);
                    _server.Router.Send(removeitem, client);
                    client.Character.UpdateInventoryItem(toInvItem);
                    client.Character.RemoveInventoryItem(fromInvItem);
                }
            }

            //SendItemPlace(client);
            //SendItemPlaceChange(client);
        }
Example #3
0
        public override void Execute(string[] command, NecClient client, ChatMessage message,
                                     List <ChatResponse> responses)
        {
            if (command[0] == null)
            {
                responses.Add(ChatResponse.CommandError(client, $"Invalid argument: {command[0]}"));
                return;
            }

            if (!int.TryParse(command[1], out int x))
            {
                try
                {
                    string binaryString = command[1];
                    binaryString = binaryString.Replace("0b", "");
                    _Logger.Debug(binaryString);
                    x = Convert.ToInt32(binaryString, 2);
                }
                catch
                {
                    responses.Add(ChatResponse.CommandError(client, "no value specified. setting x to 1"));
                    //return;
                }
            }

            if (!int.TryParse(command[2], out int y))
            {
                responses.Add(ChatResponse.CommandError(client, "Good Job!"));
            }
            IBuffer res = BufferProvider.Provide();

            res.WriteInt32(2);
            router.Send(client, (ushort)AreaPacketId.recv_situation_start, res, ServerType.Area);

            res = BufferProvider.Provide();
            res.WriteInt32(0); // 0 = normal 1 = cinematic
            res.WriteByte(0);
            //Router.Send(client, (ushort)AreaPacketId.recv_event_start, res, ServerType.Area);

            switch (command[0])
            {
            case "itemobject":
                RecvDataNotifyLocalItemobjectData itemObject = new RecvDataNotifyLocalItemobjectData(client.character, x);
                router.Send(client.map, itemObject);
                break;

            case "itemcharapost":
                RecvItemCharaPostNotify itemCharaPost = new RecvItemCharaPostNotify(x, (byte)y);
                router.Send(client.map, itemCharaPost);
                break;

            case "itemuse":
                RecvItemUseNotify itemUseNotify = new RecvItemUseNotify(x, y);
                router.Send(client.map, itemUseNotify);
                RecvItemUse itemUse = new RecvItemUse(0 /*success*/, y);
                router.Send(client.map, itemUse);
                break;

            case "dispitem":
                RecvSoulDispItemNotifyData dispItem = new RecvSoulDispItemNotifyData(x);
                router.Send(client.map, dispItem);
                break;

            case "templeopen":
                RecvTempleNotifyOpen templeOpen = new RecvTempleNotifyOpen((byte)x);
                router.Send(client.map, templeOpen);
                break;

            case "wantedstate":
                RecvWantedUpdateState wantedState = new RecvWantedUpdateState(x);
                router.Send(client.map, wantedState);
                RecvWantedUpdateStateNotify wantedStateNotify = new RecvWantedUpdateStateNotify((int)client.character.instanceId, x);
                router.Send(client.map, wantedStateNotify);
                break;

            case "jailmoney":
                RecvWantedJailUpdateMoney jailMoney = new RecvWantedJailUpdateMoney();
                router.Send(client.map, jailMoney);
                break;

            case "lootaccess":
                RecvLootAccessObject lootAcess = new RecvLootAccessObject();
                router.Send(client.map, lootAcess);
                break;

            case "partygetitem":
                //arearecv
                RecvPartyNotifyGetItem recvPartyNotifyGetItem = new RecvPartyNotifyGetItem(client.character.instanceId);
                router.Send(recvPartyNotifyGetItem, client);
                //message recv
                res = BufferProvider.Provide();
                res.WriteUInt32(client.character.instanceId);
                res.WriteCString(" a Dagger or any long string named object ");
                res.WriteByte(20);
                router.Send(client.map, (ushort)MsgPacketId.recv_party_notify_get_item, res, ServerType.Msg);
                break;

            case "partygetmoney":
                RecvPartyNotifyGetMoney recvPartyNotifyGetMoney = new RecvPartyNotifyGetMoney(client.character.instanceId);
                router.Send(client.map, recvPartyNotifyGetMoney);
                break;

            case "partybuff":
                RecvPartyNotifyAttachBuff recvPartyNotifyAttachBuff = new RecvPartyNotifyAttachBuff();
                router.Send(client.map, recvPartyNotifyAttachBuff);
                break;

            case "partydragon":
                RecvPartyNotifyUpdateDragon recvPartyNotifyUpdateDragon = new RecvPartyNotifyUpdateDragon(client.character.instanceId);
                router.Send(client.map, recvPartyNotifyUpdateDragon);
                break;

            case "partymap":
                RecvPartyNotifyUpdateMap recvPartyNotifyUpdateMap = new RecvPartyNotifyUpdateMap(client);
                router.Send(client.map, recvPartyNotifyUpdateMap);
                break;

            case "partysync":
                RecvPartyNotifyUpdateSyncLevel recvPartyNotifyUpdateSyncLevel = new RecvPartyNotifyUpdateSyncLevel(client);
                router.Send(client.map, recvPartyNotifyUpdateSyncLevel);
                break;

            case "ap":
                RecvCharaUpdateAp recvCharaUpdateAp = new RecvCharaUpdateAp(Util.GetRandomNumber(0, 200));
                router.Send(client.map, recvCharaUpdateAp);
                client.character.gp.SetCurrent(25);
                break;

            case "ac":
                RecvCharaUpdateAc recvCharaUpdateAc = new RecvCharaUpdateAc(Util.GetRandomNumber(0, 200));
                router.Send(client.map, recvCharaUpdateAc);
                break;

            case "iobject":
                //SendDataNotifyItemObjectData
                // objectid : %d, stateflag : %d, type : %d\n
                res = BufferProvider.Provide();

                res.WriteInt32(12345);                        //object instance ID
                res.WriteFloat(client.character.x);           //Initial X
                res.WriteFloat(client.character.y);           //Initial Y
                res.WriteFloat(client.character.z);           //Initial Z

                res.WriteFloat(client.character.x);           //Final X
                res.WriteFloat(client.character.y);           //Final Y
                res.WriteFloat(client.character.z);           //Final Z
                res.WriteByte(client.character.heading);      //View offset

                res.WriteInt32(0);                            // ?
                res.WriteUInt32(client.character.instanceId); // ?
                res.WriteUInt32(0);                           // ?

                res.WriteInt32(0b1);                          //object state. 1 = lootable .
                res.WriteInt32(2);                            //type

                router.Send(client.map, (ushort)AreaPacketId.recv_data_notify_itemobject_data, res, ServerType.Area);
                break;

            case "o2716":
                res = BufferProvider.Provide();

                res.WriteUInt32(0);     //errhceck

                router.Send(client, 0x2716, res, ServerType.Area);
                break;

            case "o4abb":
                res = BufferProvider.Provide();

                res.WriteUInt32(0);
                res.WriteUInt16(0);

                router.Send(client, 0x4abb, res, ServerType.Area);
                break;

            case "ob684":
                Recv0Xb684 recv0Xb684 = new Recv0Xb684();
                router.Send(client.map, recv0Xb684);
                break;

            case "ob4978":
                Recv0X4978 recv0X4978 = new Recv0X4978();
                router.Send(client.map, recv0X4978);
                break;

            case "ob5418":
                Recv0X5418 recv0X5418 = new Recv0X5418();
                router.Send(client.map, recv0X5418);
                break;

            case "ob10da":
                Recv0X10Da recv0X10Da = new Recv0X10Da();
                router.Send(client.map, recv0X10Da);
                break;

            case "ob8d62":
                Recv0X8D62 recv0X8D62 = new Recv0X8D62();
                router.Send(client.map, recv0X8D62);
                break;

            case "ob9201":
                Recv0X9201 recv0X9201 = new Recv0X9201();
                router.Send(client.map, recv0X9201);
                break;

            case "ob9ca1":
                Recv0X9Ca1 recv0X9Ca1 = new Recv0X9Ca1();
                router.Send(client.map, recv0X9Ca1);
                break;

            case "obba61":
                Recv0XBa61 recv0XBa61 = new Recv0XBa61();
                router.Send(client.map, recv0XBa61);
                break;

            case "obd1f6":
                Recv0Xd1F6 recv0Xd1F6 = new Recv0Xd1F6();
                router.Send(client.map, recv0Xd1F6);
                break;

            case "obe8b9":
                Recv0Xe8B9 recv0Xe8B9 = new Recv0Xe8B9();
                router.Send(client.map, recv0Xe8B9);
                break;


            case "partnersummon":
                RecvSoulPartnerSummonStartNotify recvSoulPartnerSummonStartNotify = new RecvSoulPartnerSummonStartNotify();
                router.Send(client.map, recvSoulPartnerSummonStartNotify);
                RecvSoulPartnerSummonExecR recvSoulPartnerSummonExecR = new RecvSoulPartnerSummonExecR();
                router.Send(client.map, recvSoulPartnerSummonExecR);
                RecvSoulPartnerUnlockAvatar recvSoulPartnerUnlockAvatar = new RecvSoulPartnerUnlockAvatar();
                router.Send(client.map, recvSoulPartnerUnlockAvatar);
                RecvSoulPartnerNotifyAvatar recvSoulPartnerNotifyAvatar = new RecvSoulPartnerNotifyAvatar();
                router.Send(client.map, recvSoulPartnerNotifyAvatar);

                break;

            case "selectraise":
                RecvDbgSelectRaise recvDbgSelectRaise = new RecvDbgSelectRaise();
                router.Send(client.map, recvDbgSelectRaise);
                break;

            case "dragonpos":
                RecvSelfDragonPosNotify recvSelfDragonPosNotify = new RecvSelfDragonPosNotify(client, (byte)x);
                router.Send(client.map, recvSelfDragonPosNotify);
                break;

            case "dragonwarp":
                RecvSelfDragonWarpNotify recvSelfDragonWarpNotify = new RecvSelfDragonWarpNotify((int)client.character.instanceId + 100);
                router.Send(client.map, recvSelfDragonWarpNotify);
                break;

            case "exdragon":
                RecvDataNotifyNpcExDragon recvDataNotifyNpcExDragon = new RecvDataNotifyNpcExDragon((uint)x);
                router.Send(client.map, recvDataNotifyNpcExDragon);
                break;

            case "level":
                RecvEventStart recvEventStart = new RecvEventStart(0, 0);
                router.Send(recvEventStart, client);
                Experience experience = new Experience();
                client.character.level++;
                client.character.hp.SetMax(client.character.hp.max + 10);
                client.character.mp.SetMax(client.character.mp.max + 10);
                client.character.strength     += (ushort)Util.GetRandomNumber(0, 2);
                client.character.vitality     += (ushort)Util.GetRandomNumber(0, 2);
                client.character.dexterity    += (ushort)Util.GetRandomNumber(0, 2);
                client.character.agility      += (ushort)Util.GetRandomNumber(0, 2);
                client.character.intelligence += (ushort)Util.GetRandomNumber(0, 2);
                client.character.piety        += (ushort)Util.GetRandomNumber(0, 2);
                client.character.luck         += (ushort)Util.GetRandomNumber(0, 2);
                int luckyShot = Util.GetRandomNumber(0, client.character.luck);
                if (luckyShot > client.character.luck * .8)
                {
                    client.character.hp.SetMax(client.character.hp.max + 10);
                    client.character.mp.SetMax(client.character.mp.max + 10);
                    client.character.strength     = (ushort)(Util.GetRandomNumber(-2, 2) + client.character.strength);
                    client.character.vitality     = (ushort)(Util.GetRandomNumber(-2, 2) + client.character.vitality);
                    client.character.dexterity    = (ushort)(Util.GetRandomNumber(-2, 2) + client.character.dexterity);
                    client.character.agility      = (ushort)(Util.GetRandomNumber(-2, 2) + client.character.agility);
                    client.character.intelligence = (ushort)(Util.GetRandomNumber(-2, 2) + client.character.intelligence);
                    client.character.piety        = (ushort)(Util.GetRandomNumber(-2, 2) + client.character.piety);
                    client.character.luck         = (ushort)(Util.GetRandomNumber(-2, 2) + client.character.luck);
                }

                RecvCharaUpdateLvDetailStart recvCharaUpdateLvDetailStart = new RecvCharaUpdateLvDetailStart();
                RecvCharaUpdateLv            recvCharaUpdateLv            = new RecvCharaUpdateLv(client.character);
                RecvCharaUpdateLvDetail      recvCharaUpdateLvDetail      = new RecvCharaUpdateLvDetail(client.character, experience);
                RecvCharaUpdateLvDetail2     recvCharaUpdateLvDetail2     = new RecvCharaUpdateLvDetail2(client.character, experience);
                RecvCharaUpdateLvDetailEnd   recvCharaUpdateLvDetailEnd   = new RecvCharaUpdateLvDetailEnd();

                RecvCharaUpdateMaxHp   recvCharaUpdateMaxHp      = new RecvCharaUpdateMaxHp(client.character.hp.max);
                RecvCharaUpdateMaxMp   recvCharaUpdateMaxMp      = new RecvCharaUpdateMaxMp(client.character.mp.max);
                RecvCharaUpdateAbility recvCharaUpdateAbilityStr = new RecvCharaUpdateAbility((int)RecvCharaUpdateAbility.Ability.Str, client.character.strength, client.character.battleParam.plusStrength);
                RecvCharaUpdateAbility recvCharaUpdateAbilityVit = new RecvCharaUpdateAbility((int)RecvCharaUpdateAbility.Ability.Vit, client.character.vitality, client.character.battleParam.plusVitality);
                RecvCharaUpdateAbility recvCharaUpdateAbilityDex = new RecvCharaUpdateAbility((int)RecvCharaUpdateAbility.Ability.Dex, client.character.dexterity, client.character.battleParam.plusDexterity);
                RecvCharaUpdateAbility recvCharaUpdateAbilityAgi = new RecvCharaUpdateAbility((int)RecvCharaUpdateAbility.Ability.Agi, client.character.agility, client.character.battleParam.plusAgility);
                RecvCharaUpdateAbility recvCharaUpdateAbilityInt = new RecvCharaUpdateAbility((int)RecvCharaUpdateAbility.Ability.Int, client.character.intelligence, client.character.battleParam.plusIntelligence);
                RecvCharaUpdateAbility recvCharaUpdateAbilityPie = new RecvCharaUpdateAbility((int)RecvCharaUpdateAbility.Ability.Pie, client.character.piety, client.character.battleParam.plusPiety);
                RecvCharaUpdateAbility recvCharaUpdateAbilityLuk = new RecvCharaUpdateAbility((int)RecvCharaUpdateAbility.Ability.Luk, client.character.luck, client.character.battleParam.plusLuck);

                router.Send(recvCharaUpdateLvDetailStart, client);


                router.Send(recvCharaUpdateMaxHp, client);
                router.Send(recvCharaUpdateMaxMp, client);
                router.Send(recvCharaUpdateAbilityStr, client);
                router.Send(recvCharaUpdateAbilityVit, client);
                router.Send(recvCharaUpdateAbilityDex, client);
                router.Send(recvCharaUpdateAbilityAgi, client);
                router.Send(recvCharaUpdateAbilityInt, client);
                router.Send(recvCharaUpdateAbilityPie, client);
                router.Send(recvCharaUpdateAbilityLuk, client);

                router.Send(recvCharaUpdateLv, client);
                router.Send(recvCharaUpdateLvDetail, client);
                router.Send(recvCharaUpdateLvDetail2, client);
                router.Send(recvCharaUpdateLvDetailEnd, client);

                break;

            case "questworks":
                RecvQuestGetMissionQuestWorks recvQuestGetMissionQuestWorks = new RecvQuestGetMissionQuestWorks();
                router.Send(client.map, recvQuestGetMissionQuestWorks);
                break;

            case "roguehistory":
                RecvQuestGetRogueMissionQuestHistoryR recvQuestGetRogueMissionQuestHistoryR = new RecvQuestGetRogueMissionQuestHistoryR();
                router.Send(client.map, recvQuestGetRogueMissionQuestHistoryR);
                break;

            case "debug":
                //recv_data_notify_debug_object_data = 0x6510,
                IBuffer resJ = BufferProvider.Provide();
                resJ.WriteUInt32(400000221);
                int numEntries = 0x20;
                resJ.WriteInt32(numEntries);     //less than or equal to 0x20
                for (int i = 0; i < numEntries; i++)
                {
                    resJ.WriteFloat(client.character.x + Util.GetRandomNumber(10, 50));
                    resJ.WriteFloat(client.character.y + Util.GetRandomNumber(10, 50));
                    resJ.WriteFloat(client.character.z + Util.GetRandomNumber(10, 50));
                }

                resJ.WriteByte(0);
                resJ.WriteByte(0);
                resJ.WriteByte(0);
                router.Send(client.map, (ushort)AreaPacketId.recv_data_notify_debug_object_data, resJ,
                            ServerType.Area);
                break;

            case "interface":
                RecvTradeNotifyInterfaceStatus recvTradeNotifyInterfaceStatus = new RecvTradeNotifyInterfaceStatus(x);
                router.Send(client.map, recvTradeNotifyInterfaceStatus);
                break;

            case "maxhp":
                RecvCharaUpdateMaxHp recvCharaUpdateMaxHp1 = new RecvCharaUpdateMaxHp(client.character.hp.max + 100);
                client.character.hp.SetMax(client.character.hp.max + 100);
                router.Send(client, recvCharaUpdateMaxHp1.ToPacket());
                break;



            default:     //you don't know what you're doing do you?
                _Logger.Error($"There is no recv of type : {command[0]} ");
                {
                    responses.Add(ChatResponse.CommandError(client,
                                                            $"{command[0]} is not a valid command."));
                }
                break;
            }

            res = BufferProvider.Provide();
            //Router.Send(client, (ushort)AreaPacketId.recv_situation_end, res, ServerType.Area);

            res = BufferProvider.Provide();
            res.WriteByte(0);
            //Router.Send(client, (ushort)AreaPacketId.recv_event_end, res, ServerType.Area);
            //Router.Send(client, (ushort)AreaPacketId.recv_event_end, res, ServerType.Area);
        }
        private void ResolveInn(NecClient client, int objectId, NpcSpawn npcSpawn)
        {
            if (client.character.eventSelectExecCode == 0)
            {
                int[]   hPandMPperChoice   = { 100, 50, 100, 100, 100, 100, 100, 50, 80, 100, 100 };
                byte[]  conditionPerChoice = { 150, 50, 100, 110, 120, 160, 150, 50, 80, 100, 120 };
                ulong[] goldCostPerChoice  = { 0, 0, 60, 300, 1200, 3000, 100, 0, 60, 300, 10000 };
                _Logger.Debug($"The selection you have made is {client.character.eventSelectExtraSelectionCode}");

                if (client.character.adventureBagGold < goldCostPerChoice[client.character.eventSelectExtraSelectionCode])
                {
                    IBuffer res = BufferProvider.Provide();
                    res.WriteCString("You don't have enough gold! This is why I don't like doing business with adventurers.");
                    router.Send(client, (ushort)AreaPacketId.recv_event_system_message, res, ServerType.Area); // show system message on middle of the screen.
                    RecvEventEnd(client);
                }
                else
                {
                    client.character.hp.SetCurrent((sbyte)hPandMPperChoice[client.character.eventSelectExtraSelectionCode], true);
                    client.character.mp.SetCurrent((sbyte)hPandMPperChoice[client.character.eventSelectExtraSelectionCode], true);
                    client.character.condition.SetCurrent(conditionPerChoice[client.character.eventSelectExtraSelectionCode]);
                    client.character.od.ToMax();
                    client.character.gp.ToMax();
                    client.character.adventureBagGold -= goldCostPerChoice[client.character.eventSelectExtraSelectionCode];
                    if (client.character.hp.current >= client.character.hp.max)
                    {
                        client.character.hp.ToMax();
                    }
                    if (client.character.mp.current >= client.character.mp.current)
                    {
                        client.character.mp.ToMax();
                    }

                    RecvCharaUpdateHp recvCharaUpdateHp = new RecvCharaUpdateHp(client.character.hp.current);
                    router.Send(recvCharaUpdateHp, client);
                    RecvCharaUpdateMp recvCharaUpdateMp = new RecvCharaUpdateMp(client.character.mp.current);
                    router.Send(recvCharaUpdateMp, client);
                    RecvCharaUpdateCon recvCharaUpdateCon = new RecvCharaUpdateCon(conditionPerChoice[client.character.eventSelectExtraSelectionCode]);
                    router.Send(recvCharaUpdateCon, client);
                    RecvSelfMoneyNotify recvSelfMoneyNotify = new RecvSelfMoneyNotify(client, client.character.adventureBagGold);
                    router.Send(recvSelfMoneyNotify, client);
                    RecvEventScriptPlay recvEventScriptPlay = new RecvEventScriptPlay("inn/fade_bgm", client.character.instanceId);
                    router.Send(recvEventScriptPlay, client);
                    Experience experience = new Experience();

                    //Level up stuff after inn cutscene
                    Task.Delay(TimeSpan.FromSeconds(6)).ContinueWith
                        (t1 =>
                    {
                        if (client.character.experienceCurrent > experience.CalculateLevelUp((uint)client.character.level + 1).cumulativeExperience)
                        {
                            RecvEventStart recvEventStart = new RecvEventStart(0, 0);
                            router.Send(recvEventStart, client);

                            LevelUpCheck(client);

                            Task.Delay(TimeSpan.FromSeconds(10)).ContinueWith
                                (t1 =>
                            {
                                RecvEventEnd recvEventEnd = new RecvEventEnd(0);
                                router.Send(recvEventEnd, client);         //Need a better way to end the event at the right time.
                            }
                                );
                        }
                    }
                        );
                }
            }
            else
            {
                SendEventEnd(client);
            }

            client.character.eventSelectExtraSelectionCode = 0;
            client.character.eventSelectExecCode           = 0;
            client.character.eventSelectReadyCode          = 0;
            client.character.secondInnAccess = false;
            server.database.UpdateCharacter(client.character);
        }