Exemplo n.º 1
0
        private void BGradeUpCommand(ConsoleSystem.Arg arg)
        {
            var player = arg?.Player();

            if (player == null)
            {
                return;
            }

            if (!player.HasAnyPermission(_registeredPermissions))
            {
                player.ChatMessage("Permission".Lang(player.UserIDString));
                return;
            }

            BGradePlayer bgradePlayer;

            if (!BGradePlayer.Players.TryGetValue(player, out bgradePlayer))
            {
                bgradePlayer = player.gameObject.AddComponent <BGradePlayer>();
            }
            var grade = bgradePlayer.GetGrade() + 1;
            var count = 0;

            if (!player.HasPluginPerm("all"))
            {
                while (!player.HasPluginPerm(grade.ToString()))
                {
                    var newGrade = grade++;
                    if (newGrade > 4)
                    {
                        grade = 1;
                    }

                    if (count > bgradePlayer.GetGrade() + 4)
                    {
                        player.ChatMessage("Permission".Lang(player.UserIDString));
                        return;
                    }
                }
            }
            else if (grade > 4)
            {
                grade = 1;
            }

            var chatMsgs = new List <string>();

            bgradePlayer.SetGrade(grade);
            var time = bgradePlayer.GetTime();

            chatMsgs.Add("Notice.SetGrade".Lang(player.UserIDString, grade, $"Words.Grade.{grade}".Lang(player.UserIDString)));
            if (AllowTimer && time > 0)
            {
                chatMsgs.Add("Notice.Time".Lang(player.UserIDString, time));
            }

            player.ChatMessage(string.Join("\n", chatMsgs.ToArray()));
        }
Exemplo n.º 2
0
        private void OnPlayerChat(ConsoleSystem.Arg arg)
        {
            var oplayer = arg?.Player();

            if (oplayer != null && TrackedPlayers.ContainsKey(oplayer.userID))
            {
                TrackedPlayers[oplayer.userID].ResetAFKTime();
            }
        }
Exemplo n.º 3
0
        void cmdHome(ConsoleSystem.Arg arg)
        {
            var player = arg?.Player();

            if (player == null || arg.Args.Length > 0)
            {
                return;
            }
            cmdChatHome(player, "", new[] { arg.Args[0] });
        }
Exemplo n.º 4
0
        private void consoleCleanInv(ConsoleSystem.Arg arg)
        {
            var player = arg?.Player() ?? null;

            if (player != null)
            {
                PrintWarning("Player not found!");
                return;
            }
        }
Exemplo n.º 5
0
        void cmdNotifyClose(ConsoleSystem.Arg arg)
        {
            var player = arg?.Player();

            if (player == null)
            {
                return;
            }
            core.DestroyUI(player, "ItemBlocker", "blockedItem");
        }
        void ConsoleCmdSpawnCargo(ConsoleSystem.Arg arg)
        {
            var player = arg?.Player();

            if (arg?.Connection != null && player && !permission.UserHasPermission(player.UserIDString, permSpawnCargo))
            {
                player.ChatMessage(Lang("Error: NoPermission", player.UserIDString));
                return;
            }

            SpawnCargo();
        }
Exemplo n.º 7
0
        void ConsoleCommand_vehicleshop_give(ConsoleSystem.Arg arg)
        {
            BasePlayer p = arg?.Player() ?? null;

            if (p != null && !p.IsAdmin)
            {
                return;
            }

            if (!arg.HasArgs(2))
            {
                SendReply(arg, _(p, "ConsoleSyntax", string.Join("|", VehicleInfo.ShortNameList())));
                return;
            }

            BasePlayer player = BasePlayer.Find(arg.GetString(0));

            if (player == null)
            {
                SendReply(arg, _(p, "PlayerNotFound", arg.GetString(0)));
                return;
            }

            VehicleInfo vehicle = VehicleInfo.FindByShortname(arg.GetString(1));

            if (vehicle == null)
            {
                SendReply(arg, _(p, "VehicleNotFound", arg.GetString(1)));
                SendReply(arg, _(p, "ConsoleSyntax", string.Join("|", VehicleInfo.ShortNameList())));
                return;
            }

            string shortname = _config.vehicleShortPrefabName;

            if (arg.HasArgs(3) && arg.GetString(2) != "default")
            {
                ItemDefinition info = ItemManager.FindItemDefinition(arg.GetString(2));
                if (info == null)
                {
                    SendReply(arg, _(p, "ShortnameNotFound", arg.GetString(2)));
                    return;
                }

                shortname = info.shortname;
            }

            SendReply(arg, _(p, "SuccessfullyGive", vehicle.Give(player, shortname, arg.GetString(3, "console")), player.displayName));
        }
