private void CraftItemCommandChat(BasePlayer player, string command, string[] args) { if (!player.IsAdmin) { SendChatMessage(player, NoPermission); return; } if (args.Length < 1) { SendChatMessage(player, NoItemRate); return; } var item = args.Any(arg => arg.All(c => char.IsDigit(c) || c == '.')) ? string.Join(" ", args.Take(args.Length - 1)) : string.Join(" ", args); if (!Items.Contains(item)) { SendChatMessage(player, InvalidItem, item); return; } float rate = args.Any(arg => arg.All(c => char.IsDigit(c) || c == '.')) ? float.Parse(args.First(arg => arg.All(c => char.IsDigit(c) || c == '.'))) : -1f; if (rate == -1f) { if (IndividualRates.ContainsKey(item)) { SendChatMessage(player, string.Format(RemovedItem, item)); IndividualRates.Remove(item); goto SCV_1; } else { SendChatMessage(player, ModifyError); } return; } if (IndividualRates.ContainsKey(item)) { IndividualRates[item] = rate; } else { IndividualRates.Add(item, rate); } SendChatMessage(player, ModifyCraftingRateItem, item, rate); SCV_1: SetConfigValue("Options", "IndividualCraftingRates", IndividualRates); UpdateCraftingRate(); }
private void CraftItemCommandConsole(ConsoleSystem.Arg arg) { if (!arg.IsAdmin) { arg.ReplyWith(NoPermission); return; } if (!arg.HasArgs(1)) { arg.ReplyWith(NoItemRate); return; } float rate = arg.Args.Any(x => x.All(c => char.IsDigit(c) || c == '.')) ? float.Parse(arg.Args.First(x => x.All(c => char.IsDigit(c) || c == '.'))) : -1f; var item = arg.Args.Any(x => x.All(c => char.IsDigit(c) || c == '.')) ? string.Join(" ", arg.Args.Take(arg.Args.Length - 1)) : string.Join(" ", arg.Args); if (!Items.Contains(item)) { arg.ReplyWith(string.Format(InvalidItem, item, rate)); return; } if (rate == -1f) { if (IndividualRates.ContainsKey(item)) { arg.ReplyWith(string.Format(RemovedItem, item)); IndividualRates.Remove(item); goto SCV_1; } else { arg.ReplyWith(ModifyError); } return; } if (IndividualRates.ContainsKey(item)) { IndividualRates[item] = rate; } else { IndividualRates.Add(item, rate); } arg.ReplyWith(string.Format(ModifyCraftingRateItem, item, rate)); SCV_1: SetConfigValue("Options", "IndividualCraftingRates", IndividualRates); UpdateCraftingRate(); }