コード例 #1
0
ファイル: ConVar.cs プロジェクト: HexHash/LegacyRust
 public static string GetString(string strName, string strDefault)
 {
     ConsoleSystem.Arg arg = new ConsoleSystem.Arg(strName);
     if (arg.Invalid)
     {
         return strDefault;
     }
     Type[] typeArray = ConsoleSystem.FindTypes(arg.Class);
     if ((int)typeArray.Length == 0)
     {
         return strDefault;
     }
     Type[] typeArray1 = typeArray;
     for (int i = 0; i < (int)typeArray1.Length; i++)
     {
         Type type = typeArray1[i];
         FieldInfo field = type.GetField(arg.Function);
         if (field != null && field.IsStatic)
         {
             return field.GetValue(null).ToString();
         }
         PropertyInfo property = type.GetProperty(arg.Function);
         if (property != null && property.GetGetMethod().IsStatic)
         {
             return property.GetValue(null, null).ToString();
         }
     }
     return strDefault;
 }
コード例 #2
0
        public ServerConsoleEvent(ConsoleSystem.Arg args, string rconCmd)
        {
            if (String.IsNullOrEmpty(rconCmd))
                return;

            _args = args;
            Args = args.Args != null ? args.Args.ToList() : new List<string>();
            Cmd = rconCmd.Split(' ')[0];
            Reply = "Command not found!";
        }
コード例 #3
0
ファイル: PlayerInv.cs プロジェクト: balu92/Fougerite
        public void AddItem(string name, int amount)
        {
            Contract.Requires(!string.IsNullOrEmpty(name));
            Contract.Requires(amount >= 0);

            string[] strArray = new string[] { name, amount.ToString() };
            ConsoleSystem.Arg arg = new ConsoleSystem.Arg("");
            arg.Args = strArray;
            arg.SetUser(this.player.PlayerClient.netUser);
            inv.give(ref arg);
        }
コード例 #4
0
ファイル: ChatEvent.cs プロジェクト: Notulp/Pluton
 public ChatEvent(Player player, ConsoleSystem.Arg args)
 {
     User = player;
     Arg = args;
     if (args.connection != null)
         BroadcastName = args.connection.username;
     else
         BroadcastName = Server.server_message_name;
     OriginalText = args.ArgsStr.Substring(1, args.ArgsStr.Length - 2).Replace("\\", "");
     FinalText = OriginalText.Replace('<', '[').Replace('>', ']');
     Reply = "chat.say was executed";
 }
コード例 #5
0
ファイル: ClientConsoleEvent.cs プロジェクト: Viproz/Pluton
        public ClientConsoleEvent(ConsoleSystem.Arg arg, string rconCmd)
        {
            Internal = arg;
            User = Server.GetPlayer((BasePlayer) arg.connection.player);
            Args = new List<string>();

            Reply = "Command not found!";

            if (String.IsNullOrEmpty(rconCmd))
                return;

            foreach (string str in rconCmd.Split(' '))
                Args.Add(str);

            cmd = Args[0];
            Args.RemoveAt(0);
        }
コード例 #6
0
 public static void sysinfo(ConsoleSystem.Arg arg)
 {
     arg.ReplyWith(SystemInfoGeneralText.currentInfo);
 }
コード例 #7
0
 public static void restart(ConsoleSystem.Arg args)
 {
     ServerMgr.RestartServer(args.GetString(1, string.Empty), args.GetInt(0, 300));
 }
コード例 #8
0
 public static void error(ConsoleSystem.Arg args)
 {
     null.transform.position = Vector3.zero;
 }
コード例 #9
0
 void cmdConsoleBpLoad(ConsoleSystem.Arg arg)
 {
     BpLoad(arg.Player(), arg.Args ?? new string[0], arg);
 }
コード例 #10
0
 void cmdConsoleBpRemoveAll(ConsoleSystem.Arg arg)
 {
     BpRemoveAll(arg.Player(), arg.Args ?? new string[0], arg);
 }
コード例 #11
0
ファイル: FriendList.cs プロジェクト: balu92/Fougerite
        public void OutputList(ref ConsoleSystem.Arg arg)
        {
            ArrayList list  = new ArrayList();
            ArrayList list2 = new ArrayList();

            foreach (Friend friend in this)
            {
                PlayerClient client;
                try
                {
                    client = EnumerableToArray.ToArray <PlayerClient>(PlayerClient.FindAllWithString(friend.GetUserID().ToString()))[0];
                }
                catch
                {
                    list2.Add(friend.GetDisplayName());
                    continue;
                }
                list.Add(client.netUser.displayName + " (Online)");
                friend.SetDisplayName(client.netUser.displayName);
            }
            if (list.Count > 0)
            {
                Util.sayUser(arg.argUser.networkPlayer, Core.Name, string.Concat(new object[] { "You currently have ", list.Count, " friend", (list.Count > 1) ? "s" : "", " online." }));
            }
            else
            {
                Util.sayUser(arg.argUser.networkPlayer, Core.Name, "None of your friend is playing right now.");
            }
            foreach (string str in list2)
            {
                list.Add(str);
            }
            int    num  = 0;
            int    num2 = 0;
            string str2 = "";

            foreach (string str3 in list)
            {
                num2++;
                if (num2 >= 60)
                {
                    num = 0;
                    break;
                }
                str2 = str2 + str3 + ", ";
                if (num == 6)
                {
                    num = 0;
                    Util.sayUser(arg.argUser.networkPlayer, Core.Name, str2.Substring(0, str2.Length - 3));
                    str2 = "";
                }
                else
                {
                    num++;
                }
            }
            if (num != 0)
            {
                Util.sayUser(arg.argUser.networkPlayer, Core.Name, str2.Substring(0, str2.Length - 3));
            }
        }
