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