source: binary-improvements/CoppisAdditions/src/Commands/ListPlayersBed.cs@ 291

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

fixes 8_10_13_1

File size: 2.4 KB
RevLine 
[273]1using System;
2using System.Collections.Generic;
3using System.Reflection;
4
5namespace CoppisAdditions.CustomCommands
6{
7 public class ListPlayersBed : ConsoleCmdAbstract
8 {
9 public override string GetDescription ()
10 {
11 return "list bed locations of all players or a specific player";
12 }
13
14 public override string GetHelp ()
15 {
16 return "Usage:\n" +
17 " 1. lpb <steam id / player name / entity id>" +
18 "or " +
19 " 2. lpb *this will list all players online and their bed";
20 }
21
22 public override string[] GetCommands ()
23 {
24 return new string[] { "listplayerbed", "lpb" };
25 }
26
27 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo)
28 {
29 try {
30 if (_params.Count > 1) {
31 SdtdConsole.Instance.Output ("Usage: listplayerbed <entityid|playername|steamid> or listplayerbed (without params)");
32 } else {
33 if (_params.Count == 1) {
34 ClientInfo ci1 = ConsoleHelper.ParseParamIdOrName (_params [0]);
35 if (ci1 == null) {
36 SdtdConsole.Instance.Output ("Playername or entity/steamid id not found.");
37 return;
38 }
39 EntityPlayer ep1 = GameManager.Instance.World.Players.dict [ci1.entityId];
40 EntityBedrollPositionList bed = ep1.SpawnPoints;
41
42 if (bed.Count == 0) {
43 SdtdConsole.Instance.Output ("The player does not have a bed");
44 return;
45 }
46 for (int x = 0; x < bed.Count; x++) {
47 Vector3i pos = bed [x];
48 SdtdConsole.Instance.Output ("PlayerBed: " + ep1.EntityName + " at " + pos.x + ", " + pos.y + ", " + pos.z);
49 }
50 } else if (_params.Count == 0) {
51 Dictionary<int, EntityPlayer>.Enumerator enumerator = GameManager.Instance.World.Players.dict.GetEnumerator ();
52 while (enumerator.MoveNext ()) {
53 KeyValuePair<int, EntityPlayer> pair = enumerator.Current;
54 EntityPlayer ep1 = pair.Value;
55 EntityBedrollPositionList bed = ep1.SpawnPoints;
56 if (bed.Count == 0) {
57 SdtdConsole.Instance.Output ("The player " + ep1.EntityName + " does not have any bed");
58 return;
59 } else {
60 for (int x = 0; x < bed.Count; x++) {
61 Vector3i pos = bed [x];
62 SdtdConsole.Instance.Output (ep1.EntityName + ": " + pos.x + ", " + pos.y + ", " + pos.z);
63 }
64 }
65 }
66 }
67 }
68 } catch (Exception e) {
69 Log.Out ("Error in ListPlayersBed.Run: " + e);
70 }
71 }
72 }
73}
Note: See TracBrowser for help on using the repository browser.