Changeset 359 for binary-improvements/AllocsCommands/Commands/Give.cs
- Timestamp:
- Oct 29, 2019, 11:20:45 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/AllocsCommands/Commands/Give.cs
r342 r359 25 25 26 26 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) { 27 try { 28 if (_params.Count != 3 && _params.Count != 4) { 29 SdtdConsole.Instance.Output ("Wrong number of arguments, expected 3 or 4, found " + _params.Count + 30 "."); 27 if (_params.Count != 3 && _params.Count != 4) { 28 SdtdConsole.Instance.Output ("Wrong number of arguments, expected 3 or 4, found " + _params.Count + 29 "."); 30 return; 31 } 32 33 ClientInfo ci = ConsoleHelper.ParseParamIdOrName (_params [0]); 34 35 if (ci == null) { 36 SdtdConsole.Instance.Output ("Playername or entity id not found."); 37 return; 38 } 39 40 ItemValue iv = ItemClass.GetItem (_params [1], true); 41 if (iv.type == ItemValue.None.type) { 42 SdtdConsole.Instance.Output ("Item not found."); 43 return; 44 } 45 46 iv = new ItemValue (iv.type, true); 47 48 int n; 49 if (!int.TryParse (_params [2], out n) || n <= 0) { 50 SdtdConsole.Instance.Output ("Amount is not an integer or not greater than zero."); 51 return; 52 } 53 54 int quality = Constants.cItemMaxQuality; 55 56 if (_params.Count == 4) { 57 if (!int.TryParse (_params [3], out quality) || quality <= 0) { 58 SdtdConsole.Instance.Output ("Quality is not an integer or not greater than zero."); 31 59 return; 32 60 } 61 } 33 62 34 ClientInfo ci = ConsoleHelper.ParseParamIdOrName (_params [0]); 63 if (ItemClass.list [iv.type].HasSubItems) { 64 for (int i = 0; i < iv.Modifications.Length; i++) { 65 ItemValue tmp = iv.Modifications [i]; 66 tmp.Quality = quality; 67 iv.Modifications [i] = tmp; 68 } 69 } else if (ItemClass.list [iv.type].HasQuality) { 70 iv.Quality = quality; 71 } 35 72 36 if (ci == null) { 37 SdtdConsole.Instance.Output ("Playername or entity id not found."); 38 return; 39 } 73 EntityPlayer p = GameManager.Instance.World.Players.dict [ci.entityId]; 40 74 41 ItemValue iv = ItemClass.GetItem (_params [1], true); 42 if (iv.type == ItemValue.None.type) { 43 SdtdConsole.Instance.Output ("Item not found."); 44 return; 45 } 75 ItemStack invField = new ItemStack (iv, n); 46 76 47 iv = new ItemValue (iv.type, true);77 GameManager.Instance.ItemDropServer (invField, p.GetPosition (), Vector3.zero); 48 78 49 int n; 50 if (!int.TryParse (_params [2], out n) || n <= 0) { 51 SdtdConsole.Instance.Output ("Amount is not an integer or not greater than zero."); 52 return; 53 } 54 55 int quality = Constants.cItemMaxQuality; 56 57 if (_params.Count == 4) { 58 if (!int.TryParse (_params [3], out quality) || quality <= 0) { 59 SdtdConsole.Instance.Output ("Quality is not an integer or not greater than zero."); 60 return; 61 } 62 } 63 64 if (ItemClass.list [iv.type].HasSubItems) { 65 for (int i = 0; i < iv.Modifications.Length; i++) { 66 ItemValue tmp = iv.Modifications [i]; 67 tmp.Quality = quality; 68 iv.Modifications [i] = tmp; 69 } 70 } else if (ItemClass.list [iv.type].HasQuality) { 71 iv.Quality = quality; 72 } 73 74 EntityPlayer p = GameManager.Instance.World.Players.dict [ci.entityId]; 75 76 ItemStack invField = new ItemStack (iv, n); 77 78 GameManager.Instance.ItemDropServer (invField, p.GetPosition (), Vector3.zero); 79 80 SdtdConsole.Instance.Output ("Dropped item"); 81 } catch (Exception e) { 82 Log.Out ("Error in Give.Run: " + e); 83 } 79 SdtdConsole.Instance.Output ("Dropped item"); 84 80 } 85 81 }
Note:
See TracChangeset
for help on using the changeset viewer.