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