1 | using AllocsFixes.PersistentData;
|
---|
2 | using System;
|
---|
3 | using System.Collections.Generic;
|
---|
4 |
|
---|
5 | namespace AllocsFixes.CustomCommands
|
---|
6 | {
|
---|
7 | public class ShowInventory : ConsoleCmdAbstract
|
---|
8 | {
|
---|
9 | public override string GetDescription ()
|
---|
10 | {
|
---|
11 | return "list inventory of a given player (steam id, entity id or name)";
|
---|
12 | }
|
---|
13 |
|
---|
14 | public override string[] GetCommands ()
|
---|
15 | {
|
---|
16 | return new string[] { "showinventory", "si" };
|
---|
17 | }
|
---|
18 |
|
---|
19 | public override void Execute (List<string> _params, CommandSenderInfo _senderInfo)
|
---|
20 | {
|
---|
21 | try {
|
---|
22 | if (_params.Count < 1) {
|
---|
23 | SdtdConsole.Instance.Output ("Usage: showinventory <steamid|playername|entityid>");
|
---|
24 | return;
|
---|
25 | }
|
---|
26 |
|
---|
27 | string steamid = PersistentContainer.Instance.Players.GetSteamID (_params [0], true);
|
---|
28 | if (steamid == null) {
|
---|
29 | SdtdConsole.Instance.Output ("Playername or entity/steamid id not found or no inventory saved (first saved after a player has been online for 30s).");
|
---|
30 | return;
|
---|
31 | }
|
---|
32 |
|
---|
33 | Player p = PersistentContainer.Instance.Players [steamid];
|
---|
34 | PersistentData.Inventory inv = p.Inventory;
|
---|
35 |
|
---|
36 | SdtdConsole.Instance.Output ("Belt of player " + p.Name + ":");
|
---|
37 | for (int i = 0; i < inv.belt.Count; i++) {
|
---|
38 | if (inv.belt [i] != null)
|
---|
39 | SdtdConsole.Instance.Output (string.Format (" Slot {0}: {1:000} * {2}", i, inv.belt [i].count, inv.belt [i].itemName));
|
---|
40 | }
|
---|
41 | SdtdConsole.Instance.Output (string.Empty);
|
---|
42 | SdtdConsole.Instance.Output ("Bagpack of player " + p.Name + ":");
|
---|
43 | for (int i = 0; i < inv.bag.Count; i++) {
|
---|
44 | if (inv.bag [i] != null)
|
---|
45 | SdtdConsole.Instance.Output (string.Format (" Slot {0}: {1:000} * {2}", i, inv.bag [i].count, inv.bag [i].itemName));
|
---|
46 | }
|
---|
47 | SdtdConsole.Instance.Output (string.Empty);
|
---|
48 | } catch (Exception e) {
|
---|
49 | Log.Out ("Error in ShowInventory.Run: " + e);
|
---|
50 | }
|
---|
51 | }
|
---|
52 | }
|
---|
53 | }
|
---|