source: binary-improvements/AllocsCommands/Commands/SayToPlayer.cs@ 231

Last change on this file since 231 was 230, checked in by alloc, 10 years ago

Binary improvements

File size: 1.1 KB
RevLine 
[224]1using System;
2using System.Collections.Generic;
3
4namespace AllocsFixes.CustomCommands
5{
[230]6 public class SayToPlayer : ConsoleCmdAbstract
[224]7 {
[230]8 public override string GetDescription ()
[224]9 {
10 return "send a message to a single player";
11 }
12
[230]13 public override string[] GetCommands ()
[224]14 {
15 return new string[] { "sayplayer", "pm" };
16 }
17
[230]18 private void RunInternal (ClientInfo _sender, List<string> _params)
[224]19 {
[230]20 if (_params.Count < 2) {
21 SdtdConsole.Instance.Output ("Usage: sayplayer <playername|entityid> <message>");
[224]22 return;
23 }
24
25 string message = _params [1];
26
[230]27 ClientInfo receiver = ConsoleHelper.ParseParamIdOrName (_params [0]);
[224]28 if (receiver != null) {
[230]29 Chat.SendMessage (receiver, _sender, message);
[224]30 } else {
[230]31 SdtdConsole.Instance.Output ("Playername or entity ID not found.");
[224]32 }
33 }
34
[230]35 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo)
[224]36 {
37 try {
[230]38 if (_senderInfo.RemoteClientInfo != null) {
39 RunInternal (_senderInfo.RemoteClientInfo, _params);
40 } else {
41 RunInternal (null, _params);
42 }
[224]43 } catch (Exception e) {
44 Log.Out ("Error in SayToPlayer.Run: " + e);
45 }
46 }
47 }
48}
Note: See TracBrowser for help on using the repository browser.