当前位置: 首页>>代码示例>>C#>>正文


C# ConsoleSystem.HasArgs方法代码示例

本文整理汇总了C#中ConsoleSystem.HasArgs方法的典型用法代码示例。如果您正苦于以下问题:C# ConsoleSystem.HasArgs方法的具体用法?C# ConsoleSystem.HasArgs怎么用?C# ConsoleSystem.HasArgs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ConsoleSystem的用法示例。


在下文中一共展示了ConsoleSystem.HasArgs方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExtractArgs

 private static string[] ExtractArgs(ConsoleSystem.Arg arg)
 {
     if (arg == null) return new string[0];
     var argsList = new List<string>();
     var i = 0;
     while (arg.HasArgs(++i)) argsList.Add(arg.GetString(i - 1));
     return argsList.ToArray();
 }
开发者ID:yas-online,项目名称:Oxide,代码行数:8,代码来源:RustLegacyCommandSystem.cs

示例2: bind

 public static void bind(ref ConsoleSystem.Arg args)
 {
     if (!args.HasArgs(3))
     {
         return;
     }
     string str = args.Args[0];
     string str1 = args.Args[1];
     string str2 = args.Args[2];
     GameInput.GameButton button = GameInput.GetButton(str);
     if (button != null)
     {
         button.Bind(str1, str2);
     }
 }
开发者ID:HexHash,项目名称:LegacyRust,代码行数:15,代码来源:input.cs

示例3: cmdConsoleKitGui

 void cmdConsoleKitGui(ConsoleSystem.Arg arg)
 {
     if (arg.connection == null)
     {
         SendReply(arg, "You can't use this command from the server console");
         return;
     }
     if (!arg.HasArgs())
     {
         SendReply(arg, "You are not allowed to use manually this command");
         return;
     }
     var player = arg.Player();
     var kitname = arg.Args[0].Substring(1, arg.Args[0].Length - 2);
     TryGiveKit(player, kitname);
     RefreshKitPanel(player, PlayerGUI[player.userID].guiid, PlayerGUI[player.userID].page);
 }
开发者ID:Arkoudaphobia,项目名称:ArkoudaphobiaConfig,代码行数:17,代码来源:Kits.cs

示例4: cmdShow

        private void cmdShow(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.UserExists(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"))
            {
                var result = "Groups:\n";
                result += string.Join(", ", permission.GetGroups());
                arg.ReplyWith(result);
            }
        }
开发者ID:906507516,项目名称:Oxide,代码行数:70,代码来源:RustLegacyCore.cs

示例5: cmdRevoke

        private void cmdRevoke(ConsoleSystem.Arg arg)
        {
            if (!PermissionsLoaded(arg)) return;
            if (!IsAdmin(arg)) return;
            if (!arg.HasArgs(3))
            {
                arg.ReplyWith("Usage: revoke <group|user> <name|id> <permission>");
                return;
            }

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

            if (mode.Equals("group"))
            {
                if (!permission.GroupExists(name))
                {
                    arg.ReplyWith("Group '" + name + "' doesn't exist");
                    return;
                }
                permission.RevokeGroupPermission(name, perm);
                arg.ReplyWith("Group '" + name + "' revoked permission: " + perm);
            }
            else if (mode.Equals("user"))
            {
                var player = FindPlayer(name);
                if (player == null && !permission.UserExists(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);
                }
                permission.RevokeUserPermission(userId, perm);
                arg.ReplyWith("User '" + name + "' revoked permission: " + perm);
            }
        }
开发者ID:906507516,项目名称:Oxide,代码行数:43,代码来源:RustLegacyCore.cs

示例6: CmdShow

        private void CmdShow(ConsoleSystem.Arg arg)
        {
            if (!PermissionsLoaded(arg)) return;
            if (!IsAdmin(arg)) return;
            if (!arg.HasArgs())
            {
                ReplyWith(arg.connection, "CommandUsageShow");
                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.UserExists(name))
                {
                    ReplyWith(arg.connection, "UserNotFound");
                    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))
                {
                    ReplyWith(arg.connection, "GroupNotFound", name);
                    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(parent);
                }
                arg.ReplyWith(result);
            }
            else if (mode.Equals("groups"))
            {
                var result = "Groups:\n";
                result += string.Join(", ", permission.GetGroups());
                arg.ReplyWith(result);
            }
        }