Exemplo n.º 8
0
        private object OnServerCommand(ConsoleSystem.Arg arg)
        {
            var player = arg?.Player();

            if (player == null || arg.cmd == null)
            {
                return(null);
            }
            if (arg.cmd.FullName.ToLower().StartsWith("kit.gui") && _cFile.Kits.ContainsKey(arg.GetString(0).ToLower()))
            {
                var kitCooldown = _cFile.Kits[arg.GetString(0).ToLower()];
                if (GetNextKitTime(kitCooldown) != TimeSpan.Zero)
                {
                    player.SendConsoleCommand("kit.close");
                    PrintToChat(player, Lang("CantUse", player.UserIDString, GetFormattedTime(GetNextKitTime(kitCooldown).TotalSeconds)));
                    return(true);
                }
            }
            return(null);
        }
Exemplo n.º 9
0
        private void ConsoleCmdCombatLog(ConsoleSystem.Arg conArgs)
        {
            if (conArgs?.Connection != null && !permission.UserHasPermission(conArgs?.Player()?.UserIDString, permissionUse))
            {
                return;
            }

            var args = conArgs.Args;

            ulong steamID;

            if (!ulong.TryParse(args[0], out steamID))
            {
                SendReply(conArgs, $"{steamID} isn't a valid SteamID64.");
                return;
            }

            int rows = args.Length > 1 ? int.Parse(args[1]) : 20;

            string combatLog = GetCombatLog(steamID, rows);

            SendReply(conArgs, "\n" + combatLog);
        }
Exemplo n.º 10
0
 void CmdCreateBot(ConsoleSystem.Arg arg)
 {
     AimPractice.CreateBot(arg.Player().transform.position);
     PrintToChat("Where them bots at?");
 }
Exemplo n.º 11
0
 private void Command(ConsoleSystem.Arg arg)
 {
     Command(arg.Player(), arg.Args);
 }
Exemplo n.º 12
0
 void cmdConsoleBpLoad(ConsoleSystem.Arg arg)
 {
     BpLoad(arg.Player(), arg.Args ?? new string[0], arg);
 }
Exemplo n.º 13
0
        void ccmdAdminPanel(ConsoleSystem.Arg arg)
        {
            var player = arg.Player();

            if (player == null)
            {
                return;
            }
            var args = arg?.Args ?? null;

            if (IsAllowed(player.UserIDString, permAP))
            {
                switch (args[0])
                {
                case "action":
                    if (args[1] == "vanish")
                    {
                        if (Vanish)
                        {
                            Vanish?.Call("VanishChatCmd", player); AdminGui(player);
                        }
                        ;
                    }
                    else if (args[1] == "admintp")
                    {
                        rust.RunServerCommand("teleport.topos " + player.UserIDString + " " + adminZoneCords);
                    }
                    else if (args[1] == "radar")
                    {
                        if (AdminRadar)
                        {
                            AdminRadar?.Call("ToggleRadar", player); AdminGui(player);
                        }
                    }
                    else if (args[1] == "god")
                    {
                        if (Godmode)
                        {
                            if (Godmode.Call <bool>("IsGod", player.UserIDString))
                            {
                                Godmode.Call("DisableGodmode", player);
                            }
                            else
                            {
                                Godmode.Call("EnableGodmode", player);
                            } AdminGui(player);
                        }
                        ;
                    }
                    break;

                case "toggle":
                    if (IsAllowed(player.UserIDString, permAP))
                    {
                        if (args[1] == "True" && (ToggleMode == true))
                        {
                            AdminGui(player);
                        }
                        else if (args[1] == "False" && (ToggleMode == true))
                        {
                            CuiHelper.DestroyUi(player, "GUIBackground");
                        }
                    }
                    break;

                default:
                    SendReply(player, $"[<color=#6275a4>{Name}</color>]: Invalid Syntax");
                    return;
                }
            }
            else
            {
                Reply(player, null);
            }
        }
