source: binary-improvements/AllocsCommands/Commands/Reply.cs@ 313

Last change on this file since 313 was 309, checked in by alloc, 7 years ago

Fixes 14_16_21

File size: 1.3 KB
Line 
1using System;
2using System.Collections.Generic;
3
4namespace AllocsFixes.CustomCommands
5{
6 public class Reply : ConsoleCmdAbstract
7 {
8 public override string GetDescription ()
9 {
10 return "send a message to the player who last sent you a PM";
11 }
12
13 public override string GetHelp () {
14 return "Usage:\n" +
15 " reply <message>\n" +
16 "Send the given message to the user you last received a PM from.";
17 }
18
19 public override string[] GetCommands ()
20 {
21 return new string[] { "reply", "re" };
22 }
23
24 private void RunInternal (ClientInfo _sender, List<string> _params)
25 {
26 if (_params.Count < 1) {
27 SdtdConsole.Instance.Output ("Usage: reply <message>");
28 return;
29 }
30
31 string message = _params [0];
32
33 ClientInfo receiver = PrivateMessageConnections.GetLastPMSenderForPlayer (_sender);
34 if (receiver != null) {
35 Chat.SendMessage (receiver, _sender, message);
36 } else {
37 SdtdConsole.Instance.Output ("You have not received a PM so far or sender of last received PM is no longer online.");
38 }
39 }
40
41 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) {
42 if (_senderInfo.RemoteClientInfo == null) {
43 Log.Out ("Command \"reply\" can only be used on clients!");
44 } else {
45 RunInternal (_senderInfo.RemoteClientInfo, _params);
46 }
47 }
48 }
49}
Note: See TracBrowser for help on using the repository browser.