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

Last change on this file since 255 was 238, checked in by alloc, 9 years ago

Server fixes for A12

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