コード例 #12
0
 private void ccmdGetWipe(ConsoleSystem.Arg arg)
 {
     SendReply(arg, string.Format(MSG("lastMapWipe"), configData.LastWipe, NextWipeDays(NextWipeDate)));
 }
コード例 #13
0
        void ChatReceived(ref ConsoleSystem.Arg arg)
        {
            Fougerite.Player pl = Fougerite.Server.Cache[arg.argUser.userID];
            var command         = ChatCommand.GetCommand("tpto") as TeleportToCommand;

            if (command.GetTPWaitList().Contains(pl.UID))
            {
                command.PartialNameTP(ref arg, arg.GetInt(0));
                arg.ArgsStr = string.Empty;
            }
            else if (Core.friendWaitList.Contains(arg.argUser.userID))
            {
                (ChatCommand.GetCommand("addfriend") as AddFriendCommand).PartialNameAddFriend(ref arg, arg.GetInt(0));
                Core.friendWaitList.Remove(arg.argUser.userID);
                arg.ArgsStr = string.Empty;
            }
            else if (Core.shareWaitList.Contains(pl.UID))
            {
                (ChatCommand.GetCommand("share") as ShareCommand).PartialNameDoorShare(ref arg, arg.GetInt(0));
                Core.shareWaitList.Remove(pl.UID);
                arg.ArgsStr = string.Empty;
            }
            else if (Core.banWaitList.Contains(pl.UID))
            {
                (ChatCommand.GetCommand("ban") as BanCommand).PartialNameBan(ref arg, arg.GetInt(0));
                Core.banWaitList.Remove(pl.UID);
                arg.ArgsStr = string.Empty;
            }
            else if (Core.kickWaitList.Contains(pl.UID))
            {
                (ChatCommand.GetCommand("kick") as KickCommand).PartialNameKick(ref arg, arg.GetInt(0));
                Core.kickWaitList.Remove(pl.UID);
                arg.ArgsStr = string.Empty;
            }
            else if (Core.killWaitList.Contains(pl.UID))
            {
                (ChatCommand.GetCommand("kill") as KillCommand).PartialNameKill(ref arg, arg.GetInt(0));
                Core.killWaitList.Remove(pl.UID);
                arg.ArgsStr = string.Empty;
            }
            else if (Core.unfriendWaitList.Contains(pl.UID))
            {
                (ChatCommand.GetCommand("unfriend") as UnfriendCommand).PartialNameUnfriend(ref arg, arg.GetInt(0));
                Core.unfriendWaitList.Remove(pl.UID);
                arg.ArgsStr = string.Empty;
            }
            else if (Core.unshareWaitList.Contains(pl.UID))
            {
                (ChatCommand.GetCommand("unshare") as UnshareCommand).PartialNameUnshareDoors(ref arg, arg.GetInt(0));
                Core.unshareWaitList.Remove(pl.UID);
                arg.ArgsStr = string.Empty;
            }
            else if (Core.whiteWaitList.Contains(pl.UID))
            {
                (ChatCommand.GetCommand("addwl") as WhiteListAddCommand).PartialNameWhitelist(ref arg, arg.GetInt(0));
                Core.whiteWaitList.Remove(pl.UID);
                arg.ArgsStr = string.Empty;
            }
            else if (Core.adminAddWaitList.Contains(arg.argUser.userID))
            {
                (ChatCommand.GetCommand("addadmin") as AddAdminCommand).PartialNameNewAdmin(ref arg, arg.GetInt(0));
                Core.adminAddWaitList.Remove(arg.argUser.userID);
                arg.ArgsStr = string.Empty;
            }
            else if (Core.adminRemoveWaitList.Contains(pl.UID))
            {
                (ChatCommand.GetCommand("unadmin") as RemoveAdminCommand).PartialNameRemoveAdmin(ref arg, arg.GetInt(0));
                Core.adminRemoveWaitList.Remove(pl.UID);
                arg.ArgsStr = string.Empty;
            }
            else if (Core.adminFlagsWaitList.Contains(pl.UID))
            {
                (ChatCommand.GetCommand("getflags") as GetFlagsCommand).PartialNameGetFlags(ref arg, arg.GetInt(0));
                Core.adminFlagsWaitList.Remove(pl.UID);
                arg.ArgsStr = string.Empty;
            }
            else if (Core.muteWaitList.Contains(pl.UID))
            {
                (ChatCommand.GetCommand("mute") as MuteCommand).PartialNameMute(ref arg, arg.GetInt(0));
                Core.muteWaitList.Remove(pl.UID);
                arg.ArgsStr = string.Empty;
            }
            else if (Core.unmuteWaitList.Contains(pl.UID))
            {
                (ChatCommand.GetCommand("unmute") as UnmuteCommand).PartialNameUnmute(ref arg, arg.GetInt(0));
                Core.unmuteWaitList.Remove(pl.UID);
                arg.ArgsStr = string.Empty;
            }
            else if (Core.adminFlagWaitList.Contains(pl.UID))
            {
                (ChatCommand.GetCommand("addflag") as AddFlagCommand).PartialNameAddFlags(ref arg, arg.GetInt(0));
                Core.adminFlagWaitList.Remove(pl.UID);
                arg.ArgsStr = string.Empty;
            }
            else if (Core.adminUnflagWaitList.Contains(pl.UID))
            {
                (ChatCommand.GetCommand("unflag") as RemoveFlagsCommand).PartialNameRemoveFlags(ref arg, arg.GetInt(0));
                Core.adminUnflagWaitList.Remove(pl.UID);
                arg.ArgsStr = string.Empty;
            }
            else if (Core.unbanWaitList.Contains(pl.UID))
            {
                (ChatCommand.GetCommand("unban") as UnbanCommand).PartialNameUnban(ref arg, arg.GetInt(0));
                Core.unbanWaitList.Remove(pl.UID);
                arg.ArgsStr = string.Empty;
            }

            if (Core.IsEnabled())
            {
                Core.handleCommand(ref arg);
            }
        }