Exemplo n.º 14
0
 void DeleteAllFrags(ConsoleSystem.Arg arg)
 {
     if (arg.Player() != null && !arg.Player().IsAdmin())
     {
         SendReply(arg, lang.GetMessage("BP_NOPERMS", this));
         return;
     }
     else
     {
         foreach (var active in BasePlayer.activePlayerList)
         {
             var frags = active.inventory.GetAmount(1351589500);
             if (frags >= 1)
             {
                 active.inventory.Take(null, 1351589500, frags);
                 FragAmount++;
                 PlayerTotalFrags++;
             }
             else
             {
             }
         }
         foreach (var sleeper in BasePlayer.sleepingPlayerList)
         {
             var frags = sleeper.inventory.GetAmount(1351589500);
             if (frags >= 1)
             {
                 sleeper.inventory.Take(null, 1351589500, frags);
                 FragAmount++;
                 PlayerTotalFrags++;
             }
             else
             {
             }
         }
         var containers = UnityEngine.Object.FindObjectsOfType <LootContainer>();
         foreach (var entity in containers)
         {
             if (entity is LootContainer)
             {
                 var container = entity as LootContainer;
                 var inv       = container.inventory.itemList.ToArray();
                 foreach (var item in inv)
                 {
                     if (item.info.shortname == "blueprint_fragment")
                     {
                         item.RemoveFromContainer();
                         item.Remove(1f);
                         EFragAmount++;
                     }
                 }
             }
         }
         if (FragAmount == 0 && EFragAmount == 0)
         {
             Puts(lang.GetMessage("BP_NOFRAGSFOUND", this));
         }
         else
         {
             Puts(string.Format(lang.GetMessage("BP_REMOVEDFRAGS", this), FragAmount, PlayerTotalFrags, EFragAmount, "?"));
             FragAmount       = 0;
             PlayerTotalFrags = 0;
             EFragAmount      = 0;
             EntityTotalFrags = 0;
         }
     }
 }
Exemplo n.º 15
0
 void cmdConsoleBpRemoveAll(ConsoleSystem.Arg arg)
 {
     BpRemoveAll(arg.Player(), arg.Args ?? new string[0], arg);
 }
Exemplo n.º 16
0
        void CcmdAddSkin(ConsoleSystem.Arg arg)
        {
            BasePlayer player = arg.Player();

            if (player is BasePlayer && !player.IsAdmin && !permission.UserHasPermission(player.UserIDString, "skins.admin"))
            {
                SendReply(player, lang.GetMessage("NotAllowed", this, player.UserIDString));
            }

            string userIDString = (player is BasePlayer) ? player.UserIDString : null;

            string[] args = arg.Args;
            if (args.Length == 2)
            {
                string shortname = args.ElementAtOrDefault(0);
                ulong  skinId    = 0;
                ulong.TryParse(args.ElementAtOrDefault(1), out skinId);
                ItemDefinition def = ItemManager.FindItemDefinition(shortname);

                if (skinId == 0)
                {
                    SendReply(arg, lang.GetMessage("ConsoleIncorrectSkinIdFormat", this, userIDString));
                    return;
                }
                else if (def != null)
                {
                    if (!SkinsList.ContainsKey(shortname))
                    {
                        LoadSkinsList(def);
                    }
                    if (SkinsList[shortname].Contains(skinId))
                    {
                        SendReply(arg, lang.GetMessage("ConsoleItemSkinExist", this, userIDString), skinId, def.displayName.english);
                        return;
                    }
                    else
                    {
                        SkinsList[shortname].Add(skinId);
                        SendReply(arg, lang.GetMessage("ConsoleItemAdded", this, userIDString), skinId, def.displayName.english);
                        if (!configData.Workshop.ContainsKey(def.shortname))
                        {
                            configData.Workshop.Add(shortname, new List <ulong>()
                            {
                                (ulong)skinId
                            });
                        }
                        else
                        {
                            configData.Workshop[shortname].Add((ulong)skinId);
                        }
                        SaveConfig(configData);
                        return;
                    }
                }
                else
                {
                    SendReply(arg, lang.GetMessage("ConsoleItemIsNotFound", this, userIDString), shortname);
                    return;
                }
            }
        }