开发者ID:906507516,项目名称:Oxide,代码行数:68,代码来源:RustCore.cs

示例7: CmdUserGroup

        private void CmdUserGroup(ConsoleSystem.Arg arg)
        {
            if (!PermissionsLoaded(arg)) return;
            if (!IsAdmin(arg)) return;
            if (!arg.HasArgs(3))
            {
                ReplyWith(arg.connection, "CommandUsageUserGroup");
                return;
            }

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

            var player = FindPlayer(name);
            if (player == null && !permission.UserExists(name))
            {
                ReplyWith(arg.connection, "UserNotFound", name);
                return;
            }
            var userId = name;
            if (player != null)
            {
                userId = player.userID.ToString();
                name = player.displayName;
                permission.UpdateNickname(userId, name);
                name += $"({userId})";
            }

            if (!permission.GroupExists(group))
            {
                ReplyWith(arg.connection, "GroupNotFound", name);
                return;
            }

            if (mode.Equals("add"))
            {
                permission.AddUserGroup(userId, group);
                ReplyWith(arg.connection, "UserAddedToGroup", name, group);
            }
            else if (mode.Equals("remove"))
            {
                permission.RemoveUserGroup(userId, group);
                ReplyWith(arg.connection, "UserRemovedFromGroup", name, group);
            }
        }
开发者ID:906507516,项目名称:Oxide,代码行数:46,代码来源:RustCore.cs

示例8: CmdLang

        private void CmdLang(ConsoleSystem.Arg arg)
        {
            if (!IsAdmin(arg)) return;

            if (arg.HasArgs()) lang.SetServerLanguage(arg.GetString(0));
            ReplyWith(arg.connection, "ServerLanguage", lang.GetServerLanguage());
        }
开发者ID:906507516,项目名称:Oxide,代码行数:7,代码来源:RustCore.cs

示例9: cmdGroup

        private void cmdGroup(ConsoleSystem.Arg arg)
        {
            if (!PermissionsLoaded(arg)) return;

            if (arg.Player() != null && !arg.Player().IsAdmin()) return;
            // Check 2 args exists
            if (!arg.HasArgs(2))
            {
                var reply = "Syntax: oxide.group <add|set> <name> [title] [rank]\n";
                reply += "Syntax: oxide.group <remove|show> <name>\n";
                reply += "Syntax: oxide.group <parent> <name> <parentName>";
                arg.ReplyWith(reply);
                return;
            }

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

            if (mode.Equals("add"))
            {
                if (permission.GroupExists(name))
                {
                    arg.ReplyWith("Group '" + name + "' already exist");
                    return;
                }
                permission.CreateGroup(name, arg.GetString(2), arg.GetInt(3));
                arg.ReplyWith("Group '" + name + "' created");
            }
            else if (mode.Equals("remove"))
            {
                if (!permission.GroupExists(name))
                {
                    arg.ReplyWith("Group '" + name + "' doesn't exist");
                    return;
                }
                permission.RemoveGroup(name);
                arg.ReplyWith("Group '" + name + "' deleted");
            }
            else if (mode.Equals("set"))
            {
                if (!permission.GroupExists(name))
                {
                    arg.ReplyWith("Group '" + name + "' doesn't exist");
                    return;
                }
                permission.SetGroupTitle(name, arg.GetString(2));
                permission.SetGroupRank(name, arg.GetInt(3));
                arg.ReplyWith("Group '" + name + "' changed");
            }
            else if (mode.Equals("parent"))
            {
                if (!permission.GroupExists(name))
                {
                    arg.ReplyWith("Group '" + name + "' doesn't exist");
                    return;
                }
                var parent = arg.GetString(2);
                if (!string.IsNullOrEmpty(parent) && !permission.GroupExists(parent))
                {
                    arg.ReplyWith("Parent group '" + parent + "' doesn't exist");
                    return;
                }
                if (permission.SetGroupParent(name, parent))
                    arg.ReplyWith("Group '" + name + "' changed");
                else
                    arg.ReplyWith("Group '" + name + "' failed to change");
            }
            else if (mode.Equals("show"))
            {
                if (!permission.GroupExists(name))
                {
                    arg.ReplyWith("Group '" + name + "' doesn't exist");
                    return;
                }
                var result = "Group '" + name + "' permissions:\n";
                result += string.Join(",", permission.GetGroupPermissions(name));
                arg.ReplyWith(result);
            }
        }
