private void CraftCommandConsole(ConsoleSystem.Arg arg)
        {
            if (!arg.HasArgs())
            {
                arg.ReplyWith(string.Format(CurrentCraftingRate, CraftingRate));
                return;
            }

            if (arg.Player() != null && !arg.Player().IsAdmin())
            {
                arg.ReplyWith(NoPermission);
                return;
            }

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

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

            CraftingRate = rate;
            SetConfigValue("Options", "CraftingRate", rate);
            UpdateCraftingRate();
            arg.ReplyWith(string.Format(ModifyCraftingRate, CraftingRate));
        }
        public static void give(ConsoleSystem.Arg arg)
        {
            BasePlayer basePlayer = arg.Player();

            if (!basePlayer)
            {
                return;
            }
            Item num = ItemManager.CreateByPartialName(arg.GetString(0, ""), 1);

            if (num == null)
            {
                arg.ReplyWith("Invalid Item!");
                return;
            }
            int num1 = arg.GetInt(1, 1);

            num.amount = num1;
            num.conditionNormalized = arg.GetFloat(2, 1f);
            num.OnVirginSpawn();
            if (!basePlayer.inventory.GiveItem(num, null))
            {
                num.Remove(0f);
                arg.ReplyWith("Couldn't give item (inventory full?)");
                return;
            }
            basePlayer.Command("note.inv", new object[] { num.info.itemid, num1 });
            Debug.Log(string.Concat(new object[] { "giving ", basePlayer.displayName, " ", num1, " x ", num.info.displayName.english }));
            Chat.Broadcast(string.Concat(new object[] { basePlayer.displayName, " gave themselves ", num1, " x ", num.info.displayName.english }), "SERVER", "#eee", (ulong)0);
        }
        public static void give(ConsoleSystem.Arg arg)
        {
            BasePlayer basePlayer = arg.Player();

            if (!Object.op_Implicit((Object)basePlayer))
            {
                return;
            }
            Item byPartialName = ItemManager.CreateByPartialName(arg.GetString(0, ""), 1);

            if (byPartialName == null)
            {
                arg.ReplyWith("Invalid Item!");
            }
            else
            {
                int num1 = arg.GetInt(1, 1);
                byPartialName.amount = num1;
                float num2 = arg.GetFloat(2, 1f);
                byPartialName.conditionNormalized = num2;
                byPartialName.OnVirginSpawn();
                if (!basePlayer.inventory.GiveItem(byPartialName, (ItemContainer)null))
                {
                    byPartialName.Remove(0.0f);
                    arg.ReplyWith("Couldn't give item (inventory full?)");
                }
                else
                {
                    basePlayer.Command("note.inv", (object)byPartialName.info.itemid, (object)num1);
                    Debug.Log((object)("giving " + basePlayer.displayName + " " + (object)num1 + " x " + byPartialName.info.displayName.english));
                    Chat.Broadcast(basePlayer.displayName + " gave themselves " + (object)num1 + " x " + byPartialName.info.displayName.english, "SERVER", "#eee", 0UL);
                }
            }
        }
        public static void stall(ConsoleSystem.Arg arg)
        {
            float num = Mathf.Clamp(arg.GetFloat(0, 0.0f), 0.0f, 1f);

            arg.ReplyWith("Stalling for " + (object)num + " seconds...");
            Thread.Sleep(Mathf.RoundToInt(num * 1000f));
        }
        public static void stall(ConsoleSystem.Arg arg)
        {
            float single = Mathf.Clamp(arg.GetFloat(0, 0f), 0f, 1f);

            arg.ReplyWith(string.Concat("Stalling for ", single, " seconds..."));
            Thread.Sleep(Mathf.RoundToInt(single * 1000f));
        }
Beispiel #6
0
        private void ExcavatorTickRate(ConsoleSystem.Arg arg)
        {
            if (arg.Player() != null && !arg.Player().IsAdmin)
            {
                arg.ReplyWith(NotAllowed);
                return;
            }

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

            var modifier = arg.GetFloat(0, -1);

            if (modifier < 1)
            {
                arg.ReplyWith(InvalidSpeed);
                return;
            }

            ExcavatorResourceTickRate = modifier;
            SetConfigValue("Options", "ExcavatorResourceTickRate", ExcavatorResourceTickRate);
            arg.ReplyWith(string.Format(ModifySpeed, modifier));
            var excavators = UnityEngine.Object.FindObjectsOfType <MiningQuarry>();

            foreach (var excavator in excavators.Where(excavator => excavator.IsOn()))
            {
                excavator.CancelInvoke("ProcessResources");
                excavator.InvokeRepeating("ProcessResources", ExcavatorResourceTickRate, ExcavatorResourceTickRate);
            }
        }