コード例 #14
0
ファイル: Hooks.cs プロジェクト: xBDMx/oxide-plugins
 private void OnPlayerChat(ConsoleSystem.Arg arg)
 {
     HookCalled("OnPlayerChat");
 }
コード例 #15
0
ファイル: Hooks.cs プロジェクト: xBDMx/oxide-plugins
 private void OnRunCommand(ConsoleSystem.Arg arg)
 {
     HookCalled("OnRunCommand");
     // TODO: Print command messages
 }
コード例 #16
0
ファイル: FriendList.cs プロジェクト: slavagmail/Fougerite
        public void OutputList(ref ConsoleSystem.Arg arg)
        {
            List <string> onlineFriends  = new List <string>();
            List <string> offlineFriends = new List <string>();

            foreach (Friend friend in this)
            {
                PlayerClient client;
                if (PlayerClient.FindByUserID(friend.GetUserID(), out client))
                {
                    onlineFriends.Add(client.netUser.displayName);
                    friend.SetDisplayName(client.netUser.displayName);
                }
                else
                {
                    offlineFriends.Add(friend.GetDisplayName());
                }
            }

            int friendsPerRow = 7;

            Util.sayUser(arg.argUser.networkPlayer, Core.Name,
                         string.Format("You currently have {0} friend{1} online:",
                                       (onlineFriends.Count == 0 ? "no" : onlineFriends.Count.ToString()), ((onlineFriends.Count != 1) ? "s" : string.Empty)));

            if (onlineFriends.Count <= friendsPerRow && onlineFriends.Count > 0)
            {
                Util.sayUser(arg.argUser.networkPlayer, Core.Name, string.Join(", ", onlineFriends.ToArray()));
            }
            else if (onlineFriends.Count > 0)
            {
                int i = friendsPerRow;
                for (; i <= onlineFriends.Count; i += friendsPerRow)
                {
                    Util.sayUser(arg.argUser.networkPlayer, Core.Name, string.Join(", ", onlineFriends.GetRange(i - friendsPerRow, friendsPerRow).ToArray()));
                }
                if (offlineFriends.Count % friendsPerRow > 0 || i - friendsPerRow == friendsPerRow)
                {
                    Util.sayUser(arg.argUser.networkPlayer, Core.Name, string.Join(", ", onlineFriends.GetRange(i - friendsPerRow, offlineFriends.Count % friendsPerRow).ToArray()));
                }
            }

            Util.sayUser(arg.argUser.networkPlayer, Core.Name,
                         string.Format("You have {0} offline friend{1}:",
                                       (offlineFriends.Count == 0 ? "no" : offlineFriends.Count.ToString()), ((offlineFriends.Count != 1) ? "s" : string.Empty)));

            if (offlineFriends.Count <= friendsPerRow && offlineFriends.Count > 0)
            {
                Util.sayUser(arg.argUser.networkPlayer, Core.Name, string.Join(", ", offlineFriends.ToArray()));
            }
            else if (offlineFriends.Count > 0)
            {
                int i = friendsPerRow;
                for (; i <= offlineFriends.Count; i += friendsPerRow)
                {
                    Util.sayUser(arg.argUser.networkPlayer, Core.Name, string.Join(", ", offlineFriends.GetRange(i - friendsPerRow, friendsPerRow).ToArray()));
                }
                if (offlineFriends.Count % friendsPerRow > 0 || i - friendsPerRow == friendsPerRow)
                {
                    Util.sayUser(arg.argUser.networkPlayer, Core.Name, string.Join(", ", offlineFriends.GetRange(i - friendsPerRow, offlineFriends.Count % friendsPerRow).ToArray()));
                }
            }
        }
コード例 #17
0
ファイル: RustLegacyCore.cs プロジェクト: longstl/Oxide
        private object OnRunCommand(ConsoleSystem.Arg arg, bool wantreply)
        {
            if (arg == null)
            {
                return(null);
            }
            var cmdnamefull = $"{arg.Class}.{arg.Function}";

            // Get the args
            var str = arg.GetString(0);

            // Get the covalence player
            var iplayer = arg.argUser != null?covalence.PlayerManager.FindPlayer(arg.argUser.userID.ToString()) : null;

            // Is it a console command?
            if (cmdnamefull != "chat.say")
            {
                if (covalence.CommandSystem.HandleConsoleMessage(iplayer, $"{cmdnamefull} {str}") || cmdlib.HandleConsoleCommand(arg, wantreply))
                {
                    return(true);
                }
                return(null);
            }

            if (str.Length == 0)
            {
                return(true);
            }

            // Is it a chat command?
            if (str[0] != '/')
            {
                var chatSpecific  = Interface.Call("OnPlayerChat", arg.argUser, str);
                var chatCovalence = Interface.Call("OnUserChat", iplayer, str);
                return(chatSpecific ?? chatCovalence);
            }

            // Get the full command
            var command = str.Substring(1);

            // Parse it
            string cmd;

            string[] args;
            ParseChatCommand(command, out cmd, out args);
            if (cmd == null)
            {
                return(true);
            }

            // Is the command blocked?
            var commandSpecific  = Interface.Call("OnPlayerCommand", arg);
            var commandCovalence = Interface.Call("OnUserCommand", iplayer, cmd, args);

            if (commandSpecific != null || commandCovalence != null)
            {
                return(true);
            }

            // Is this a Covalence command?
            if (covalence.CommandSystem.HandleChatMessage(iplayer, str))
            {
                return(true);
            }

            // Is it a regular chat command?
            var player = arg.argUser;

            if (player == null)
            {
                Interface.Oxide.LogDebug("Player is actually a {0}!", arg.argUser);
            }
            else if (!cmdlib.HandleChatCommand(player, cmd, args))
            {
                ConsoleNetworker.SendClientCommand(player.networkPlayer, $"chat.add \"Server\" \" Unknown command {cmd}\"");
            }

            // Handled
            arg.ReplyWith(string.Empty);
            return(true);
        }