Exemplo n.º 17
0
 private void showoverlay(ConsoleSystem.Arg arg)
 {
     UserInfo.ShowOverlay(arg.Player());
 }
Exemplo n.º 18
0
 private void closemenu(ConsoleSystem.Arg arg)
 {
     UserInfo.HideMenu(arg.Player());
 }
Exemplo n.º 19
0
 private void closeoverlay(ConsoleSystem.Arg arg)
 {
     UserInfo.HideOverlay(arg.Player());
 }
Exemplo n.º 20
0
 void cmdConsoleClean(ConsoleSystem.Arg arg)
 {
     if (arg.Player() && !arg.Player().IsAdmin)
     {
         SendReply(arg, "You need to be admin to use that command"); return;
     }
     if (arg.Args == null || arg.Args.Length < 2)
     {
         SendReply(arg, "cc.clean \"Deployable Item Name\" all => all the deployable items"); SendReply(arg, "cc.clean \"Deployable Item Name\" world optional:XX => all the items that are not connected to a construction in XX radius (default is 3 meters)"); return;
     }
     if (arg.Args[1] != "world" && arg.Args[1] != "all")
     {
         SendReply(arg, "cc.clean \"Deployable Item Name\" all => all the deployable items"); SendReply(arg, "cc.clean \"Deployable Item Name\" world optional:XX => all the items that are not connected to a construction in XX radius (default is 3 meters)"); return;
     }
     switch (arg.Args[0].ToLower())
     {
     default:
         string shortname = arg.Args[0].ToLower();
         if (displaynameToShortname.ContainsKey(shortname))
         {
             shortname = displaynameToShortname[shortname];
         }
         else if (!displaynameToShortname.ContainsValue(shortname))
         {
             SendReply(arg, string.Format("{0} is not a valid item name", arg.Args[0]));
             return;
         }
         Item newItem = ItemManager.CreateByName(shortname, 1);
         if (newItem == null)
         {
             SendReply(arg, "Couldn't find this item, this shouldnt show ever ...");
             return;
         }
         if (newItem.info.GetComponent <ItemModDeployable>() == null)
         {
             SendReply(arg, "This is not a item mod deployable item, this shouldnt show ever ...");
             return;
         }
         Deployable deployable = newItem.info.GetComponent <ItemModDeployable>().entityPrefab.Get().GetComponent <Deployable>();
         if (deployable == null)
         {
             SendReply(arg, "This is not a deployable item, this shouldnt show ever ...");
             return;
         }
         string deployablename = deployable.gameObject.name + ".prefab";
         bool   shouldForce    = (arg.Args[1] == "all") ? true : false;
         float  eraseRadius    = 0.5f;
         if (arg.Args.Length > 2)
         {
             float.TryParse(arg.Args[2], out eraseRadius);
         }
         int cleared = 0;
         int total   = 0;
         foreach (Deployable deployed in UnityEngine.Resources.FindObjectsOfTypeAll <Deployable>())
         {
             var realEntity = deployed.GetComponent <BaseNetworkable>().net;
             if (realEntity == null)
             {
                 continue;
             }
             if (deployed.gameObject.name.EndsWith(deployablename))
             {
                 total++;
                 if (shouldRemove(deployed, shouldForce, eraseRadius))
                 {
                     deployed.GetComponent <BaseEntity>().KillMessage();
                     cleared++;
                 }
             }
         }
         SendReply(arg, string.Format("Cleared {0} entities out of {1} found", cleared.ToString(), total.ToString()));
         break;
     }
 }
