source: binary-improvements2/AllocsCommands/Commands/SayToPlayer.cs@ 390

Last change on this file since 390 was 383, checked in by alloc, 2 years ago

Fixed a bunch of warnings

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