コード例 #18
0
ファイル: RustLegacyCore.cs プロジェクト: longstl/Oxide
        private void ConsoleShow(ConsoleSystem.Arg arg)
        {
            if (!PermissionsLoaded(arg))
            {
                return;
            }
            if (!IsAdmin(arg))
            {
                return;
            }
            if (!arg.HasArgs())
            {
                var reply = "Syntax: show <group|user> <name>\n";
                reply += "Syntax: show <groups|perms>";
                arg.ReplyWith(reply);
                return;
            }

            var mode = arg.GetString(0);
            var name = arg.GetString(1);

            if (mode.Equals("perms"))
            {
                var result = "Permissions:\n";
                result += string.Join(", ", permission.GetPermissions());
                arg.ReplyWith(result);
            }
            else if (mode.Equals("user"))
            {
                var player = FindPlayer(name);
                if (player == null && !permission.UserIdValid(name))
                {
                    arg.ReplyWith("User '" + name + "' not found");
                    return;
                }
                var userId = name;
                if (player != null)
                {
                    userId = player.userID.ToString();
                    name   = player.displayName;
                    permission.UpdateNickname(userId, name);
                    name += $"({userId})";
                }
                var result = "User '" + name + "' permissions:\n";
                result += string.Join(", ", permission.GetUserPermissions(userId));
                result += "\nUser '" + name + "' groups:\n";
                result += string.Join(", ", permission.GetUserGroups(userId));
                arg.ReplyWith(result);
            }
            else if (mode.Equals("group"))
            {
                if (!permission.GroupExists(name))
                {
                    arg.ReplyWith("Group '" + name + "' doesn't exist");
                    return;
                }
                var result = "Group '" + name + "' users:\n";
                result += string.Join(", ", permission.GetUsersInGroup(name));
                result += "\nGroup '" + name + "' permissions:\n";
                result += string.Join(", ", permission.GetGroupPermissions(name));
                var parent = permission.GetGroupParent(name);
                while (permission.GroupExists(parent))
                {
                    result += "\nParent group '" + parent + "' permissions:\n";
                    result += string.Join(", ", permission.GetGroupPermissions(parent));
                    parent  = permission.GetGroupParent(name);
                }
                arg.ReplyWith(result);
            }
            else if (mode.Equals("groups"))
            {
                arg.ReplyWith("Groups:\n" + string.Join(", ", permission.GetGroups()));
            }
        }
コード例 #19
0
        void ccmdAuth(ConsoleSystem.Arg arg)
        {
            var args = arg.Args;

            if (args == null)
            {
                Puts("Correct syntax: auth [command] (arguments)");
                return;
            }

            switch (args.Length)
            {
            case 1:
                if (args[0] == "password")                       // /auth password
                {
                    Puts("Password: "******"PASSWORD"]));
                }
                else if (args[0] == "toggle")                       // /auth toggle
                {
                    Config["ENABLED"] = !isEnabled();
                    SaveConfig();
                    Puts("Authentication is now " + ((isEnabled()) ? "enabled" : "disabled") + ".");
                }
                else if (args[0] == "status")                       // /auth status
                {
                    Puts("Authentication is " + ((isEnabled()) ? "enabled" : "disabled") + ".");
                }
                else if (args[0] == "timeout")
                {
                    Puts("Timeout: " + Convert.ToString(Config["TIMEOUT"]) + " seconds.");
                }
                else if (args[0] == "help")                       // /auth help
                {
                    Puts("Authentication commands:\n"
                         + "syntax: auth command [required] (optional)\n"
                         + "auth password (new password) - shows or sets password\n"
                         + "auth timeout (new timeout) - shows or sets timeout\n"
                         + "auth retries (new timeout) - shows or sets retries\n"
                         + "auth toggle (on/off) - toggles Authentication on/off\n"
                         + "auth status - shows Authentication status");
                }
                else if (args[0] == "retries")                       // /auth retries
                {
                    Puts("Retries: " + Convert.ToString(Config["RETRIES"]));
                }
                break;

            case 2:
                if (args[0] == "password")                       // /auth password [new password]
                {
                    if (args[1] != "password" && args[1] != "help" && args[1] != "toggle" && args[1] != "status" && args[1] != "timeout")
                    {
                        Config["PASSWORD"] = args[1];
                        SaveConfig();
                        Puts("New password: "******"PASSWORD"]));
                    }
                }
                else if (args[0] == "toggle")                       // /auth toggle (on/off)
                {
                    if (args[1] == "on")
                    {
                        if (!isEnabled())
                        {
                            Config["ENABLED"] = true;
                            SaveConfig();
                            Puts("Authentication is now enabled.");
                        }
                        else
                        {
                            Puts("Authentication is already enabled.");
                        }
                    }
                    else if (args[1] == "off")
                    {
                        if (isEnabled())
                        {
                            Config["ENABLED"] = false;
                            SaveConfig();
                            Puts("Authentication is now disabled.");
                        }
                        else
                        {
                            Puts("Authentication is already disabled.");
                        }
                    }
                    else
                    {
                        Puts("Correct syntax: /auth toggle (on/off)");
                    }
                }
                else if (args[0] == "timeout")                       // /auth timeout [new timeout]
                {
                    int converted;

                    try
                    {
                        converted = Convert.ToInt32(args[1]);
                    }
                    catch (FormatException e)
                    {
                        Puts("Could not convert " + args[1] + " to an integer.");
                        break;
                    }

                    if (converted > 0)
                    {
                        Config["TIMEOUT"] = converted;
                        SaveConfig();
                        Puts("New timeout: " + Convert.ToString(Config["TIMEOUT"]) + " seconds.");
                    }
                    else
                    {
                        Puts("Timeout must be greater than 0 seconds.");
                    }
                }
                else if (args[0] == "retries")                       // /auth retries [new retries]
                {
                    int converted;

                    try
                    {
                        converted = Convert.ToInt32(args[1]);
                    }
                    catch (FormatException e)
                    {
                        Puts("Could not convert " + args[1] + " to an integer.");
                        break;
                    }

                    if (converted >= 0)
                    {
                        Config["RETRIES"] = converted;
                        SaveConfig();
                        Puts("New retries: " + Convert.ToString(Config["RETRIES"]));
                    }
                    else
                    {
                        Puts("Retries must be a positive integer.");
                    }
                }
                break;
            }
        }
