Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 |
|
---|
4 | namespace AllocsFixes.CustomCommands
|
---|
5 | {
|
---|
6 | public class SayToPlayer : ConsoleCmdAbstract
|
---|
7 | {
|
---|
8 | public override string GetDescription ()
|
---|
9 | {
|
---|
10 | return "send a message to a single player";
|
---|
11 | }
|
---|
12 |
|
---|
13 | public override string[] GetCommands ()
|
---|
14 | {
|
---|
15 | return new string[] { "sayplayer", "pm" };
|
---|
16 | }
|
---|
17 |
|
---|
18 | private void RunInternal (ClientInfo _sender, List<string> _params)
|
---|
19 | {
|
---|
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 | {
|
---|
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.