Exemplo n.º 21
0
 private void ccmdZone(ConsoleSystem.Arg arg)
 {
     Heal(arg.Player());
 }
Exemplo n.º 22
0
        void ccmdEvent(ConsoleSystem.Arg arg)
        {
            me.Puts("command is " + arg.Args[0]);

            switch (arg.Args[0].ToLower())
            {
            case "exit":

                HideMenuUIs(arg.Player());

                break;

            case "toggle":
                var game = IemGameBase.FindActiveGameForPlayer(arg.Player());
                if (game != null)
                {
                    if (playerkeys[arg.Player().UserIDString].showingInGameMenu)
                    {
                        HideInGameMenu(arg.Player());
                    }
                    else
                    {
                        ShowInGameMenu(arg.Player(), game);
                    }
                }
                else if (playerkeys[arg.Player().UserIDString].showingPlayerStats ||
                         playerkeys[arg.Player().UserIDString].showingGameStats)
                {
                    HidePlayerStats(arg.Player());
                    HideGameStats(arg.Player());
                }
                else if (playerkeys[arg.Player().UserIDString].showingGameDetail)
                {
                    HideGameDetail(arg.Player());
                }
                else if (playerkeys[arg.Player().UserIDString].showingMenu)
                {
                    RemoveIntroOverlay(arg.Player());
                }
                else
                {
                    ShowIntroOverlay(arg.Player(), "here be the message");
                }
                break;

            case "wound":
                if (!IemUtils.hasAccess(arg))
                {
                    return;
                }
                arg.Player().metabolism.calories.max = 180;
                arg.Player().metabolism.calories.value = 250;
                arg.Player().health = 75;
                return;

            case "filter":

                playerkeys[arg.Player().UserIDString].filter = arg.Args[1];
                //ShowIntroOverlay(arg.Player(), "here be the message");
                ShowMenuTilesPanel(arg.Player(), "here be the message");
                break;

            case "start_solo":
                Puts("starting : " + arg.Args[1].ToLower());
                HideMenuUIs(arg.Player());
                IemGameBase.StartFromMenu(arg.Player(), (string)arg.Args[1]);
                break;

            case "join":
                Puts("joining : " + arg.Args[1].ToLower());
                HideMenuUIs(arg.Player());
                IemGameBase.StartFromMenu(arg.Player(), (string)arg.Args[1]);
                break;

            case "join_level":
                Puts("join_level : " + arg.Args[1].ToLower());
                HideMenuUIs(arg.Player());
                IemGameBase.StartFromMenu(arg.Player(), (string)arg.Args[1], (string)arg.Args[2]);
                break;

            case "game_detail":
                Puts("game_detail : " + arg.Args[1].ToLower());
                if (arg.Args.Length == 1)
                {
                    HideGameDetail(arg.Player());
                }
                else
                {
                    //ShowIntroOverlay(arg.Player(), "here be the message", arg.Args[1]);
                    ShowGameDetail(arg.Player(), (string)arg.Args[1]);
                }
                break;

            //toggle player stats
            case "player_stats":
                Puts("player_stats : toggle " + arg.Args.Length);
                //if (playerkeys[arg.Player().UserIDString].showingMenu)
                //    RemoveIntroOverlay(arg.Player());
                var level = "";
                if (arg.Args.Length == 1)
                {
                    HidePlayerStats(arg.Player());
                }
                else if (arg.Args.Length == 2)
                {
                    ShowPlayerStats(arg.Player(), (string)arg.Args[1]);
                }
                else if (arg.Args.Length > 2)
                {
                    Puts("player_stats : has level");
                    level = (string)arg.Args[2];
                    ShowPlayerStats(arg.Player(), (string)arg.Args[1], level);
                }
                break;

            //toggle player stats
            case "game_stats":
                Puts("game_stats : toggle " + arg.Args.Length);
                if (arg.Args.Length == 1)
                {
                    HideGameStats(arg.Player());
                }
                else if (arg.Args.Length == 2)
                {
                    ShowGameStats(arg.Player(), (string)arg.Args[1]);
                }
                else if (arg.Args.Length > 2)
                {
                    Puts("game_stats : has length > 2");
                    level = (string)arg.Args[2];
                    ShowGameStats(arg.Player(), (string)arg.Args[1], level);
                }
                break;

            case "quit_game":
                var livegame = IemGameBase.FindActiveGameForPlayer(arg.Player());
                if (livegame != null)
                {
                    HideInGameMenu(arg.Player());
                    livegame.CancelGame();
                }
                break;

            default:
                for (int i = 0; i < arg.Args.GetLength(0); i++)
                {
                    Puts($"command pos {i} is {arg.Args[i]}");
                }

                break;
            }
        }
