fCraft.Chat.SendCustom C# (CSharp) Method

SendCustom() public static method

public static SendCustom ( Player player, string rawMessage ) : bool
player Player
rawMessage string
return bool
        public static bool SendCustom( Player player, string rawMessage ) {
            if ( player == null )
                throw new ArgumentNullException( "player" );
            if ( rawMessage == null )
                throw new ArgumentNullException( "rawMessage" );
            var recepientList = Server.Players.Can( Permission.ReadCustomChat )
                                              .NotIgnoring( player );

            string formattedMessage = String.Format( Color.Custom + "({2}){0}&b: {1}",
                                                     player.ClassyName,
                                                     rawMessage, ConfigKey.CustomChatName.GetString() );

            var e = new ChatSendingEventArgs( player,
                                              rawMessage,
                                              formattedMessage,
                                              ChatMessageType.Staff,
                                              recepientList );

            if ( !SendInternal( e ) )
                return false;

            Logger.Log( LogType.GlobalChat, "({2}){0}: {1}", player.Name, rawMessage, ConfigKey.CustomChatName.GetString() );
            return true;
        }

Usage Example

Example #1
0
        private static void CustomChatHandler(Player player, Command cmd)
        {
            if (player.Info.IsMuted)
            {
                player.MessageMuted();
                return;
            }

            if (player.DetectChatSpam())
            {
                return;
            }

            string message = cmd.NextAll().Trim();

            if (message.Length <= 0)
            {
                return;
            }
            if (player.Can(Permission.UseColorCodes) && message.Contains("%"))
            {
                message = Color.ReplacePercentCodes(message);
            }
            Chat.SendCustom(player, message);
        }