Beispiel #7
0
    public static void popup(ref ConsoleSystem.Arg arg)
    {
        float  @float  = arg.GetFloat(0, 2f);
        string strIcon = arg.GetString(1, "!");
        string strText = arg.GetString(2, "This is the text");

        PopupUI.singleton.CreateNotice(@float, strIcon, strText);
    }
Beispiel #8
0
    public static void popup(ref ConsoleSystem.Arg arg)
    {
        float  num  = arg.GetFloat(0, 2f);
        string str  = arg.GetString(1, "!");
        string str1 = arg.GetString(2, "This is the text");

        PopupUI.singleton.CreateNotice(num, str, str1);
    }
Beispiel #9
0
        public static void NpcSenseLoadBalancerUpdateInterval(ConsoleSystem.Arg args)
        {
            LoadBalancedQueue npcSensesLoadBalancer = NPCSensesLoadBalancer.NpcSensesLoadBalancer as LoadBalancedQueue;

            if (npcSensesLoadBalancer != null)
            {
                npcSensesLoadBalancer.defaultUpdateInterval = args.GetFloat(0, npcSensesLoadBalancer.defaultUpdateInterval);
            }
        }
Beispiel #10
0
        public static void defaultLoadBalancerUpdateInterval(ConsoleSystem.Arg args)
        {
            LoadBalancedQueue num = LoadBalancer.defaultBalancer as LoadBalancedQueue;

            if (num != null)
            {
                num.defaultUpdateInterval = args.GetFloat(0, num.defaultUpdateInterval);
            }
        }
Beispiel #11
0
 void ChangeCharcoal_ConsoleCommand(ConsoleSystem.Arg args)
 {
     if (!args.IsAdmin)
     {
         return;
     }
     if (args.HasArgs(1))
     {
         Settings.CharcoalRate = args.GetFloat(0, 1);
     }
     args.ReplyWith($"Charcoal Rate: {Settings.CharcoalRate.ToString("0.0")} (Default: 0.7)");
     _settingsFile.Save();
 }
Beispiel #12
0
        public static void rain(ConsoleSystem.Arg args)
        {
            if (Object.op_Equality((Object)SingletonComponent <Climate> .Instance, (Object)null))
            {
                return;
            }
            float  rain = ((Climate)SingletonComponent <Climate> .Instance).Overrides.Rain;
            float  num  = args.GetFloat(0, -1f);
            string str1 = (double)rain < 0.0 ? "automatic" : Mathf.RoundToInt(100f * rain).ToString() + "%";
            string str2 = (double)num < 0.0 ? "automatic" : Mathf.RoundToInt(100f * num).ToString() + "%";

            args.ReplyWith("Rain: " + str2 + " (was " + str1 + ")");
            ((Climate)SingletonComponent <Climate> .Instance).Overrides.Rain = num;
        }
Beispiel #13
0
        public static void wind(ConsoleSystem.Arg args)
        {
            if (SingletonComponent <Climate> .Instance == null)
            {
                return;
            }
            float  wind = SingletonComponent <Climate> .Instance.Overrides.Wind;
            float  num  = args.GetFloat(0, -1f);
            string str  = (wind < 0f ? "automatic" : string.Concat(Mathf.RoundToInt(100f * wind), "%"));
            string str1 = (num < 0f ? "automatic" : string.Concat(Mathf.RoundToInt(100f * num), "%"));

            args.ReplyWith(string.Concat(new string[] { "Wind: ", str1, " (was ", str, ")" }));
            SingletonComponent <Climate> .Instance.Overrides.Wind = num;
        }
        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();
        }
Beispiel #15
0
        private void ModifyConsoleCommand(ConsoleSystem.Arg arg)
        {
            if (!HasPermission(arg, "corpseduration.modify") || !arg.HasArgs())
            {
                arg.ReplyWith(string.Format(GetMessage("Setting", arg?.Connection?.userid.ToString()), Math.Round(Duration / 60, 1)));
                return;
            }

            var duration = arg.GetFloat(0, -1);

            if (duration < 0)
            {
                arg.ReplyWith(GetMessage("SyntaxError", arg?.Connection?.userid.ToString()));
                return;
            }

            Duration = duration * 60;
            SetConfigValue("Options", "Duration", Duration);

            arg.ReplyWith(string.Format(GetMessage("Modify", arg?.Connection?.userid.ToString()), Math.Round(Duration / 60, 1)));
        }
