source: binary-improvements/7dtd-server-fixes/src/CustomCommands/ShowInventory.cs@ 208

Last change on this file since 208 was 174, checked in by alloc, 10 years ago

fixes

File size: 1.7 KB
RevLine 
[144]1using AllocsFixes.PersistentData;
[93]2using System;
3using System.Collections.Generic;
4
[130]5namespace AllocsFixes.CustomCommands
[93]6{
[130]7 public class ShowInventory : ConsoleCommand
[93]8 {
[130]9 public ShowInventory (ConsoleSdtd cons) : base(cons)
10 {
11 }
[93]12
[130]13 public override string Description ()
14 {
[144]15 return "list inventory of a given player (steam id, entity id or name)";
[130]16 }
[93]17
[130]18 public override string[] Names ()
19 {
20 return new string[] { "showinventory", "si" };
21 }
[93]22
[130]23 public override void Run (string[] _params)
24 {
25 try {
26 if (_params.Length < 1) {
[144]27 m_Console.SendResult ("Usage: showinventory <steamid|playername|entityid>");
[130]28 return;
29 }
[93]30
[145]31 string steamid = PersistentContainer.Instance.Players.GetSteamID (_params [0], true);
[144]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;
[130]35 }
36
[145]37 Player p = PersistentContainer.Instance.Players [steamid];
[144]38 PersistentData.Inventory inv = p.Inventory;
39
[174]40 m_Console.SendResult ("Belt of player " + p.Name + ":");
[144]41 for (int i = 0; i < inv.belt.Count; i++) {
[145]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));
[130]44 }
45 m_Console.SendResult (string.Empty);
[174]46 m_Console.SendResult ("Bagpack of player " + p.Name + ":");
[144]47 for (int i = 0; i < inv.bag.Count; i++) {
[145]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));
[130]50 }
51 m_Console.SendResult (string.Empty);
52 } catch (Exception e) {
53 Log.Out ("Error in ShowInventory.Run: " + e);
[103]54 }
[93]55 }
56 }
57}
Note: See TracBrowser for help on using the repository browser.