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();
        }
예제 #3
0
        private void CraftItemCommandChat(BasePlayer player, string command, string[] args)
        {
            if (!player.IsAdmin())
            {
                SendChatMessage(player, NoPermission);
                return;
            }

            if (args.Length == 0 || args.Length < 2)
            {
                SendChatMessage(player, NoItemRate);
                return;
            }

            float rate;

            if (!float.TryParse(args[args.Length - 1], out rate))
            {
                SendChatMessage(player, ModifyError);
                return;
            }

            var item = string.Empty;

            for (var i = 0; i < args.Length - 1; i++)
            {
                item += args[i] + " ";
            }
            item = item.Trim();

            if (!Items.Contains(item))
            {
                SendChatMessage(player, InvalidItem, item);
                return;
            }


            if (IndividualRates.ContainsKey(item))
            {
                IndividualRates[item] = rate;
            }
            else
            {
                IndividualRates.Add(item, rate);
            }

            SetConfigValue("Options", "IndividualCraftingRates", IndividualRates);
            SendChatMessage(player, ModifyCraftingRateItem, item, rate);
            UpdateCraftingRate();
        }
예제 #4
0
        private void CraftItemCommandConsole(ConsoleSystem.Arg arg)
        {
            if (arg.Player() != null && !arg.Player().IsAdmin())
            {
                arg.ReplyWith(NoPermission);
                return;
            }

            if (!arg.HasArgs(2))
            {
                arg.ReplyWith(NoItemRate);
                return;
            }

            var rate = arg.GetFloat(arg.Args.Length - 1, -1f);

            if (rate == -1f)
            {
                arg.ReplyWith(ModifyError);
                return;
            }

            var item = string.Empty;

            for (var i = 0; i < arg.Args.Length - 1; i++)
            {
                item += arg.Args[i] + " ";
            }
            item = item.Trim();

            if (!Items.Contains(item))
            {
                arg.ReplyWith(string.Format(InvalidItem, item, rate));
                return;
            }

            if (IndividualRates.ContainsKey(item))
            {
                IndividualRates[item] = rate;
            }
            else
            {
                IndividualRates.Add(item, rate);
            }

            SetConfigValue("Options", "IndividualCraftingRates", IndividualRates);
            arg.ReplyWith(string.Format(ModifyCraftingRateItem, item, rate));
            UpdateCraftingRate();
        }