Last change
on this file since 373 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
|
Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 |
|
---|
4 | namespace 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 | if (_senderInfo.RemoteClientInfo != null) {
|
---|
38 | RunInternal (_senderInfo.RemoteClientInfo, _params);
|
---|
39 | } else {
|
---|
40 | RunInternal (null, _params);
|
---|
41 | }
|
---|
42 | }
|
---|
43 | }
|
---|
44 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.