Exemple #1
0
        /*public static void OpenChatWindowRequest( NetState state, PacketReader pvSrc )
         * {
         *      Mobile from = state.Mobile;
         *
         *      if ( !m_Enabled )
         *      {
         *              from.SendMessage( "The chat system has been disabled." );
         *              return;
         *      }
         *
         *      //pvSrc.Seek( 2, System.IO.SeekOrigin.Begin );
         *      //string chatName = pvSrc.ReadUnicodeStringSafe( ( 0x40 - 2 ) >> 1 ).Trim();
         * string chatName = "";
         *
         *      Account acct = state.Account as Account;
         *
         *      string accountChatName = null;
         *
         *      if ( acct != null )
         *              accountChatName = acct.GetTag( "ChatName" );
         *
         *      if ( accountChatName != null )
         *              accountChatName = accountChatName.Trim();
         *
         *      if ( accountChatName != null && accountChatName.Length > 0 )
         *      {
         *              if ( chatName.Length > 0 && chatName != accountChatName )
         *                      from.SendMessage( "You cannot change chat nickname once it has been set." );
         *      }
         *      else
         *      {
         *              if ( chatName == null || chatName.Length == 0 )
         *              {
         *                      SendCommandTo( from, ChatCommand.AskNewNickname );
         *                      return;
         *              }
         *
         *              if ( NameVerification.Validate( chatName, 2, 31, true, true, true, 0, NameVerification.SpaceDashPeriodQuote ) && chatName.ToLower().IndexOf( "system" ) == -1 )
         *              {
         *                      // TODO: Optimize this search
         *
         *                      foreach ( Account checkAccount in Accounts.GetAccounts() )
         *                      {
         *                              string existingName = checkAccount.GetTag( "ChatName" );
         *
         *                              if ( existingName != null )
         *                              {
         *                                      existingName = existingName.Trim();
         *
         *                                      if ( Insensitive.Equals( existingName, chatName ) )
         *                                      {
         *                                              from.SendMessage( "Nickname already in use." );
         *                                              SendCommandTo( from, ChatCommand.AskNewNickname );
         *                                              return;
         *                                      }
         *                              }
         *                      }
         *
         *                      accountChatName = chatName;
         *
         *                      if ( acct != null )
         *                              acct.AddTag( "ChatName", chatName );
         *              }
         *              else
         *              {
         *                      from.SendLocalizedMessage( 501173 ); // That name is disallowed.
         *                      SendCommandTo( from, ChatCommand.AskNewNickname );
         *                      return;
         *              }
         *      }
         *
         *      SendCommandTo( from, ChatCommand.OpenChatWindow, accountChatName );
         *      ChatUser.AddChatUser( from );
         * } */

        public static void EventSink_Login(LoginEventArgs e)
        {
            Mobile from = e.Mobile;

            if (!m_Enabled)
            {
                return;
            }

            else if (from.RawName == "Generic Player")
            {
                return;
            }

            var user = ChatUser.GetChatUser(from);

            if (user != null)
            {
                Channel.SendChannelsTo(user);
            }

            else
            {
                ChatUser.AddChatUser(from);
            }
        }
Exemple #2
0
        public static ChatUser SearchForUser(ChatUser from, string name)
        {
            ChatUser user = ChatUser.GetChatUser(name);

            if (user == null)
            {
                from.SendMessage(32, name);                   // There is no player named '%1'.
            }
            return(user);
        }
Exemple #3
0
        public static void ChatAction(NetState state, PacketReader pvSrc)
        {
            if (!m_Enabled)
            {
                return;
            }

            try
            {
                Mobile   from = state.Mobile;
                ChatUser user = ChatUser.GetChatUser(from);

                if (user == null)
                {
                    return;
                }

                string lang     = pvSrc.ReadStringSafe(4);
                int    actionID = pvSrc.ReadInt16();
                string param    = pvSrc.ReadUnicodeString();

                ChatActionHandler handler = ChatActionHandlers.GetHandler(actionID);

                if (handler != null)
                {
                    Channel channel = user.CurrentChannel;

                    if (handler.RequireConference && channel == null)
                    {
                        user.SendMessage(31);                         /* You must be in a conference to do this.
                                                                       * To join a conference, select one from the Conference menu.
                                                                       */
                    }
                    else if (handler.RequireModerator && !user.IsModerator)
                    {
                        user.SendMessage(29);                         // You must have operator status to do this.
                    }
                    else
                    {
                        handler.Callback(user, channel, param);
                    }
                }
                else
                {
                    Console.WriteLine("Client: {0}: Unknown chat action 0x{1:X}: {2}", state, actionID, param);
                }
            }
            catch (Exception e)
            {
                LogHelper.LogException(e);
                Console.WriteLine(e);
            }
        }
