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

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

Server fixes for A12

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