source: binary-improvements/CoppisAdditions/src/Commands/SayToPlayer2.cs@ 298

Last change on this file since 298 was 273, checked in by alloc, 9 years ago

fixes 8_10_13_1

File size: 1.7 KB
RevLine 
[273]1using System;
2using System.Collections.Generic;
3
4namespace CoppisAdditions.CustomCommands
5{
6 public class SayToPlayer2 : ConsoleCmdAbstract
7 {
8 public override string GetDescription ()
9 {
10 return "send a message to a single player with a specific sender name";
11 }
12
13 public override string GetHelp ()
14 {
15 return "Usage:\n" +
16 " pm2 <sender player name / steam id / entity id> <receiver player name / steam id / entity id> <message>\n" +
17 "Send a PM from a player to another player, both given by the player name or steam / entity id (as given by e.g. \"lpi\").";
18 }
19
20 public override string[] GetCommands ()
21 {
22 return new string[] { "sayplayer2", "pm2" };
23 }
24
25 private void RunInternal (ClientInfo _sender, List<string> _params)
26 {
27 if (_params.Count < 3) {
28 SdtdConsole.Instance.Output ("Usage: sayplayer2 <playername|entityid> <playername|entityid> <message>");
29 return;
30 }
31
32 string message = _params [2];
33 ClientInfo sender = ConsoleHelper.ParseParamIdOrName (_params [0]);
34 ClientInfo receiver = ConsoleHelper.ParseParamIdOrName (_params [1]);
35
36 if (sender != null && receiver != null) {
37 AllocsFixes.CustomCommands.Chat.SendMessage (receiver, sender, message);
38 } else {
39 SdtdConsole.Instance.Output ("Playername / SteamID / entity id of either sender or receiver not found.");
40 }
41 }
42
43 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo)
44 {
45 try {
46 if (_senderInfo.RemoteClientInfo != null) {
47 RunInternal (_senderInfo.RemoteClientInfo, _params);
48 } else {
49 RunInternal (null, _params);
50 }
51 } catch (Exception e) {
52 Log.Out ("Error in SayToPlayer2.Run: " + e);
53 }
54 }
55 }
56}
Note: See TracBrowser for help on using the repository browser.