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

Last change on this file since 241 was 238, checked in by alloc, 9 years ago

Server fixes for A12

File size: 1.4 KB
RevLine 
[224]1using System;
2using System.Collections.Generic;
3
4namespace AllocsFixes.CustomCommands
5{
[230]6 public class Reply : ConsoleCmdAbstract
[224]7 {
[230]8 public override string GetDescription ()
[224]9 {
10 return "send a message to the player who last sent you a PM";
11 }
12
[238]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
[230]19 public override string[] GetCommands ()
[224]20 {
21 return new string[] { "reply", "re" };
22 }
23
[230]24 private void RunInternal (ClientInfo _sender, List<string> _params)
[224]25 {
[230]26 if (_params.Count < 1) {
27 SdtdConsole.Instance.Output ("Usage: reply <message>");
[224]28 return;
29 }
30
31 string message = _params [0];
32
33 ClientInfo receiver = PrivateMassageConnections.GetLastPMSenderForPlayer (_sender);
[233]34 if (receiver != null) {
[230]35 Chat.SendMessage (receiver, _sender, message);
[224]36 } else {
37 if (receiver != null) {
[230]38 SdtdConsole.Instance.Output ("The sender of the PM you last received is currently not online.");
[224]39 } else {
[230]40 SdtdConsole.Instance.Output ("You have not received a PM so far.");
[224]41 }
42 }
43 }
44
[230]45 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) {
46 if (_senderInfo.RemoteClientInfo == null) {
47 Log.Out ("Command \"reply\" can only be used on clients!");
48 } else {
49 RunInternal (_senderInfo.RemoteClientInfo, _params);
[224]50 }
51 }
52 }
53}
Note: See TracBrowser for help on using the repository browser.