- Timestamp:
- Aug 30, 2014, 6:11:18 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/7dtd-server-fixes/src/CustomCommands/ShowInventory.cs
r130 r144 1 using AllocsFixes.PersistentData; 1 2 using System; 2 3 using System.Collections.Generic; … … 6 7 public class ShowInventory : ConsoleCommand 7 8 { 8 private GameManager manager;9 10 9 public ShowInventory (ConsoleSdtd cons) : base(cons) 11 10 { 12 manager = m_Console.gameManager;13 11 } 14 12 15 13 public override string Description () 16 14 { 17 return "list inventory of a given player ( entity id or name)";15 return "list inventory of a given player (steam id, entity id or name)"; 18 16 } 19 17 … … 27 25 try { 28 26 if (_params.Length < 1) { 29 m_Console.SendResult ("Usage: showinventory < playername|entityid>");27 m_Console.SendResult ("Usage: showinventory <steamid|playername|entityid>"); 30 28 return; 31 29 } 32 30 33 int entityId = -1; 34 PlayerDataStuff.PlayerItems items = null; 35 if (int.TryParse (_params [0], out entityId)) { 36 items = PlayerDataStuff.GetPlayerItems (entityId); 37 } 38 39 if (items == null) { 40 string playerName = _params [0].ToLower (); 41 foreach (KeyValuePair<int, EntityPlayer> kvp in manager.World.playerEntities.dict) { 42 if (kvp.Value.EntityName.ToLower ().Equals (playerName)) { 43 entityId = kvp.Key; 44 break; 45 } 46 } 47 } 48 items = PlayerDataStuff.GetPlayerItems (entityId); 49 50 if (items == null) { 51 m_Console.SendResult ("Playername or entity id not found or no inventory saved (first saved after a player has been online for 30s)."); 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)."); 52 34 return; 53 35 } 54 36 37 Log.Out ( "SteamID: " + steamid); 38 39 Player p = PersistentContainer.Instance.Players[steamid]; 40 41 Log.Out ("Player"); 42 43 PersistentData.Inventory inv = p.Inventory; 44 45 Log.Out ("Inv"); 46 55 47 m_Console.SendResult ("Belt of player:"); 56 for each (KeyValuePair<string, int> kvp in items.belt) {57 m_Console.SendResult (string.Format (" {0:000} * {1}", kvp.Value, kvp.Key));48 for (int i = 0; i < inv.belt.Count; i++) { 49 m_Console.SendResult (string.Format (" Slot {0}: {1:000} * {2}", i, inv.belt[i].count, inv.belt[i].itemName)); 58 50 } 59 51 m_Console.SendResult (string.Empty); 60 52 m_Console.SendResult ("Bagpack of player:"); 61 for each (KeyValuePair<string, int> kvp in items.bag) {62 m_Console.SendResult (string.Format (" {0:000} * {1}", kvp.Value, kvp.Key));53 for (int i = 0; i < inv.bag.Count; i++) { 54 m_Console.SendResult (string.Format (" Slot {0}: {1:000} * {2}", i, inv.bag[i].count, inv.bag[i].itemName)); 63 55 } 64 56 m_Console.SendResult (string.Empty);
Note:
See TracChangeset
for help on using the changeset viewer.