Beispiel #16
0
        private void DispenserRate(ConsoleSystem.Arg arg)
        {
            if (arg.Player() != null && !arg.Player().IsAdmin)
            {
                arg.ReplyWith(NotAllowed);
                return;
            }

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

            if (!validDispensers.ContainsKey(arg.GetString(0).ToLower()))
            {
                arg.ReplyWith(string.Format(InvalidDispenser, arg.GetString(0)));
                return;
            }

            var dispenser = validDispensers[arg.GetString(0).ToLower()].ToString("G");
            var modifier  = arg.GetFloat(1, -1);

            if (modifier < 0)
            {
                arg.ReplyWith(InvalidModifier);
                return;
            }

            if (GatherDispenserModifiers.ContainsKey(dispenser))
            {
                GatherDispenserModifiers[dispenser] = modifier;
            }
            else
            {
                GatherDispenserModifiers.Add(dispenser, modifier);
            }
            SetConfigValue("Options", "GatherDispenserModifiers", GatherDispenserModifiers);
            arg.ReplyWith(string.Format(ModifyDispenser, dispenser, modifier));
        }
Beispiel #17
0
        public static void defaultLoadBalancerUpdateInterval(ConsoleSystem.Arg args)
        {
            LoadBalancedQueue defaultBalancer = LoadBalancer.defaultBalancer as LoadBalancedQueue;

            defaultBalancer?.set_defaultUpdateInterval(args.GetFloat(0, defaultBalancer.get_defaultUpdateInterval()));
        }
Beispiel #18
0
        public static void aiLoadBalancerUpdateInterval(ConsoleSystem.Arg args)
        {
            LoadBalancedQueue aiLoadBalancer = AILoadBalancer.aiLoadBalancer as LoadBalancedQueue;

            aiLoadBalancer?.set_defaultUpdateInterval(args.GetFloat(0, aiLoadBalancer.get_defaultUpdateInterval()));
        }
Beispiel #19
0
        private void GatherRate(ConsoleSystem.Arg arg)
        {
            if (arg.Player() != null && !arg.Player().IsAdmin)
            {
                arg.ReplyWith(NotAllowed);
                return;
            }

            var subcommand = arg.GetString(0).ToLower();

            if (!arg.HasArgs(3) || !subcommands.Contains(subcommand))
            {
                arg.ReplyWith(InvalidArgumentsGather);
                return;
            }

            if (!validResources[arg.GetString(1).ToLower()] && arg.GetString(1) != "*")
            {
                arg.ReplyWith(string.Format(InvalidResource, arg.GetString(1)));
                return;
            }

            var resource = validResources[arg.GetString(1).ToLower()]?.displayName.english ?? "*";
            var modifier = arg.GetFloat(2, -1);
            var remove   = false;

            if (modifier < 0)
            {
                if (arg.GetString(2).ToLower() == "remove")
                {
                    remove = true;
                }
                else
                {
                    arg.ReplyWith(InvalidModifier);
                    return;
                }
            }

            switch (subcommand)
            {
            case "dispenser":
                if (remove)
                {
                    if (GatherResourceModifiers.ContainsKey(resource))
                    {
                        GatherResourceModifiers.Remove(resource);
                    }
                    arg.ReplyWith(string.Format(ModifyResourceRemove, resource, Dispensers));
                }
                else
                {
                    if (GatherResourceModifiers.ContainsKey(resource))
                    {
                        GatherResourceModifiers[resource] = modifier;
                    }
                    else
                    {
                        GatherResourceModifiers.Add(resource, modifier);
                    }
                    arg.ReplyWith(string.Format(ModifyResource, resource, modifier, Dispensers));
                }
                SetConfigValue("Options", "GatherResourceModifiers", GatherResourceModifiers);
                break;

            case "pickup":
                if (remove)
                {
                    if (PickupResourceModifiers.ContainsKey(resource))
                    {
                        PickupResourceModifiers.Remove(resource);
                    }
                    arg.ReplyWith(string.Format(ModifyResourceRemove, resource, Pickups));
                }
                else
                {
                    if (PickupResourceModifiers.ContainsKey(resource))
                    {
                        PickupResourceModifiers[resource] = modifier;
                    }
                    else
                    {
                        PickupResourceModifiers.Add(resource, modifier);
                    }
                    arg.ReplyWith(string.Format(ModifyResource, resource, modifier, Pickups));
                }
                SetConfigValue("Options", "PickupResourceModifiers", PickupResourceModifiers);
                break;

            case "quarry":
                if (remove)
                {
                    if (QuarryResourceModifiers.ContainsKey(resource))
                    {
                        QuarryResourceModifiers.Remove(resource);
                    }
                    arg.ReplyWith(string.Format(ModifyResourceRemove, resource, Quarries));
                }
                else
                {
                    if (QuarryResourceModifiers.ContainsKey(resource))
                    {
                        QuarryResourceModifiers[resource] = modifier;
                    }
                    else
                    {
                        QuarryResourceModifiers.Add(resource, modifier);
                    }
                    arg.ReplyWith(string.Format(ModifyResource, resource, modifier, Quarries));
                }
                SetConfigValue("Options", "QuarryResourceModifiers", QuarryResourceModifiers);
                break;

            case "excavator":
                if (remove)
                {
                    if (ExcavatorResourceModifiers.ContainsKey(resource))
                    {
                        ExcavatorResourceModifiers.Remove(resource);
                    }
                    arg.ReplyWith(string.Format(ModifyResourceRemove, resource, Excavators));
                }
                else
                {
                    if (ExcavatorResourceModifiers.ContainsKey(resource))
                    {
                        ExcavatorResourceModifiers[resource] = modifier;
                    }
                    else
                    {
                        ExcavatorResourceModifiers.Add(resource, modifier);
                    }
                    arg.ReplyWith(string.Format(ModifyResource, resource, modifier, Excavators));
                }
                SetConfigValue("Options", "ExcavatorResourceModifiers", ExcavatorResourceModifiers);
                break;

            case "survey":
                if (remove)
                {
                    if (SurveyResourceModifiers.ContainsKey(resource))
                    {
                        SurveyResourceModifiers.Remove(resource);
                    }
                    arg.ReplyWith(string.Format(ModifyResourceRemove, resource, Charges));
                }
                else
                {
                    if (SurveyResourceModifiers.ContainsKey(resource))
                    {
                        SurveyResourceModifiers[resource] = modifier;
                    }
                    else
                    {
                        SurveyResourceModifiers.Add(resource, modifier);
                    }
                    arg.ReplyWith(string.Format(ModifyResource, resource, modifier, Charges));
                }
                SetConfigValue("Options", "SurveyResourceModifiers", SurveyResourceModifiers);
                break;
            }
        }