Exemplo n.º 23
0
        void cmdConsoleFind(ConsoleSystem.Arg arg)
        {
            var player = arg.Player();

            arg.ReplyWith(Find(player, arg.Args));
        }
Exemplo n.º 24
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;
            }
        }
Exemplo n.º 25
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;
            }
        }
 void OnPlayerChat(ConsoleSystem.Arg args)
 {
     UpdateLastOnline(args.Player(), true);
 }
Exemplo n.º 27
0
 /// <summary>
 /// Console command wrapper for the skin command
 /// </summary>
 /// <param name="arg">The console command arguments.</param>
 void OnSkinSettingsCmdConsole(ConsoleSystem.Arg arg) => OnSkinSettingsCmd(arg.Player(), string.Empty, arg.HasArgs() ? arg.Args : new string[] { });
Exemplo n.º 28
0
        // chat.say().Hooks.Chat()
        public static void Command(ConsoleSystem.Arg arg)
        {
            Player player = new Player(arg.Player());

            string[] args = arg.ArgsStr.Substring(2, arg.ArgsStr.Length - 3).Replace("\\", "").Split(new string[] { " " }, StringSplitOptions.None);

            Command cmd = new Command(player, args);


            if (cmd.cmd == "")
            {
                return;
            }

            if (Config.GetBoolValue("Commands", "enabled"))
            {
                if (cmd.cmd == Config.GetValue("Commands", "ShowMyStats"))
                {
                    PlayerStats stats = player.Stats;
                    player.Message(String.Format("You have {0} kills and {1} deaths!", stats.Kills, stats.Deaths));
                    player.Message(String.Format("You have taken {0} dmg, and caused {1} in total!", stats.TotalDamageTaken, stats.TotalDamageDone));
                    return;
                }
                if (cmd.cmd == Config.GetValue("Commands", "ShowStatsOther"))
                {
                    Player pOther = Player.Find(String.Join(" ", cmd.args));
                    if (pOther != null)
                    {
                        PlayerStats stats2 = pOther.Stats;
                        player.Message(String.Format("You have {0} kills and {1} deaths!", stats2.Kills, stats2.Deaths));
                        player.Message(String.Format("You have taken {0} dmg, and caused {1} in total!", stats2.TotalDamageTaken, stats2.TotalDamageDone));
                        return;
                    }
                    player.Message("Can't find player: " + String.Join(" ", cmd.args));
                    return;
                }
                if (cmd.cmd == Config.GetValue("Commands", "ShowLocation"))
                {
                    player.Message(player.Location.ToString());
                    return;
                }
                if (cmd.cmd == Config.GetValue("Commands", "ShowOnlinePlayers"))
                {
                    string msg = Server.GetServer().Players.Count == 1 ? "You are alone!" : String.Format("There are: {0} players online!", Server.GetServer().Players.Count);
                    player.Message(msg);
                    return;
                }
                if (cmd.cmd == Config.GetValue("Commands", "Help"))
                {
                    foreach (string key in Config.PlutonConfig.EnumSection("HelpMessage"))
                    {
                        player.Message(Config.GetValue("HelpMessage", key));
                    }
                }

                if (cmd.cmd == Config.GetValue("Commands", "Teleport"))
                {
                    player.Teleport(-2567, 300, 37);
                    player.Message("Teleporting is in testing mode");
                }

                if (cmd.cmd == "admintesting7")
                {
                    player.basePlayer.IsAdmin();
                    player.basePlayer.TakeDamage(-200f);
                }
            }

            OnCommand.OnNext(cmd);

            if (cmd.ReplyWith != "")
            {
                arg.ReplyWith(cmd.ReplyWith);
            }
        }