コード例 #20
0
 void cmdConsoleBpPrint(ConsoleSystem.Arg arg)
 {
     Puts(string.Join(",", GetAllPersistentPlayerId().ToList().ConvertAll(id => id.ToString()).ToArray()));
 }
コード例 #21
0
 void CmdSpawn(ConsoleSystem.Arg arg)
 {
     startSpawn();
 }
コード例 #22
0
        void BpRemoveAll(BasePlayer player, string[] args, ConsoleSystem.Arg arg = null)
        {
            if (!CheckAccess(player, _authLevelOther, arg))
            {
                return;
            }
            Puts("{0} used /bpremoveall {1}", player?.displayName, string.Join(" ", args));
            List <int> definitions;
            var        defaultBlueprints = new List <int>(ItemManager.defaultBlueprints);

            if (args != null && args.Length > 0)
            {
                definitions = new List <int>();
                foreach (var cur in args)
                {
                    foreach (var def in cur.Split(','))
                    {
                        var name = def.ToLower();
                        if (_itemShortname.ContainsKey(name))
                        {
                            name = _itemShortname[name];
                        }
                        var itemDef = ItemManager.FindItemDefinition(name);
                        if (itemDef == null)
                        {
                            Reply(player, arg, "Item not found: {0}", def);
                            return;
                        }
                        definitions.Add(itemDef.itemid);
                    }
                }
            }
            else
            {
                definitions = ItemManager.GetItemDefinitions().ConvertAll(i => i.itemid);
                //just delete non default
                definitions.RemoveAll(d => defaultBlueprints.Contains(d));
            }
            var defaultRemoved = definitions.Where(d => defaultBlueprints.Contains(d)).Select(d => ItemManager.itemDictionary[d].shortname).ToArray();

            if (defaultRemoved.Length > 0)
            {
                Reply(player, arg, "Found default blueprint(s)! Removed until respawn.");
                Reply(player, arg, "Bps: " + string.Join(",", defaultRemoved));
            }
            var allPersistentPlayerId = GetAllPersistentPlayerId();

            foreach (var persistentPlayerId in allPersistentPlayerId)
            {
                if (persistentPlayerId == 0)
                {
                    continue;
                }
                var data = ServerMgr.Instance.persistance.GetPlayerInfo(persistentPlayerId);
                if (data.blueprints.complete.RemoveAll(a => definitions.Contains(a)) > 0)
                {
                    ServerMgr.Instance.persistance.SetPlayerInfo(persistentPlayerId, data);
                    var targetPlayer = FindPlayer(persistentPlayerId.ToString());
                    if (targetPlayer?.net?.subscriber?.subscribed == null)
                    {
                        continue;
                    }
                    targetPlayer.SendFullSnapshot();
                }
            }
            Reply(player, arg, "Removed learned blueprints");
        }
コード例 #23
0
 void CmdBotKill(ConsoleSystem.Arg arg)
 {
     Kill();
 }
