Changeset 250 for binary-improvements/AllocsCommands/Commands/Give.cs
- Timestamp:
- Aug 12, 2015, 6:10:28 PM (9 years ago)
- File:
-
- 1 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
Note:
See TracChangeset
for help on using the changeset viewer.