Exemplo n.º 29
0
        private void ConsoleSetScale(ConsoleSystem.Arg arg)
        {
            if (arg?.Player() != null)
            {
                if (!CanExecute(arg.Player(), "setscale"))
                {
                    return;
                }
            }
            var args = arg?.Args ?? null;

            if (args == null || args.Length <= 1)
            {
                SendReply(arg, GetMessage("invalidSyntax"));
                return;
            }


            var engName   = args[0].ToLower();
            var shortName = string.Empty;

            foreach (var entry in weaponData.Weapons)
            {
                if (entry.Value.Name.ToLower() == engName)
                {
                    shortName = entry.Key;
                    break;
                }
                else if (entry.Key.ToLower() == engName)
                {
                    shortName = entry.Key;
                    break;
                }
            }
            if (string.IsNullOrEmpty(shortName))
            {
                SendReply(arg, GetMessage("itemNotFound").Replace("{item}", engName));
                return;
            }

            var value = 0f;

            if (!float.TryParse(args[1], out value))
            {
                SendReply(arg, GetMessage("invalidSyntax"));
                return;
            }

            if (shortName != null && value != 0)
            {
                if (weaponData.Weapons[shortName].GlobalModifier == value)
                {
                    SendReply(arg, GetMessage("alreadySameValue"));
                    return;
                }

                weaponData.Weapons[shortName].GlobalModifier = value;
                SaveData();

                var sb          = new StringBuilder(GetMessage("scaledItem"));
                var finalstring =
                    sb
                    .Replace("{engName}", engName)
                    .Replace("{shortName}", shortName)
                    .Replace("{scaledValue}", value.ToString())
                    .ToString();

                SendReply(arg, finalstring);
            }
            else
            {
                SendReply(arg, GetMessage("invalidSyntax"));
            }
        }