Exemple #4
0
        public static void ChatAction(NetState state, CircularBufferReader reader, int packetLength)
        {
            if (!ChatSystem.Enabled)
            {
                return;
            }

            try
            {
                var from = state.Mobile;
                var user = ChatUser.GetChatUser(from);

                if (user == null)
                {
                    return;
                }

                var lang     = reader.ReadAsciiSafe(4);
                int actionID = reader.ReadInt16();
                var param    = reader.ReadBigUniSafe();

                var handler = ChatActionHandlers.GetHandler(actionID);

                if (handler == null)
                {
                    state.LogInfo($"Unknown chat action 0x{actionID:X}: {param}");
                    return;
                }

                var channel = user.CurrentChannel;

                if (handler.RequireConference && channel == null)
                {
                    // You must be in a conference to do this.
                    // To join a conference, select one from the Conference menu.
                    user.SendMessage(31);
                    return;
                }

                if (handler.RequireModerator && !user.IsModerator)
                {
                    user.SendMessage(29); // You must have operator status to do this.
                    return;
                }

                handler.Callback(user, channel, param);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemple #5
0
        public static void ChatAction(NetState state, PacketReader reader)
        {
            if (!Enabled)
            {
                return;
            }

            try
            {
                var from = state.Mobile;
                var user = ChatUser.GetChatUser(from);

                if (user == null)
                {
                    return;
                }

                var lang     = reader.ReadStringSafe(4);
                int actionID = reader.ReadInt16();
                var param    = reader.ReadUnicodeString();

                var handler = ChatActionHandlers.GetHandler(actionID);

                if (handler == null)
                {
                    Console.WriteLine("Client: {0}: Unknown chat action 0x{1:X}: {2}", state, actionID, param);
                    return;
                }

                var channel = user.CurrentChannel;

                if (handler.RequireConference && channel == null)
                {
                    // You must be in a conference to do this.
                    // To join a conference, select one from the Conference menu.
                    user.SendMessage(31);
                    return;
                }

                if (handler.RequireModerator && !user.IsModerator)
                {
                    user.SendMessage(29); // You must have operator status to do this.
                    return;
                }

                handler.Callback(user, channel, param);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        private static void HideChatFrom(Mobile player)
        {
            if (player.Account == null)
            {
                return;
            }

            Account account = player.Account as Account;

            ChatSystem.SendCommandTo(player, ChatCommand.CloseChatWindow);
            ChatUser user = ChatUser.GetChatUser(player);

            ChatUser.RemoveChatUser(user);
        }
Exemple #7
0
        public static void ChatAction(NetState state, PacketReader pvSrc)
        {
            if (!Enabled)
            {
                return;
            }

            try
            {
                Mobile   from = state.Mobile;
                ChatUser user = ChatUser.GetChatUser(from);

                if (user == null)
                {
                    return;
                }

                string lang     = pvSrc.ReadStringSafe(4);
                short  actionId = pvSrc.ReadInt16();
                string param    = pvSrc.ReadUnicodeString();

                ChatActionHandler handler = ChatActionHandlers.GetHandler(actionId);

                if (handler != null)
                {
                    Channel channel = user.CurrentChannel;

                    if (handler.RequireConference && channel == null)
                    {
                        /* You must be in a conference to do this.
                         * To join a conference, select one from the Conference menu.
                         */
                        user.SendMessage(31);
                    }
                    else
                    {
                        handler.Callback(user, channel, param);
                    }
                }
                else
                {
                    Console.WriteLine("Client: {0}: Unknown chat action 0x{1:X}: {2}", state, actionId, param);
                }
            }
            catch (Exception e)
            {
                Diagnostics.ExceptionLogging.LogException(e);
            }
        }