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

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

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

File size: 1.4 KB
RevLine 
[224]1using System;
2using System.Collections.Generic;
3
[325]4namespace AllocsFixes.CustomCommands {
5 public class SayToPlayer : ConsoleCmdAbstract {
6 public override string GetDescription () {
[224]7 return "send a message to a single player";
8 }
9
[238]10 public override string GetHelp () {
11 return "Usage:\n" +
[325]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\").";
[238]14 }
15
[325]16 public override string[] GetCommands () {
17 return new[] {"sayplayer", "pm"};
[224]18 }
19
[325]20 private void RunInternal (ClientInfo _sender, List<string> _params) {
[230]21 if (_params.Count < 2) {
22 SdtdConsole.Instance.Output ("Usage: sayplayer <playername|entityid> <message>");
[224]23 return;
24 }
25
26 string message = _params [1];
27
[230]28 ClientInfo receiver = ConsoleHelper.ParseParamIdOrName (_params [0]);
[224]29 if (receiver != null) {
[230]30 Chat.SendMessage (receiver, _sender, message);
[224]31 } else {
[230]32 SdtdConsole.Instance.Output ("Playername or entity ID not found.");
[224]33 }
34 }
35
[325]36 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) {
[224]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 }
[325]48}
Note: See TracBrowser for help on using the repository browser.