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

Last change on this file since 327 was 325, checked in by alloc, 6 years ago

Code style cleanup (mostly whitespace changes, enforcing braces, using cleanup)

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