开发者ID:HalfShotz,项目名称:Oxide,代码行数:79,代码来源:RustCore.cs

示例10: cmdGrant

        private void cmdGrant(ConsoleSystem.Arg arg)
        {
            if (!PermissionsLoaded(arg)) return;

            if (arg.Player() != null && !arg.Player().IsAdmin()) return;
            // Check 3 args exists
            if (!arg.HasArgs(3))
            {
                arg.ReplyWith("Syntax: oxide.grant <group|user> <name|id> <permission>");
                return;
            }

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

            if (mode.Equals("group"))
            {
                if (!permission.GroupExists(name))
                {
                    arg.ReplyWith("Group '" + name + "' doesn't exist");
                    return;
                }
                permission.GrantGroupPermission(name, perm, null);
                arg.ReplyWith("Group '" + name + "' granted permission: " + perm);
            }
            else if (mode.Equals("user"))
            {
                var player = FindPlayer(name);
                if (player == null && !permission.UserExists(name))
                {
                    arg.ReplyWith("User '" + name + "' not found");
                    return;
                }
                var userId = name;
                if (player != null)
                {
                    userId = player.userID.ToString();
                    name = player.displayName;
                    permission.GetUserData(name).LastSeenNickname = name;
                }
                permission.GrantUserPermission(userId, perm, null);
                arg.ReplyWith("User '" + name + "' granted permission: " + perm);
            }
        }
开发者ID:HalfShotz,项目名称:Oxide,代码行数:45,代码来源:RustCore.cs

示例11: cmdLoad

        private void cmdLoad(ConsoleSystem.Arg arg)
        {
            if (arg.argUser != null && !arg.argUser.admin) return;
            // Check arg 1 exists
            if (!arg.HasArgs())
            {
                arg.ReplyWith("Syntax: oxide.load *|<pluginname>+");
                return;
            }

            if (arg.GetString(0).Equals("*"))
            {
                Interface.Oxide.LoadAllPlugins();
                return;
            }

            foreach (var name in arg.Args)
            {
                if (string.IsNullOrEmpty(name)) continue;
                // Load
                Interface.Oxide.LoadPlugin(name);
                pluginmanager.GetPlugin(name);
            }
        }
开发者ID:CypressCube,项目名称:Oxide,代码行数:24,代码来源:RustLegacyCore.cs

示例12: cmdGroup

        private void cmdGroup(ConsoleSystem.Arg arg)
        {
            if (!PermissionsLoaded(arg)) return;

            if (arg.argUser != null && !arg.argUser.CanAdmin()) return;
            // Check 2 args exists
            if (!arg.HasArgs(2))
            {
                arg.ReplyWith("Syntax: oxide.group <add|remove|set> <name> [title] [rank]");
                return;
            }

            var mode = arg.GetString(0);
            var name = arg.GetString(1);
            var title = arg.GetString(2);
            var rank = arg.GetInt(3);

            if (mode.Equals("add"))
            {
                if (permission.GroupExists(name))
                {
                    arg.ReplyWith("Group '" + name + "' already exist");
                    return;
                }
                permission.CreateGroup(name, title, rank);
                arg.ReplyWith("Group '" + name + "' created");
            }
            else if (mode.Equals("remove"))
            {
                if (!permission.GroupExists(name))
                {
                    arg.ReplyWith("Group '" + name + "' doesn't exist");
                    return;
                }
                permission.RemoveGroup(name);
                arg.ReplyWith("Group '" + name + "' deleted");
            }
            else if (mode.Equals("set"))
            {
                if (!permission.GroupExists(name))
                {
                    arg.ReplyWith("Group '" + name + "' doesn't exist");
                    return;
                }
                permission.SetGroupTitle(name, title);
                permission.SetGroupRank(name, rank);
                arg.ReplyWith("Group '" + name + "' changed");
            }
        }
