Changeset 230 for binary-improvements/AllocsCommands/Commands/Reply.cs
- Timestamp:
- Apr 18, 2015, 4:27:57 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/AllocsCommands/Commands/Reply.cs
r224 r230 4 4 namespace AllocsFixes.CustomCommands 5 5 { 6 public class Reply : ConsoleC ommand6 public class Reply : ConsoleCmdAbstract 7 7 { 8 public Reply (ConsoleSdtd cons) : base(cons) 9 { 10 } 11 12 public override string Description () 8 public override string GetDescription () 13 9 { 14 10 return "send a message to the player who last sent you a PM"; 15 11 } 16 12 17 public override string[] Names ()13 public override string[] GetCommands () 18 14 { 19 15 return new string[] { "reply", "re" }; 20 16 } 21 17 22 private void SendMessage (ClientInfo _receiver, ClientInfo _sender, string _message)18 private void RunInternal (ClientInfo _sender, List<string> _params) 23 19 { 24 PrivateMassageConnections.SetLastPMSender (_sender, _receiver); 25 string senderName = CommonMappingFunctions.GetPlayerName (_sender); 26 27 _receiver.netConnection [0].AddToSendQueue (new NetPackage_GameInfoMessage (_message, senderName + " (PM)")); 28 string receiverName = CommonMappingFunctions.GetPlayerName (_receiver); 29 m_Console.SendResult ("Message to player " + (receiverName != null ? "\"" + receiverName + "\"" : "unknownName") + " sent with sender \"" + senderName + "\""); 30 } 31 32 private void RunInternal (ClientInfo _sender, string[] _params) 33 { 34 if (_params.Length < 1) { 35 m_Console.SendResult ("Usage: reply <message>"); 20 if (_params.Count < 1) { 21 SdtdConsole.Instance.Output ("Usage: reply <message>"); 36 22 return; 37 23 } 38 24 39 25 string message = _params [0]; 40 for (int i = 1; i < _params.Length; i++) {41 message += " " + _params [i];42 }43 26 44 27 ClientInfo receiver = PrivateMassageConnections.GetLastPMSenderForPlayer (_sender); 45 if (receiver != null && CommonMappingFunctions.GetClientID (receiver)>= 0) {46 SendMessage (receiver, _sender, message);28 if (receiver != null && receiver.clientId >= 0) { 29 Chat.SendMessage (receiver, _sender, message); 47 30 } else { 48 31 if (receiver != null) { 49 m_Console.SendResult ("The sender of the PM you last received is currently not online.");32 SdtdConsole.Instance.Output ("The sender of the PM you last received is currently not online."); 50 33 } else { 51 m_Console.SendResult ("You have not received a PM so far.");34 SdtdConsole.Instance.Output ("You have not received a PM so far."); 52 35 } 53 36 } 54 37 } 55 38 56 public override void ExecuteRemote (string _sender, string[] _params) 57 { 58 try { 59 m_Console.SendResult (string.Format ("{0} executing remote command '{1}' {2}", _sender, this.Names () [0], string.Join (" ", _params))); 60 ClientInfo ci = CommonMappingFunctions.GetClientInfoFromSteamID (_sender); 61 RunInternal (ci, _params); 62 } catch (Exception e) { 63 Log.Out ("Error in Reply.ExecuteRemote: " + e); 39 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) { 40 if (_senderInfo.RemoteClientInfo == null) { 41 Log.Out ("Command \"reply\" can only be used on clients!"); 42 } else { 43 RunInternal (_senderInfo.RemoteClientInfo, _params); 64 44 } 65 }66 67 public override void Run (string[] _params)68 {69 Log.Out ("Command \"reply\" can only be used on clients!");70 45 } 71 46 }
Note:
See TracChangeset
for help on using the changeset viewer.