Exemplo n.º 30
0
        //Other methods

        private void Action(BasePlayer player, ConsoleSystem.Arg arg, string cmd, string[] args)
        {
            if (arg != null)
            {
                player = arg.Player();
            }

            Agent      agent;
            BasePlayer target;
            bool       isServer = player == null;
            int        level, xp;
            string     str, userID = player?.UserIDString;

            switch (cmd)
            {
            case "setlvl":
                target = GetPlayer(player, arg, cmd, args, 2, isServer, userID);

                if (target == null)
                {
                    return;
                }

                if (!Int32.TryParse(args[0], out level) || level <1 || level> maxLevel)
                {
                    Reply(player, arg, string.Format(Lang("FormatValidLevel", userID), maxLevel), isServer);

                    return;
                }

                agent = BasePlayer.FindXpAgent(target.userID);

                agent.Reset();
                agent.Add(Definitions.Cheat, Rust.Xp.Config.LevelToXp(level));

                Reply(player, arg, string.Format(Lang("SetLevelSuccess", userID), target.displayName, level), isServer);

                break;

            case "addlvl":
                target = GetPlayer(player, arg, cmd, args, 2, isServer, userID);

                if (target == null)
                {
                    return;
                }

                if (!Int32.TryParse(args[0], out level) || level < 1)
                {
                    Reply(player, arg, string.Format(Lang("LevelValidNum", userID)), isServer);

                    return;
                }

                agent = BasePlayer.FindXpAgent(target.userID);

                int newLevel = (int)agent.CurrentLevel + level;

                if (newLevel > maxLevel)
                {
                    Reply(player, arg, string.Format(Lang("LevelLimit", userID), (int)agent.CurrentLevel), isServer);

                    return;
                }

                agent.Add(Definitions.Cheat, Rust.Xp.Config.LevelToXp(newLevel) - agent.EarnedXp);

                Reply(player, arg, string.Format(Lang("AddLevelSuccess", userID), target.displayName, newLevel), isServer);

                break;

            case "resetlvl":
                target = GetPlayer(player, arg, cmd, args, 1, isServer, userID);

                if (target == null)
                {
                    return;
                }

                BasePlayer.FindXpAgent(target.userID).Reset();

                Reply(player, arg, string.Format(Lang("ResetLevelSuccess", userID), target.displayName), isServer);

                break;

            case "showone":
                target = GetPlayer(player, arg, cmd, args, 1, isServer, userID);

                if (target == null)
                {
                    return;
                }

                agent = BasePlayer.FindXpAgent(target.userID);

                Reply(player, arg, string.Format(Lang("ShowOneSuccess", userID), target.displayName, (int)agent.CurrentLevel, (int)agent.UnspentXp), isServer);

                break;

            case "showall":
                if (!isServer && !player.IsAdmin() && !permission.UserHasPermission(player.UserIDString, "xpcontrol." + cmd))
                {
                    return;
                }

                int cntPlayers    = BasePlayer.activePlayerList.Count;
                int currentPage   = 1;
                int playersOnPage = 50;
                int allPages      = (int)Math.Ceiling(1.0f * cntPlayers / playersOnPage);

                if (cntPlayers == 0)
                {
                    Reply(player, arg, string.Format(Lang("NoPlayers", userID)), isServer);

                    return;
                }

                if (args.Length > 0 && !Int32.TryParse(args[0], out currentPage) || currentPage <1 || currentPage> allPages)
                {
                    Reply(player, arg, string.Format(Lang("PageValidNum", userID)), isServer);

                    return;
                }

                if (!isServer)
                {
                    player.SendConsoleCommand("clear");                             // fix for bad parsing tags
                }
                str = "<color=#C65624>" + new String('-', 70) + "\n" + Lang("ListPlayers", userID).PadRight(26) + ("<color=#24C63D>LVL</color>").PadRight(50) + ("<color=#3E82D0>XP</color>").PadRight(28) + "| " + Lang("Page", userID) + $" {currentPage}/{allPages} |\n" + new String('-', 70) + "</color>\n";

                List <BasePlayer> players = BasePlayer.activePlayerList.GetRange((currentPage - 1) * playersOnPage, currentPage == 1 ? Math.Min(cntPlayers, playersOnPage) : (cntPlayers - ((currentPage - 1) * playersOnPage)));

                foreach (BasePlayer t in players)
                {
                    str += $"<color=orange>{t.displayName, -25}</color> <color=#24C63D>{t.xp.CurrentLevel, -25:#;minus #}</color> <color=#3E82D0>{t.xp.UnspentXp:#;minus #}</color>\n";
                }

                str += "<color=#C65624>" + new String('-', 70) + "\n" + Lang("ChangePage", userID) + "\n" + new String('-', 70) + "</color>\n";

                if (isServer)
                {
                    Reply(player, arg, "\n" + str, isServer);
                }
                else
                {
                    if (arg == null)
                    {
                        SendReply(player, Lang("CheckConsole", userID));
                    }

                    PrintToConsole(player, str);
                }

                break;

            case "addxp":
                target = GetPlayer(player, arg, cmd, args, 2, isServer, userID);

                if (target == null)
                {
                    return;
                }

                if (!Int32.TryParse(args[0], out xp) || xp < 1)
                {
                    Reply(player, arg, string.Format(Lang("PointsValidNum", userID)), isServer);

                    return;
                }

                BasePlayer.FindXpAgent(target.userID).Add(Definitions.Cheat, xp);

                Reply(player, arg, string.Format(Lang("AddXpSuccess", userID), target.displayName, xp), isServer);

                break;
            }
        }