コード例 #24
0
        private void permsList(ConsoleSystem.Arg arg, int plugNumber, string actiontype, string Perm, string isGroup, string all, int page)
        {
            var player = arg.Connection.player as BasePlayer;
            var path   = ActiveAdmins[player.userID];

            if (player == null || arg.Args == null || arg.Args.Length < 6)
            {
                return;
            }
            int    pageNo = Convert.ToInt32(arg.Args[5]);
            string Pname;
            string group = arg.Args[3];

            if (arg.Args[4] == "all")
            {
                if (arg.Args[2] != null)
                {
                    Pname = path.subject?.userID.ToString();
                    string action     = arg.Args[1];
                    string PermInHand = arg.Args[2];
                    foreach (var perm in numberedPerms)
                    {
                        if (AllPerPage == true && perm.Key > (pageNo * 20) - 20 && perm.Key < ((pageNo * 20) + 1)) //All = page or All = all?! config option?
                        {
                            if (action == "grant" && group == "false")
                            {
                                permission.GrantUserPermission(Pname, perm.Value, null);
                            }
                            if (action == "revoke" && group == "false")
                            {
                                permission.RevokeUserPermission(Pname, perm.Value);
                            }
                            if (action == "grant" && group == "true")
                            {
                                permission.GrantGroupPermission(path.subjectGroup, perm.Value, null);
                            }
                            if (action == "revoke" && group == "true")
                            {
                                permission.RevokeGroupPermission(path.subjectGroup, perm.Value);
                            }
                        }
                        if (AllPerPage == false)
                        {
                            if (action == "grant" && group == "false")
                            {
                                permission.GrantUserPermission(Pname, perm.Value, null);
                            }
                            if (action == "revoke" && group == "false")
                            {
                                permission.RevokeUserPermission(Pname, perm.Value);
                            }
                            if (action == "grant" && group == "true")
                            {
                                permission.GrantGroupPermission(path.subjectGroup, perm.Value, null);
                            }
                            if (action == "revoke" && group == "true")
                            {
                                permission.RevokeGroupPermission(path.subjectGroup, perm.Value);
                            }
                        }
                    }
                }
            }
            else
            {
                Pname = path.subject?.userID.ToString();
                string action     = arg.Args[1];
                string PermInHand = arg.Args[2];
                if (arg.Args[2] != null)
                {
                    if (action == "grant" && group == "false")
                    {
                        permission.GrantUserPermission(Pname, PermInHand, null);
                    }
                    if (action == "revoke" && group == "false")
                    {
                        permission.RevokeUserPermission(Pname, PermInHand);
                    }
                    if (action == "grant" && group == "true")
                    {
                        permission.GrantGroupPermission(path.subjectGroup, PermInHand, null);
                    }
                    if (action == "revoke" && group == "true")
                    {
                        permission.RevokeGroupPermission(path.subjectGroup, PermInHand);
                    }
                }
            }

            plugNumber = Convert.ToInt32(arg.Args[0]);
            string plugName = "";

            foreach (var key in PlugList)
            {
                if (key.Key == plugNumber)
                {
                    plugName = key.Value;
                }
            }

            numberedPerms.Clear();
            int numOfPerms = 0;

            foreach (var perm in permission.GetPermissions())
            {
                if (perm.Contains($"{plugName}."))
                {
                    numOfPerms++;
                    numberedPerms.Add(numOfPerms, perm);
                }
            }
            CuiHelper.DestroyUi(player, "MenuGUI");
            if (group == "false")
            {
                PermsUI(player, $"{path.subject.displayName} - {plugName}", plugNumber, null, group, pageNo);
            }
            else
            {
                PermsUI(player, $"{path.subjectGroup} - {plugName}", plugNumber, null, group, pageNo);
            }
            return;
        }
コード例 #25
0
 void CmdBotWipe(ConsoleSystem.Arg arg)
 {
     Delete();
 }
コード例 #26
0
 public static void report(ConsoleSystem.Arg args)
 {
     ServerPerformance.DoReport();
 }
コード例 #27
0
        private void cmdTeam(ConsoleSystem.Arg arg)
        {
            if (!UseTDM)
            {
                return;
            }
            if (!isAuth(arg))
            {
                return;
            }
            if (arg.Args == null || arg.Args.Length != 2)
            {
                SendReply(arg, "Format: tdm.team \"playername\" \"A\" or \"B\"");
                return;
            }
            var fplayer = FindPlayer(arg.Args[0]);

            if (fplayer.Count == 0)
            {
                SendReply(arg, "No players found.");
                return;
            }
            if (fplayer.Count > 1)
            {
                SendReply(arg, "Multiple players found.");
                return;
            }
            var newTeamArg = arg.Args[1].ToUpper();
            var newTeam    = Team.NONE;

            switch (newTeamArg)
            {
            case "A":
                newTeam = Team.A;
                break;

            case "B":
                newTeam = Team.B;
                break;

            default:
                return;
            }
            var p           = fplayer[0].GetComponent <TDMPlayer>();
            var currentTeam = p.team;

            if (newTeam == currentTeam)
            {
                SendReply(arg, p.player.displayName + " is already on " + currentTeam);
                return;
            }
            p.team = newTeam;
            p.player.Hurt(300, DamageType.Bullet, null, true);

            string color = string.Empty;

            if (p.team == Team.A)
            {
                color = configData.TeamA_Color;
            }
            else if (p.team == Team.B)
            {
                color = configData.TeamB_Color;
            }

            SendReply(p.player, string.Format(TitleM() + "You have been moved to <color=" + color + ">Team {0}</color>", newTeam.ToString().ToUpper()));
            SendReply(arg, string.Format("{0} has been moved to Team {1}", p.player.displayName, newTeam.ToString().ToUpper()));
        }
コード例 #28
0
 public static void status_cl(ConsoleSystem.Arg args)
 {
 }
