示例#1
0
        private void pmCommand(BasePlayer player, string command, string[] args)
        {
            if (!hasPermission(player, permissions.use))
            {
                PrintToChat(player, lang.GetMessage("noPermission", this, player.UserIDString));
                return;
            }

            if (args.Length < 2)
            {
                PrintToChat(player, lang.GetMessage(msg.invalidArguments.ToString(), this, player.UserIDString));
                return;
            }

            BasePlayer recipient = findPlayer(args[0], player);

            if (recipient == null)
            {
                return;
            }

            StringBuilder sb = new StringBuilder();

            foreach (string s in args.Skip(1))
            {
                sb.Append($" {s}");
            }
            string text = sb.ToString().Trim();

            List <BasePlayer> participants = new List <BasePlayer> {
                player, recipient
            };

            Conversation conversation = ConversationData.ConversationFactory(participants);

            Message message = new Message(player, text, conversation);

            conversation.Messages.Add(message);
            ConversationData.save();

            message.deliver();
        }