Changeset 250 for binary-improvements/AllocsCommands/Commands
- Timestamp:
- Aug 12, 2015, 6:10:28 PM (9 years ago)
- Location:
- binary-improvements/AllocsCommands/Commands
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/AllocsCommands/Commands/Give.cs
r238 r250 5 5 namespace AllocsFixes.CustomCommands 6 6 { 7 public class Give : ConsoleCmdAbstract 8 { 9 public override string GetDescription () 10 { 7 public class Give : ConsoleCmdAbstract { 8 public override string GetDescription () { 11 9 return "give an item to a player (entity id or name)"; 12 10 } … … 14 12 public override string GetHelp () { 15 13 return "Give an item to a player by dropping it in front of that player\n" + 16 "Usage:\n" + 17 " give <name / entity id> <item name> <amount>\n" + 18 "Either pass the full name of a player or his entity id (given by e.g. \"lpi\").\n" + 19 "Item name has to be the exact name of an item as listed by \"listitems\".\n" + 20 "Amount is the number of instances of this item to drop (as a single stack)."; 14 "Usage:\n" + 15 " give <name / entity id> <item name> <amount>\n" + 16 " give <name / entity id> <item name> <amount> <quality>\n" + 17 "Either pass the full name of a player or his entity id (given by e.g. \"lpi\").\n" + 18 "Item name has to be the exact name of an item as listed by \"listitems\".\n" + 19 "Amount is the number of instances of this item to drop (as a single stack).\n" + 20 "Quality is the quality of the dropped items for items that have a quality."; 21 21 } 22 22 23 public override string[] GetCommands () 24 { 23 public override string[] GetCommands () { 25 24 return new string[] { "give", string.Empty }; 26 25 } 27 26 28 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) 29 { 27 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) { 30 28 try { 31 if (_params.Count != 3 ) {32 SdtdConsole.Instance.Output ("Wrong number of arguments, expected 3 , found " + _params.Count + ".");29 if (_params.Count != 3 && _params.Count != 4) { 30 SdtdConsole.Instance.Output ("Wrong number of arguments, expected 3 or 4, found " + _params.Count + "."); 33 31 return; 34 32 } … … 41 39 } 42 40 43 ItemValue iv = ItemList.Instance.GetItemValue (_params [1]);41 ItemValue iv = ItemList.Instance.GetItemValue (_params [1]); 44 42 if (iv == null) { 45 43 SdtdConsole.Instance.Output ("Item not found."); … … 51 49 SdtdConsole.Instance.Output ("Amount is not an integer or not greater than zero."); 52 50 return; 51 } 52 53 if (_params.Count == 4) { 54 if (!iv.HasQuality) { 55 SdtdConsole.Instance.Output ("Item " + _params [1] + " does not support quality."); 56 return; 57 } 58 59 int quality = int.MinValue; 60 if (!int.TryParse (_params [3], out quality) || quality <= 0) { 61 SdtdConsole.Instance.Output ("Quality is not an integer or not greater than zero."); 62 return; 63 } 64 iv.Quality = quality; 53 65 } 54 66 -
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 } -
binary-improvements/AllocsCommands/Commands/TeleportPlayer.cs
r238 r250 5 5 namespace AllocsFixes.CustomCommands 6 6 { 7 public class TeleportPlayer : ConsoleCmdAbstract 8 { 9 public override string GetDescription () 10 { 7 public class TeleportPlayer : ConsoleCmdAbstract { 8 public override string GetDescription () { 11 9 return "teleport a player to a given location"; 12 10 } … … 14 12 public override string GetHelp () { 15 13 return "Usage:\n" + 16 " 1. teleportplayer <steam id / player name / entity id> <x> <y> <z>\n" + 17 " 2. teleportplayer <steam id / player name / entity id> <target steam id / player name / entity id>\n" + 18 "1. Teleports the player given by his SteamID, player name or entity id (as given by e.g. \"lpi\")\n" + 19 " to the specified location\n" + 20 "2. As 1, but destination given by another player which has to be online"; 14 " 1. teleportplayer <steam id / player name / entity id> <x> <y> <z>\n" + 15 " 2. teleportplayer <steam id / player name / entity id> <target steam id / player name / entity id>\n" + 16 " 3. teleportplayer <inc x> <inc y> <inc z>\n" + 17 "1. Teleports the player given by his SteamID, player name or entity id (as given by e.g. \"lpi\")\n" + 18 " to the specified location\n" + 19 "2. As 1, but destination given by another player which has to be online\n" + 20 "3. Teleport the local player to the position calculated by his current position and the given offsets"; 21 21 } 22 22 23 public override string[] GetCommands () 24 { 23 public override string[] GetCommands () { 25 24 return new string[] { "teleportplayer", "tele" }; 26 25 } 27 26 28 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) 29 { 27 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) { 30 28 try { 31 if (_params.Count != 4 && _params.Count != 2) {32 SdtdConsole.Instance.Output (" Usage: teleportplayer <entityid|playername|steamid> <x> <y> <z>");33 SdtdConsole.Instance.Output (" or: teleportplayer <entityid|playername|steamid> <target entityid|playername|steamid>");29 if (_params.Count < 2 || _params.Count > 4) { 30 SdtdConsole.Instance.Output ("Wrong number of arguments, expected 2 to 4, found " + _params.Count + "."); 31 return; 34 32 } else { 35 ClientInfo ci1 = ConsoleHelper.ParseParamIdOrName (_params [0]); 36 if (ci1 == null) { 37 SdtdConsole.Instance.Output ("Playername or entity/steamid id not found."); 38 return; 39 } 40 EntityPlayer ep1 = GameManager.Instance.World.Players.dict [ci1.entityId]; 33 ClientInfo ci1 = null; 34 EntityPlayer ep1 = null; 35 36 if (_params.Count == 2 || _params.Count == 4) { 37 ci1 = ConsoleHelper.ParseParamIdOrName (_params [0]); 38 if (ci1 == null) { 39 SdtdConsole.Instance.Output ("Playername or entity/steamid id not found."); 40 return; 41 } 42 ep1 = GameManager.Instance.World.Players.dict [ci1.entityId]; 41 43 42 if (_params.Count == 4) { 44 if (_params.Count == 4) { 45 int x = int.MinValue; 46 int y = int.MinValue; 47 int z = int.MinValue; 48 49 int.TryParse (_params [1], out x); 50 int.TryParse (_params [2], out y); 51 int.TryParse (_params [3], out z); 52 53 if (x == int.MinValue || y == int.MinValue || z == int.MinValue) { 54 SdtdConsole.Instance.Output ("At least one of the given coordinates is not a valid integer"); 55 return; 56 } 57 58 ep1.position.x = x; 59 ep1.position.y = y; 60 ep1.position.z = z; 61 } else if (_params.Count == 2) { 62 ClientInfo ci2 = ConsoleHelper.ParseParamIdOrName (_params [1]); 63 if (ci2 == null) { 64 SdtdConsole.Instance.Output ("Target playername or entity/steamid id not found."); 65 return; 66 } 67 EntityPlayer ep2 = GameManager.Instance.World.Players.dict [ci2.entityId]; 68 69 ep1.position = ep2.GetPosition (); 70 ep1.position.y += 1; 71 ep1.position.z += 1; 72 } 73 } else if (_params.Count == 3) { 74 if (_senderInfo.RemoteClientInfo == null) { 75 SdtdConsole.Instance.Output ("This command can only be executed on the in-game console."); 76 return; 77 } 78 79 ci1 = _senderInfo.RemoteClientInfo; 80 ep1 = GameManager.Instance.World.Players.dict [ci1.entityId]; 81 43 82 int x = int.MinValue; 44 83 int y = int.MinValue; 45 84 int z = int.MinValue; 46 85 47 int.TryParse (_params [ 1], out x);48 int.TryParse (_params [ 2], out y);49 int.TryParse (_params [ 3], out z);86 int.TryParse (_params [0], out x); 87 int.TryParse (_params [1], out y); 88 int.TryParse (_params [2], out z); 50 89 51 90 if (x == int.MinValue || y == int.MinValue || z == int.MinValue) { … … 54 93 } 55 94 56 ep1.position.x = x; 57 ep1.position.y = y; 58 ep1.position.z = z; 59 } else { 60 ClientInfo ci2 = ConsoleHelper.ParseParamIdOrName (_params [1]); 61 if (ci2 == null) { 62 SdtdConsole.Instance.Output ("Target playername or entity/steamid id not found."); 63 return; 64 } 65 EntityPlayer ep2 = GameManager.Instance.World.Players.dict [ci2.entityId]; 66 67 ep1.position = ep2.GetPosition(); 68 ep1.position.y += 1; 69 ep1.position.z += 1; 95 ep1.position.x = ep1.position.x + x; 96 ep1.position.y = ep1.position.y + y; 97 ep1.position.z = ep1.position.z + z; 70 98 } 71 99
Note:
See TracChangeset
for help on using the changeset viewer.