- Timestamp:
- Aug 12, 2015, 6:10:28 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/AllocsCommands/Commands/ShowInventory.cs
r238 r250 5 5 namespace AllocsFixes.CustomCommands 6 6 { 7 public class ShowInventory : ConsoleCmdAbstract 8 { 9 public override string GetDescription () 10 { 7 public class ShowInventory : ConsoleCmdAbstract { 8 public override string GetDescription () { 11 9 return "list inventory of a given player"; 12 10 } … … 14 12 public override string GetHelp () { 15 13 return "Usage:\n" + 16 17 18 19 20 14 " showinventory <steam id / player name / entity id>\n" + 15 "Show the inventory of the player given by his SteamID, player name or\n" + 16 "entity id (as given by e.g. \"lpi\")." + 17 "Note: This only shows the player's inventory after it was first sent to\n" + 18 "the server which happens at least every 30 seconds."; 21 19 } 22 20 23 public override string[] GetCommands () 24 { 21 public override string[] GetCommands () { 25 22 return new string[] { "showinventory", "si" }; 26 23 } 27 24 28 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) 29 { 25 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) { 30 26 try { 31 27 if (_params.Count < 1) { … … 44 40 45 41 SdtdConsole.Instance.Output ("Belt of player " + p.Name + ":"); 46 for (int i = 0; i < inv.belt.Count; i++) { 47 if (inv.belt [i] != null) 48 SdtdConsole.Instance.Output (string.Format (" Slot {0}: {1:000} * {2}", i, inv.belt [i].count, inv.belt [i].itemName)); 49 } 42 PrintInv (inv.belt); 50 43 SdtdConsole.Instance.Output (string.Empty); 44 51 45 SdtdConsole.Instance.Output ("Bagpack of player " + p.Name + ":"); 52 for (int i = 0; i < inv.bag.Count; i++) { 53 if (inv.bag [i] != null) 54 SdtdConsole.Instance.Output (string.Format (" Slot {0}: {1:000} * {2}", i, inv.bag [i].count, inv.bag [i].itemName)); 55 } 46 PrintInv (inv.bag); 56 47 SdtdConsole.Instance.Output (string.Empty); 48 49 SdtdConsole.Instance.Output ("Equipment of player " + p.Name + ":"); 50 PrintEquipment (inv.equipment); 51 57 52 } catch (Exception e) { 58 53 Log.Out ("Error in ShowInventory.Run: " + e); 59 54 } 60 55 } 56 57 private void PrintInv (List<InvItem> _inv) { 58 for (int i = 0; i < _inv.Count; i++) { 59 if (_inv [i] != null) { 60 if (_inv [i].quality < 0) { 61 SdtdConsole.Instance.Output (string.Format (" Slot {0}: {1:000} * {2}", i, _inv [i].count, _inv [i].itemName)); 62 } else { 63 SdtdConsole.Instance.Output (string.Format (" Slot {0}: {1:000} * {2} - quality: {3}", i, _inv [i].count, _inv [i].itemName, _inv [i].quality)); 64 } 65 DoParts (_inv [i].parts, 1); 66 } 67 } 68 } 69 70 private void PrintEquipment (InvItem[] _equipment) { 71 AddEquipment ("head", _equipment, XMLData.Item.EnumEquipmentSlot.Head, NGuiInvGridEquipment.EnumClothingLayer.Middle); 72 AddEquipment ("eyes", _equipment, XMLData.Item.EnumEquipmentSlot.Eyes, NGuiInvGridEquipment.EnumClothingLayer.Middle); 73 AddEquipment ("face", _equipment, XMLData.Item.EnumEquipmentSlot.Face, NGuiInvGridEquipment.EnumClothingLayer.Middle); 74 75 AddEquipment ("armor", _equipment, XMLData.Item.EnumEquipmentSlot.Chest, NGuiInvGridEquipment.EnumClothingLayer.Outer); 76 AddEquipment ("jacket", _equipment, XMLData.Item.EnumEquipmentSlot.Chest, NGuiInvGridEquipment.EnumClothingLayer.Middle); 77 AddEquipment ("shirt", _equipment, XMLData.Item.EnumEquipmentSlot.Chest, NGuiInvGridEquipment.EnumClothingLayer.Inner); 78 79 AddEquipment ("legarmor", _equipment, XMLData.Item.EnumEquipmentSlot.Legs, NGuiInvGridEquipment.EnumClothingLayer.Outer); 80 AddEquipment ("pants", _equipment, XMLData.Item.EnumEquipmentSlot.Legs, NGuiInvGridEquipment.EnumClothingLayer.Inner); 81 AddEquipment ("boots", _equipment, XMLData.Item.EnumEquipmentSlot.Feet, NGuiInvGridEquipment.EnumClothingLayer.Inner); 82 83 AddEquipment ("gloves", _equipment, XMLData.Item.EnumEquipmentSlot.Hands, NGuiInvGridEquipment.EnumClothingLayer.Inner); 84 AddEquipment ("backpack", _equipment, XMLData.Item.EnumEquipmentSlot.Back, NGuiInvGridEquipment.EnumClothingLayer.Outer); 85 } 86 87 private void AddEquipment (string _slotname, InvItem[] _items, XMLData.Item.EnumEquipmentSlot _slot, NGuiInvGridEquipment.EnumClothingLayer _layer) { 88 int index = (int)_slot + (int)_layer * (int)XMLData.Item.EnumEquipmentSlot.Count; 89 if (_items != null && _items [index] != null) { 90 if (_items [index].quality < 0) { 91 SdtdConsole.Instance.Output (string.Format (" Slot {0:8}: {1:000}", _slotname, _items [index].itemName)); 92 } else { 93 SdtdConsole.Instance.Output (string.Format (" Slot {0:8}: {1:000} - quality: {2}", _slotname, _items [index].itemName, _items [index].quality)); 94 } 95 DoParts (_items [index].parts, 1); 96 } 97 } 98 99 private void DoParts (InvItem[] _parts, int _indent) { 100 if (_parts != null && _parts.Length > 0) { 101 string indenter = new string (' ', _indent * 4); 102 for (int i = 0; i < _parts.Length; i++) { 103 if (_parts [i] != null) { 104 if (_parts [i].quality < 0) { 105 SdtdConsole.Instance.Output (string.Format ("{0} - {1}", indenter, _parts [i].itemName)); 106 } else { 107 SdtdConsole.Instance.Output (string.Format ("{0} - {1} - quality: {2}", indenter, _parts [i].itemName, _parts [i].quality)); 108 } 109 DoParts (_parts [i].parts, _indent + 1); 110 } 111 } 112 } 113 } 114 61 115 } 62 116 }
Note:
See TracChangeset
for help on using the changeset viewer.