- Timestamp:
- Aug 26, 2014, 4:41:47 PM (10 years ago)
- Location:
- binary-improvements/7dtd-server-fixes/src/CustomCommands
- Files:
-
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/7dtd-server-fixes/src/CustomCommands/Reply.cs
r112 r130 2 2 using System.Collections.Generic; 3 3 4 public class Reply : ConsoleCommand 4 namespace AllocsFixes.CustomCommands 5 5 { 6 public Reply (ConsoleSdtd cons) : base(cons)6 public class Reply : ConsoleCommand 7 7 { 8 } 8 public Reply (ConsoleSdtd cons) : base(cons) 9 { 10 } 9 11 10 public override string Description ()11 {12 return "send a message to the player who last sent you a PM";13 }12 public override string Description () 13 { 14 return "send a message to the player who last sent you a PM"; 15 } 14 16 15 public override string[] Names ()16 {17 return new string[] { "reply", "re" };18 }17 public override string[] Names () 18 { 19 return new string[] { "reply", "re" }; 20 } 19 21 20 private void SendMessage (ClientInfo _receiver, ClientInfo _sender, string _message)21 {22 PrivateMassageConnections.SetLastPMSender (_sender, _receiver);23 string senderName = CommonMappingFunctions.GetPlayerName (_sender);22 private void SendMessage (ClientInfo _receiver, ClientInfo _sender, string _message) 23 { 24 PrivateMassageConnections.SetLastPMSender (_sender, _receiver); 25 string senderName = CommonMappingFunctions.GetPlayerName (_sender); 24 26 25 CommonMappingFunctions.GetConnectionManager ().networkView.RPC ("RPC_ChatMessage", _receiver.networkPlayer,27 CommonMappingFunctions.GetConnectionManager ().networkView.RPC ("RPC_ChatMessage", _receiver.networkPlayer, 26 28 new object[] { 27 29 _message, … … 30 32 true 31 33 } 32 ); 33 string receiverName = CommonMappingFunctions.GetPlayerName (_receiver); 34 m_Console.SendResult ("Message to player " + (receiverName != null ? "\"" + receiverName + "\"" : "unknownName") + " sent with sender \"" + senderName + "\""); 35 } 36 37 private void RunInternal (ClientInfo _sender, string[] _params) 38 { 39 if (_params.Length < 1) { 40 m_Console.SendResult ("Usage: reply <message>"); 41 return; 34 ); 35 string receiverName = CommonMappingFunctions.GetPlayerName (_receiver); 36 m_Console.SendResult ("Message to player " + (receiverName != null ? "\"" + receiverName + "\"" : "unknownName") + " sent with sender \"" + senderName + "\""); 42 37 } 43 38 44 string message = _params [0]; 45 for (int i = 1; i < _params.Length; i++) { 46 message += " " + _params [i]; 39 private void RunInternal (ClientInfo _sender, string[] _params) 40 { 41 if (_params.Length < 1) { 42 m_Console.SendResult ("Usage: reply <message>"); 43 return; 44 } 45 46 string message = _params [0]; 47 for (int i = 1; i < _params.Length; i++) { 48 message += " " + _params [i]; 49 } 50 51 ClientInfo receiver = PrivateMassageConnections.GetLastPMSenderForPlayer (_sender); 52 if (receiver != null && CommonMappingFunctions.GetClientID (receiver) >= 0) { 53 SendMessage (receiver, _sender, message); 54 } else { 55 if (receiver != null) { 56 m_Console.SendResult ("The sender of the PM you last received is currently not online."); 57 } else { 58 m_Console.SendResult ("You have not received a PM so far."); 59 } 60 } 47 61 } 48 62 49 ClientInfo receiver = PrivateMassageConnections.GetLastPMSenderForPlayer (_sender);50 if (receiver != null && CommonMappingFunctions.GetClientID (receiver) >= 0){51 SendMessage (receiver, _sender, message);52 } else {53 if (receiver != null) {54 m_Console.SendResult ("The sender of the PM you last received is currently not online.");55 } else{56 m_Console.SendResult ("You have not received a PM so far.");63 public override void ExecuteRemote (string _sender, string[] _params) 64 { 65 try { 66 m_Console.SendResult (string.Format ("{0} executing remote command '{1}' {2}", _sender, this.Names () [0], string.Join (" ", _params))); 67 ClientInfo ci = CommonMappingFunctions.GetClientInfoFromSteamID (_sender); 68 RunInternal (ci, _params); 69 } catch (Exception e) { 70 Log.Out ("Error in Reply.ExecuteRemote: " + e); 57 71 } 58 72 } 59 }60 73 61 public override void ExecuteRemote (string _sender, string[] _params) 62 { 63 try { 64 m_Console.SendResult (string.Format ("{0} executing remote command '{1}' {2}", _sender, this.Names () [0], string.Join (" ", _params))); 65 ClientInfo ci = CommonMappingFunctions.GetClientInfoFromSteamID (_sender); 66 RunInternal (ci, _params); 67 } catch (Exception e) { 68 Log.Out ("Error in Reply.ExecuteRemote: " + e); 74 public override void Run (string[] _params) 75 { 76 Log.Out ("Command \"reply\" can only be used on clients!"); 69 77 } 70 78 } 71 72 public override void Run (string[] _params)73 {74 Log.Out ("Command \"reply\" can only be used on clients!");75 }76 79 } 77
Note:
See TracChangeset
for help on using the changeset viewer.