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

Last change on this file since 397 was 359, checked in by alloc, 5 years ago

Removed unnecessary try-catch-blocks from commands (command handler catches exceptions anyway and provides more detailed output)

File size: 1.3 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) {
[359]37 if (_senderInfo.RemoteClientInfo != null) {
38 RunInternal (_senderInfo.RemoteClientInfo, _params);
39 } else {
40 RunInternal (null, _params);
[224]41 }
42 }
43 }
[325]44}
Note: See TracBrowser for help on using the repository browser.