开发者ID:CypressCube,项目名称:Oxide,代码行数:49,代码来源:RustLegacyCore.cs

示例13: ccmdZone

        private void ccmdZone(ConsoleSystem.Arg arg)
        {
            var player = arg.Player();
            if (!hasPermission(player, PermZone)) { SendMessage(player, "You don't have access to this command"); return; }
            var zoneId = arg.GetString(0);
            ZoneDefinition zoneDefinition;
            if (!arg.HasArgs(3) || !ZoneDefinitions.TryGetValue(zoneId, out zoneDefinition)) { SendMessage(player, "Zone Id not found or Too few arguments: zone <zoneid> <arg> <value>"); return; }

            var args = new string[arg.Args.Length - 1];
            Array.Copy(arg.Args, 1, args, 0, args.Length);
            UpdateZoneDefinition(zoneDefinition, args, player);
            RefreshZone(zoneId);
            //SaveData();
            //ShowZone(player, zoneId);
        }
开发者ID:mpendel,项目名称:RUSTBOYS,代码行数:15,代码来源:ZoneManager.cs

示例14: ConsoleLoad

        private void ConsoleLoad(ConsoleSystem.Arg arg)
        {
            if (!IsAdmin(arg.Player())) return;
            if (!arg.HasArgs())
            {
                Reply(arg.connection, "CommandUsageLoad");
                return;
            }

            if (arg.GetString(0).Equals("*"))
            {
                Interface.Oxide.LoadAllPlugins();
                return;
            }

            foreach (var name in arg.Args)
            {
                if (string.IsNullOrEmpty(name)) continue;
                Interface.Oxide.LoadPlugin(name);
                pluginManager.GetPlugin(name);
            }
        }
开发者ID:yas-online,项目名称:Oxide,代码行数:22,代码来源:RustCore.cs

示例15: ConsoleShow

        private void ConsoleShow(ConsoleSystem.Arg arg)
        {
            if (!PermissionsLoaded(arg)) return;
            if (!IsAdmin(arg.Player())) return;
            if (!arg.HasArgs())
            {
                Reply(arg.connection, "CommandUsageShow");
                return;
            }

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

            if (mode.Equals("perms"))
            {
                arg.ReplyWith("Permissions:\n" + string.Join(", ", permission.GetPermissions()));
            }
            else if (mode.Equals("perm"))
            {
                if (string.IsNullOrEmpty(name))
                {
                    Reply(arg.connection, "CommandUsageShow");
                    return;
                }

                var result = $"Permission '{name}' Users:\n";
                result += string.Join(", ", permission.GetPermissionUsers(name));
                result += $"\nPermission '{name}' Groups:\n";
                result += string.Join(", ", permission.GetPermissionGroups(name));
                arg.ReplyWith(result);
            }
            else if (mode.Equals("user"))
            {
                if (string.IsNullOrEmpty(name))
                {
                    Reply(arg.connection, "CommandUsageShow");
                    return;
                }

                var target = FindPlayer(name);
                if (target == null && !permission.UserIdValid(name))
                {
                    Reply(arg.connection, "UserNotFound", name);
                    return;
                }
                var userId = name;
                if (target != null)
                {
                    userId = target.UserIDString;
                    name = target.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 (string.IsNullOrEmpty(name))
                {
                    Reply(arg.connection, "CommandUsageShow");
                    return;
                }

                if (!permission.GroupExists(name))
                {
                    Reply(arg.connection, "GroupNotFound", name);
                    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(parent);
                }
                arg.ReplyWith(result);
            }
            else if (mode.Equals("groups"))
            {
                arg.ReplyWith("Groups:\n" + string.Join(", ", permission.GetGroups()));
            }
        }
开发者ID:yas-online,项目名称:Oxide,代码行数:91,代码来源:RustCore.cs


注:本文中的ConsoleSystem.HasArgs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。