コード例 #1
0
        internal static void OnMessageChat(RealmServerSession session, PacketReader handler)
        {
            ChatMessageType     msgType     = (ChatMessageType)handler.ReadUInt32();
            ChatMessageLanguage msgLanguage = (ChatMessageLanguage)handler.ReadUInt32();

            string toUser  = null;
            string channel = null;

            if (msgType == ChatMessageType.CHAT_MSG_CHANNEL)
            {
                channel = handler.ReadCString();
            }

            if (msgType == ChatMessageType.CHAT_MSG_WHISPER)
            {
                toUser = handler.ReadCString();
            }

            string message = handler.ReadCString();

            // Call Commands
            new CommandsHelper(session, message);

            switch ((ChatMessageType)msgType)
            {
            case ChatMessageType.CHAT_MSG_SAY:
            case ChatMessageType.CHAT_MSG_YELL:
            case ChatMessageType.CHAT_MSG_EMOTE:
                session.SendPacket(new SmsgMessagechat(msgType, ChatMessageLanguage.LANG_UNIVERSAL, (ulong)session.Character.Id, message));
                session.Entity.KnownPlayers.ForEach(s => s.Session.SendPacket(new SmsgMessagechat(msgType, ChatMessageLanguage.LANG_UNIVERSAL, (ulong)session.Character.Id, message)));
                break;

            case ChatMessageType.CHAT_MSG_WHISPER:
                try
                {
                    RealmServerSession remoteSession = RealmServerSession.GetSessionByPlayerName(toUser);

                    // Check if player is the same faction?

                    // Send packet
                    session.SendPacket(new SmsgMessagechat(ChatMessageType.CHAT_MSG_WHISPER_INFORM,
                                                           ChatMessageLanguage.LANG_UNIVERSAL, (ulong)remoteSession.Character.Id, message));
                    remoteSession.SendPacket(new SmsgMessagechat(msgType, ChatMessageLanguage.LANG_UNIVERSAL,
                                                                 (ulong)session.Character.Id, message));
                }
                catch (Exception e)
                {
                    // Envia mensagem que nao achou
                    Console.WriteLine($@"naoa chei nada {e.Message}");
                }
                break;

            default:
                Console.WriteLine($@"veio aqui algo [{msgType}]");
                session.SendPacket(new SmsgMessagechat(msgType, ChatMessageLanguage.LANG_UNIVERSAL, (ulong)session.Character.Id, message));
                break;
            }

            /*
             *  2 - Raid
             *  3 - Guild
             *  4 - Officer
             *  6 - Whisper From
             *  7 - Whisper To
             *  8 - Emote
             *  9 - nao sei
             *  10 - Server
             *  17 - nao sei  cinza
             *  20 - AFK
             *  21 - DND
             *  22 - Ignore
             *  23 - nao sei azul
             *  24 - verde
             *              Write((byte) type);
             *              Write((uint) msgLanguage);
             *              Write(characterId);
             *              Write((uint) message.Length + 1);
             *              Write(Encoding.UTF8.GetBytes(message + '\0'));
             *              Write((byte)0); // Flag????
             *
             *  13 - ti´po emote
             *  26 - whispers: algo
             *              Write((byte) type);
             *              Write((uint) msgLanguage);
             *              Write((uint) 0);
             *              Write(characterId);
             *              Write((uint) message.Length + 1);
             *              Write(Encoding.UTF8.GetBytes(message + '\0'));
             *              Write((byte) 0); // 0 = normal / 1 = AFK / 2 = DND / 3 = GM
             *
             *  11 - npc Says
             *  12 - npc Yells
             *              Write((byte) type);
             *              Write((uint) msgLanguage);
             *              Write((uint) 0);
             *              Write(characterId);
             *              Write(characterId);
             *              Write((uint) message.Length + 1);
             *              Write(Encoding.UTF8.GetBytes(message + '\0'));
             *              Write((byte) 0); // 0 = normal / 1 = AFK / 2 = DND / 3 = GM
             *
             *  0- say
             *  1 - party
             *  5 - yell
             *              Write((byte) type);
             *              Write((uint) msgLanguage);
             *              Write(characterId);
             *              Write(characterId);
             *              Write((uint) message.Length + 1);
             *              Write(Encoding.UTF8.GetBytes(message + '\0'));
             *              Write((byte) 0); // 0 = normal / 1 = AFK / 2 = DND / 3 = GM
             */
        }