source: binary-improvements/AllocsCommands/Commands/ShowInventory.cs@ 236

Last change on this file since 236 was 233, checked in by alloc, 10 years ago

Fixes for 11.4

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