Beispiel #20
0
        private void ccmdEco(ConsoleSystem.Arg arg)
        {
            if (!arg.HasArgs())
            {
                arg.ReplyWith("Economy Commands: 'eco.c deposit', 'eco.c save','eco.c balance', 'eco.c withdraw', 'eco.c setmoney', 'eco.c wipe'");
                return;
            }
            var player = arg.Player();

            if (player != null && !HasAccess(player))
            {
                arg.ReplyWith("No permission!");
                return;
            }
            var cmdArg = arg.GetString(0).ToLower();

            switch (cmdArg)
            {
            case "save":
                changed = true;
                SaveEconomics();
                arg.ReplyWith("Economics data saved!");
                break;

            case "wipe":
                economicsData = new Dictionary <ulong, double>();
                changed       = true;
                SaveEconomics();
                arg.ReplyWith("Economics data wiped!");
                break;

            case "deposit":
            case "balance":
            case "withdraw":
            case "setmoney":
                var target = FindPlayer(arg.GetString(1));
                if (target == null)
                {
                    arg.ReplyWith($"No user with steam/name: '{arg.GetString(1)}'!");
                    return;
                }
                if (cmdArg.Equals("balance"))
                {
                    arg.ReplyWith($"Balance({target.displayName}) = {GetPlayerMoney(target.userID)}");
                    return;
                }
                double money = arg.GetFloat(2, -1f);
                if (money < 0)
                {
                    money = arg.GetUInt64(2, 0);
                }
                if (money >= 0)
                {
                    if (cmdArg.Equals("setmoney"))
                    {
                        Set(target.userID, money);
                        arg.ReplyWith($"(SetMoney) New '{target.displayName}' balance: {GetPlayerMoney(target.userID)}");
                        PrintMessage(target, "My_Balance", GetPlayerMoney(target.userID));
                    }
                    else if (cmdArg.Equals("deposit"))
                    {
                        Deposit(target.userID, money);
                        arg.ReplyWith($"(Deposit) New '{target.displayName}' balance: {GetPlayerMoney(target.userID)}");
                        PrintMessage(target, "Received", money);
                    }
                    else if (Withdraw(target.userID, money))
                    {
                        arg.ReplyWith($"(Withdraw) New '{target.displayName}' balance: {GetPlayerMoney(target.userID)}");
                        PrintMessage(target, "Lost", money);
                    }
                    else
                    {
                        arg.ReplyWith("This user haven't enough money!");
                    }
                }
                else
                {
                    arg.ReplyWith($"Syntax Error! (eco.c {cmdArg} <steam/name> <money>)");
                }
                break;

            default:
                arg.ReplyWith("Economy Commands: 'eco.c deposit', 'eco.c save','eco.c balance', 'eco.c withdraw', 'eco.c setmoney'");
                break;
            }
        }
Beispiel #21
0
        public static void AnimalSenseLoadBalancerUpdateInterval(ConsoleSystem.Arg args)
        {
            LoadBalancedQueue sensesLoadBalancer = AnimalSensesLoadBalancer.animalSensesLoadBalancer as LoadBalancedQueue;

            sensesLoadBalancer?.set_defaultUpdateInterval(args.GetFloat(0, sensesLoadBalancer.get_defaultUpdateInterval()));
        }