コード例 #29
0
ファイル: IGather.cs プロジェクト: welcometopwn/oxideplugins
        private BasePlayer FindPlayerC(ConsoleSystem.Arg targer, string arg)
        {
            var   foundPlayers = new List <BasePlayer>();
            ulong steamid;

            ulong.TryParse(arg, out steamid);
            string lowerarg = arg.ToLower();

            foreach (var p in BasePlayer.activePlayerList)
            {
                if (p != null)
                {
                    if (steamid != 0L)
                    {
                        if (p.userID == steamid)
                        {
                            return(p);
                        }
                    }
                    string lowername = p.displayName.ToLower();
                    if (lowername.Contains(lowerarg))
                    {
                        foundPlayers.Add(p);
                    }
                }
            }
            if (foundPlayers.Count == 0)
            {
                foreach (var sleeper in BasePlayer.sleepingPlayerList)
                {
                    if (sleeper != null)
                    {
                        if (steamid != 0L)
                        {
                            if (sleeper.userID == steamid)
                            {
                                foundPlayers.Clear();
                                foundPlayers.Add(sleeper);
                                return(foundPlayers[0]);
                            }
                        }
                        string lowername = targer.ToString();
                        if (lowername.Contains(lowerarg))
                        {
                            foundPlayers.Add(sleeper);
                        }
                    }
                }
            }
            if (foundPlayers.Count == 0)
            {
                if (arg != null)
                {
                    SendReply(targer, "Could not find a player with the name of " + arg);
                }
                return(null);
            }
            if (foundPlayers.Count > 1)
            {
                if (arg != null)
                {
                    SendReply(targer, "Could not find a player with the name of " + arg);
                }
                return(null);
            }

            return(foundPlayers[0]);
        }
コード例 #30
0
ファイル: TeleportToCommand.cs プロジェクト: balu92/Fougerite
        public void PartialNameTP(Fougerite.Player p, int choice)
        {
            if (!tpWaitList.Contains(p.PlayerClient.userID)) return;

            List<string> list = (List<string>)tpWaitList[p.PlayerClient.userID];
            string str = list[choice];
            if (choice == 0)
            {
                Util.sayUser(p.PlayerClient.netPlayer, Core.Name, "Cancelled!");
                tpWaitList.Remove(p.PlayerClient.userID);
            }
            else
            {
                ConsoleSystem.Arg arg;
                if (list[0] == "ToTarget")
                {
                    arg = new ConsoleSystem.Arg("teleport.toplayer " + Facepunch.Utility.String.QuoteSafe(p.Name) + " " + Facepunch.Utility.String.QuoteSafe(str));
                }
                else
                {
                    arg = new ConsoleSystem.Arg("teleport.toplayer " + Facepunch.Utility.String.QuoteSafe(str) + " " + Facepunch.Utility.String.QuoteSafe(p.Name));
                }
                teleport.toplayer(ref arg);
                tpWaitList.Remove(p.PlayerClient.userID);
            }
        }
コード例 #31
0
ファイル: NameGrabber.cs プロジェクト: wilddip/oxideplugins
        void cmdGrabName(ConsoleSystem.Arg arg)
        {
            if (arg.Player() && !arg.Player().IsAdmin())
            {
                SendReply(arg, "You don't have access to this command.");
                return;
            }


            if (arg.Args.Length == 0)
            {
                Puts("Wrong command usage! Try: grabname type name.");
                return;
            }

            string type = arg.Args[0];
            string name = arg.Args[1];

            var items_definition = ItemManager.GetItemDefinitions();
            var items_found      = new List <string>();
            var temp_variable    = "";

            switch (type)
            {
            case "item":
                foreach (ItemDefinition def in items_definition)
                {
                    if (def != null)
                    {
                        if (name.Equals("all") || def.shortname.Contains(name))
                        {
                            temp_variable += "'" + def.shortname + "' ";

                            if (temp_variable.Length >= 120)
                            {
                                items_found.Add(temp_variable);
                                temp_variable = "";
                            }
                        }
                    }
                }
                break;

            case "deployable":
                foreach (ItemDefinition itemDef in items_definition)
                {
                    if (itemDef.GetComponent <ItemModDeployable>() != null && (name.Equals("all") || itemDef.GetComponent <ItemModDeployable>().name.ToLower().Contains(name)))
                    {
                        temp_variable += "'" + itemDef.GetComponent <ItemModDeployable>().entityPrefab.resourcePath + "' ";

                        if (temp_variable.Length >= 120)
                        {
                            items_found.Add(temp_variable);
                            temp_variable = "";
                        }
                    }
                }
                break;

            case "animal":
                var animals = UnityEngine.Object.FindObjectsOfType <BaseNPC>().Where(entity => name.Equals("all") || entity.name.Contains(name)).ToArray();
                foreach (var o in animals)
                {
                    if (!items_found.Contains(o.name))
                    {
                        items_found.Add(o.name);
                    }
                }
                break;

            case "ingame":
                var objects = UnityEngine.Object.FindObjectsOfType <BaseEntity>().Where(entity => name.Equals("all") || entity.name.Contains(name)).ToArray();
                foreach (var o in objects)
                {
                    if (!items_found.Contains(o.name))
                    {
                        items_found.Add(o.name);
                    }
                }
                type = "In game object";
                break;

            default:
                Puts("No entity found!");
                break;
            }

            if (temp_variable.Length > 0)
            {
                items_found.Add(temp_variable);
            }

            if (items_found.Count != 0)
            {
                foreach (string s in items_found)
                {
                    Puts(type + "s Found: " + s);
                }
            }
            else
            {
                Puts("There is no " + type + " named " + name + ".");
            }
        }
