- Timestamp:
- Apr 18, 2015, 4:27:57 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/AllocsCommands/Commands/SayToPlayer.cs
r224 r230 4 4 namespace AllocsFixes.CustomCommands 5 5 { 6 public class SayToPlayer : ConsoleC ommand6 public class SayToPlayer : ConsoleCmdAbstract 7 7 { 8 public SayToPlayer (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 a single player"; 15 11 } 16 12 17 public override string[] Names ()13 public override string[] GetCommands () 18 14 { 19 15 return new string[] { "sayplayer", "pm" }; 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 string senderName; 25 if (_sender != null) { 26 PrivateMassageConnections.SetLastPMSender (_sender, _receiver); 27 senderName = CommonMappingFunctions.GetPlayerName (_sender); 28 } else { 29 senderName = "Server"; 30 } 31 ConnectionManager.Instance.SendPackage (new NetPackage_GameInfoMessage (_message, senderName + " (PM)"), new PackageDestinationSingleEntityID (_receiver.entityId)); 32 string receiverName = CommonMappingFunctions.GetPlayerName (_receiver); 33 m_Console.SendResult ("Message to player " + (receiverName != null ? "\"" + receiverName + "\"" : "unknownName") + " sent with sender \"" + senderName + "\""); 34 } 35 36 private void RunInternal (ClientInfo _sender, string[] _params) 37 { 38 if (_params.Length < 2) { 39 m_Console.SendResult ("Usage: sayplayer <playername|entityid> <message>"); 20 if (_params.Count < 2) { 21 SdtdConsole.Instance.Output ("Usage: sayplayer <playername|entityid> <message>"); 40 22 return; 41 23 } 42 24 43 25 string message = _params [1]; 44 for (int i = 2; i < _params.Length; i++) {45 message += " " + _params [i];46 }47 26 48 ClientInfo receiver = Co mmonMappingFunctions.GetClientInfoFromNameOrID (_params [0], true);27 ClientInfo receiver = ConsoleHelper.ParseParamIdOrName (_params [0]); 49 28 if (receiver != null) { 50 SendMessage (receiver, _sender, message);29 Chat.SendMessage (receiver, _sender, message); 51 30 } else { 52 m_Console.SendResult ("Playername or entity ID not found.");31 SdtdConsole.Instance.Output ("Playername or entity ID not found."); 53 32 } 54 33 } 55 34 56 public override void Execute Remote (string _sender, string[] _params)35 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) 57 36 { 58 37 try { 59 this.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 SayToPlayer.ExecuteRemote: " + e); 64 } 65 } 66 67 public override void Run (string[] _params) 68 { 69 try { 70 RunInternal (null, _params); 38 if (_senderInfo.RemoteClientInfo != null) { 39 RunInternal (_senderInfo.RemoteClientInfo, _params); 40 } else { 41 RunInternal (null, _params); 42 } 71 43 } catch (Exception e) { 72 44 Log.Out ("Error in SayToPlayer.Run: " + e);
Note:
See TracChangeset
for help on using the changeset viewer.