コード例 #32
0
ファイル: ServerTests.cs プロジェクト: balu92/Fougerite
        void ConsoleReceived_Test()
        {
            try
            {
                ConsoleSystem.Arg arg = new ConsoleSystem.Arg("");
                Log("ConsoleReceived_Test: Test 1");
                Hooks.ConsoleReceived(ref arg);

                arg = null;
                Log("ConsoleReceived_Test: Test 2");
                Hooks.ConsoleReceived(ref arg);

                arg = new ConsoleSystem.Arg("say test");
                Log("ConsoleReceived_Test: Test 3");
                Hooks.ConsoleReceived(ref arg);
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
        }
コード例 #33
0
ファイル: Hooks.cs プロジェクト: slavagmail/Fougerite
        public static void ChatReceived(ref ConsoleSystem.Arg arg)
        {
            if (!chat.enabled)
            {
                return;
            }

            if (string.IsNullOrEmpty(arg.ArgsStr))
            {
                return;
            }

            var quotedName    = Facepunch.Utility.String.QuoteSafe(arg.argUser.displayName);
            var quotedMessage = Facepunch.Utility.String.QuoteSafe(arg.GetString(0));

            if (quotedMessage.Trim('"').StartsWith("/"))
            {
                Logger.LogDebug("[CHAT-CMD] "
                                + quotedName + " executed " + quotedMessage);
            }

            if (OnChatRaw != null)
            {
                OnChatRaw(ref arg);
            }

            if (string.IsNullOrEmpty(arg.ArgsStr))
            {
                return;
            }

            if (quotedMessage.Trim('"').StartsWith("/"))
            {
                string[] args    = Facepunch.Utility.String.SplitQuotesStrings(quotedMessage.Trim('"'));
                var      command = args[0].TrimStart('/');
                var      cargs   = new string[args.Length - 1];
                Array.Copy(args, 1, cargs, 0, cargs.Length);
                if (OnCommand != null)
                {
                    //OnCommand(Fougerite.Player.FindByPlayerClient(arg.argUser.playerClient), command, cargs);
                    OnCommand(Fougerite.Server.Cache[arg.argUser.playerClient.userID], command, cargs);
                }
            }
            else
            {
                Logger.ChatLog(quotedName, quotedMessage);
                var chatstr = new ChatString(quotedMessage);
                if (OnChat != null)
                {
                    //OnChat(Fougerite.Player.FindByPlayerClient(arg.argUser.playerClient), ref chatstr);
                    OnChat(Fougerite.Server.Cache[arg.argUser.playerClient.userID], ref chatstr);
                }

                string newchat = Facepunch.Utility.String.QuoteSafe(chatstr.NewText.Substring(1, chatstr.NewText.Length - 2)).Replace("\\\"", "" + '\u0022');

                if (string.IsNullOrEmpty(newchat))
                {
                    return;
                }

                Fougerite.Data.GetData().chat_history.Add(newchat);
                Fougerite.Data.GetData().chat_history_username.Add(quotedName);
                ConsoleNetworker.Broadcast("chat.add " + quotedName + " " + newchat);
            }
        }
コード例 #34
0
ファイル: Command.cs プロジェクト: tralivali1234/Oxide
 public void HandleCommand(ConsoleSystem.Arg arg)
 {
     Callback.Plugin?.TrackStart();
     Callback.Call(arg);
     Callback.Plugin?.TrackEnd();
 }
コード例 #35
0
ファイル: RustLegacyCore.cs プロジェクト: longstl/Oxide
 private void ConsoleVersion(ConsoleSystem.Arg arg) => arg.ReplyWith($"Oxide {OxideMod.Version} for Rust {Rust.Defines.Connection.protocol}");
コード例 #36
0
 private void cmdSpawnDump(ConsoleSystem.Arg arg)
 {
     SpawnDump();
 }
コード例 #37
0
ファイル: Hooks.cs プロジェクト: slavagmail/Fougerite
        public static bool ConsoleReceived(ref ConsoleSystem.Arg a)
        {
            StringComparison ic          = StringComparison.InvariantCultureIgnoreCase;
            bool             external    = a.argUser == null;
            bool             adminRights = (a.argUser != null && a.argUser.admin) || external;

            string userid = "[external][external]";

            if (adminRights && !external)
            {
                userid = string.Format("[{0}][{1}]", a.argUser.displayName, a.argUser.userID.ToString());
            }

            string logmsg = string.Format("[ConsoleReceived] userid={0} adminRights={1} command={2}.{3} args={4}", userid, adminRights.ToString(), a.Class, a.Function, (a.HasArgs(1) ? a.ArgsStr : "none"));

            Logger.LogDebug(logmsg);

            if (a.Class.Equals("fougerite", ic) && a.Function.Equals("reload", ic))
            {
                if (adminRights)
                {
                    ModuleManager.ReloadModules();
                    a.ReplyWith("Fougerite: Reloaded!");
                }
            }
            else if (a.Class.Equals("fougerite", ic) && a.Function.Equals("save", ic))
            {
                AvatarSaveProc.SaveAll();
                ServerSaveManager.AutoSave();
                if (Fougerite.Server.GetServer().HasRustPP)
                {
                    Fougerite.Server.GetServer().GetRustPPAPI().RustPPSave();
                }
                DataStore.GetInstance().Save();
                a.ReplyWith("Fougerite: Saved!");
            }
            else if (a.Class.Equals("fougerite", ic) && a.Function.Equals("rustpp", ic))
            {
                foreach (var module in Fougerite.ModuleManager.Modules)
                {
                    if (module.Plugin.Name.Equals("RustPPModule"))
                    {
                        module.DeInitialize();
                        module.Initialize();
                        break;
                    }
                }
                a.ReplyWith("Rust++ Reloaded!");
            }
            else if (OnConsoleReceived != null)
            {
                OnConsoleReceived(ref a, external);
            }

            if (string.IsNullOrEmpty(a.Reply))
            {
                a.ReplyWith(string.Format("Fougerite: {0}.{1} was executed!", a.Class, a.Function));
            }

            return(true);
        }