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


C# ArgumentList类代码示例

本文整理汇总了C#中ArgumentList的典型用法代码示例。如果您正苦于以下问题:C# ArgumentList类的具体用法?C# ArgumentList怎么用?C# ArgumentList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: InvalidatePlayer

        public static void InvalidatePlayer(Server server, ISender sender, ArgumentList args)
        {
            string playerName, param;
            Player player = server.GetPlayerByName(sender.Name);

            if (args.TryGetString(0, out playerName))
            {
                if (server.GetPlayerByName(playerName) != null)
                {
                    Login.plugin.SetPlayerInvalid(playerName);
                    SendMessage(player, "You have invalidated " + playerName);
                }
                else
                {
                    if (args.TryGetString(1, out param))
                    {
                        if (param.ToUpper() == "FORCE")
                        {
                            Login.plugin.SetPlayerInvalid(playerName);
                            SendMessage(player, "You have invalidated " + playerName);
                        }
                        else
                            SendMessage(player, "Usage: /invalidate <player> (force)");
                    }
                    else
                    {
                        SendMessage(player, "There is no current player names " + playerName);
                        SendMessage(player, "Use /invalidate <player> force to remove offline players");
                    }
                }
            }
            else
                SendMessage(player, "You must supply a player name");
        }
开发者ID:Erls-Corporation,项目名称:Login,代码行数:34,代码来源:Commands.cs

示例2: roll

        public static void roll(Server server, ISender sender, ArgumentList args)
        {
            Random random = new Random();
            int result = 0;
            int times = 1;
            int die = 6;

            if (args.Count > 0)
            {
                string[] arg = args[0].Split('d');
                times = Int32.Parse(arg[0]);
                die = Int32.Parse(arg[1]);
            }

            for (int i = 0; i < times; i++)
            {
                result += random.Next(1, die);
            }

            Player player = server.GetPlayerByName(sender.Name);

            if (! player.PluginData.ContainsKey("roll"))
            {
                player.PluginData.Add("roll", result);
            }
            else
            {
                player.PluginData["roll"] = result;
            }

            server.notifyAll(player.Name + " rolled a " + player.PluginData["roll"] + " on " + times.ToString() + "d" + die.ToString(), true);
        }
开发者ID:amarriner,项目名称:amarriner-Plugin,代码行数:32,代码来源:Commands.cs

示例3: ExampleCommand

 public static void ExampleCommand(ISender sender, ArgumentList args)
 {
     TDSM_Plugin MyPlugin = (TDSM_Plugin)args.Plugin; //Get the plugin object who's assigned to the "tdsmpluginexample"
     int arg;
     //if the user enters /tdsmpluginexample -test 1, it will retreive the next value '1' and put into 'arg' as an integer.
     if (args.TryParseOne<int>("-test", out arg))
     {
         sender.sendMessage(sender.Name + " Argument: " + arg);
     }
     else
     {
         //For new people, I would not really expect you to understand the following.
         //If needed I can simplify this down...
         string Platform = Terraria_Server.Definitions.Platform.Type.ToString();
         switch (Terraria_Server.Definitions.Platform.Type)
         {
             case Terraria_Server.Definitions.Platform.PlatformType.LINUX:
                 Platform = "Linux";
                 break;
             case Terraria_Server.Definitions.Platform.PlatformType.MAC:
                 Platform = "Mac";
                 break;
             case Terraria_Server.Definitions.Platform.PlatformType.WINDOWS:
                 Platform = "Windows";
                 break;
         }
         (sender as Player).sendMessage("TDSM Plugin Example, Running OS: " + Platform, ChatColor.DarkGreen);
     }
 }
开发者ID:Skiles,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:29,代码来源:PluginCommands.cs

示例4: ban

 // bans if ban = true, unbans if ban = false
 public static void ban(String name, String bannedby, bool ban)
 {
     Player player = FindPlayer(name);
     Sender sender = new ConsoleSender();
     ArgumentList command = new ArgumentList();
     command.Add(name);
     if (player != null)
     {
         if (player.Name != null)
         {
             if (ban)
             {
                 Commands.Ban(sender, command);
                 server.sendToOneClient(Packet.PLAYER_BANNED(name), bannedby);
             }
         }
     }
     else
     {
         if (ban)
             server.sendToOneClient(Packet.PLAYER_NOT_FOUND_ERROR(), bannedby);
         else
         {
             Commands.UnBan(sender, command);
             server.sendToOneClient(Packet.PLAYER_UNBANNED(name), bannedby);
         }
     }
 }
开发者ID:elevatorguy,项目名称:TDSM_Android,代码行数:29,代码来源:AndroidPlugin.cs

示例5: FastForwardTime

        /// <summary>
        /// Fast forwards time
        /// </summary>
        /// <param name="sender">Sending player</param>
        /// <param name="args">Arguments sent with command</param>
        public void FastForwardTime(ISender sender, ArgumentList args)
        {
            args.ParseNone();

            Core.TimeFastForwarding = !Core.TimeFastForwarding;
            sender.Message("Time is now " + (Core.TimeFastForwarding ? "fast" : "normal") + "!");
        }
开发者ID:carriercomm,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:12,代码来源:TimeCommand.cs

示例6: Mux

        public void Mux(object sender, DoWorkEventArgs e)
        {
            var inputM2TsFlags = _keepM2TsAudio ? null : "--no-audio";
            var inputMkvFlags = _keepM2TsAudio ? "--no-audio" : null;

            var args = new ArgumentList();

            // Chapter file
            args.AddIfAllNonEmpty("--chapters", _inputChaptersPath);

            // Output file
            args.AddAll("-o", _outputMkvPath);

            // Input M2TS file
            args.AddNonEmpty("--no-video", inputM2TsFlags, _inputM2TsPath);

            // If an input chapter file is specified, exclude chapters from the input MKV file
            if (!string.IsNullOrEmpty(_inputChaptersPath))
                args.Add("--no-chapters");

            // Input MKV file
            args.AddNonEmpty(inputMkvFlags, _inputMkvPath);

            Execute(args, sender, e);
        }
开发者ID:bdhero,项目名称:bdhero-fat,代码行数:25,代码来源:MkvMerge.cs

示例7: Refresh

        /// <summary>
        /// Refreshes a players area
        /// </summary>
        /// <param name="sender">Sending player</param>
        /// <param name="args">Arguments sent with command</param>
        public void Refresh(ISender sender, ArgumentList args)
        {
            args.ParseNone();

            var player = sender as Player;

            if (player == null)
            {
                sender.Message(255, "This is a player command");
                return;
            }

            if (player.whoAmI < 0)
                return;

            if (!player.Op)
            {
                var diff = DateTime.Now - player.GetLastCostlyCommand();

                if (diff < TimeSpan.FromSeconds(30))
                {
                    sender.Message(255, "You must wait {0:0} more seconds before using this command.", 30.0 - diff.TotalSeconds);
                    return;
                }

                player.SetLastCostlyCommand(DateTime.Now);
            }

            NetMessage.SendTileSquare(player.whoAmI, (int)(player.position.X / 16), (int)(player.position.Y / 16), 32);
        }
开发者ID:carriercomm,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:35,代码来源:RefreshCommand.cs

示例8: Clear

 //TODO sort commands in alphabetical order.
 /// <summary>
 /// Shuts down an exists.
 /// </summary>
 /// <param name="sender">Sending entity</param>
 /// <param name="args">Arguments sent with command</param>
 public static void Clear(ISender sender, ArgumentList args)
 {
     if (sender is ConsoleSender)
     {
         Console.Clear();
     }
 }
开发者ID:VanixxGraphix,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:13,代码来源:DefaultCommands.cs

示例9: Heal

        /// <summary>
        /// Heals one or all players.
        /// </summary>
        /// <param name="sender">Sending player</param>
        /// <param name="message">Message to send</param>
        public void Heal(ISender sender, ArgumentList args)
        {
            Player subject;

            if (args.TryPopOne(out subject))
            {
                subject = sender as Player;
                if (subject == null)
                {
                    sender.Message("Need a heal target");
                    return;
                }

                NetMessage.SendData((int)Packet.HEAL_PLAYER, -1, -1, String.Empty, subject.whoAmI, (float)subject.statLifeMax);
                subject.Message("You have been healed!", Color.Green);
            }
            else if (args.TryPop("-all"))
            {
                foreach (var plr in Main.player)
                {
                    if (plr.active)
                    {
                        NetMessage.SendData((int)Packet.HEAL_PLAYER, -1, -1, String.Empty, plr.whoAmI, (float)plr.statLifeMax);
                        plr.Message("You have been healed!", Color.Green);
                    }
                }
            }
            else if (sender is Player)
            {
                var plr = sender as Player;
                NetMessage.SendData((int)Packet.HEAL_PLAYER, -1, -1, String.Empty, plr.whoAmI, (float)plr.statLifeMax);
                plr.Message("You have been healed!", Color.Green);
            }
            else throw new CommandError("Nobody specified to heal");
        }
开发者ID:DeathCradle,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:40,代码来源:HealCommand.cs

示例10: TeleportHere

        /// <summary>
        /// Teleports specified player to sending player's location.
        /// </summary>
        /// <param name="sender">Sending player</param>
        /// <param name="args">Arguments sent with command</param>
        public void TeleportHere(ISender sender, ArgumentList args)
        {
            if (sender is Player)
            {
                Player player = ((Player)sender);
                Player subject;

                if (args.TryPopOne(out subject))
                {
                    if (subject == null)
                    {
                        sender.Message("Cannot find player");
                        return;
                    }

                    subject.Teleport(player);

                    Utils.NotifyAllOps("Teleported " + subject.name + " to " +
                        player.name + " [" + sender.SenderName + "]", true);
                }
            }
            else
            {
                throw new CommandError("This command is for players only");
            }
        }
开发者ID:DeathCradle,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:31,代码来源:TeleportHereCommand.cs

示例11: List

        /// <summary>
        /// Prints a player list, Possibly readable by bots.
        /// </summary>
        /// <param name="sender">Sending player</param>
        /// <param name="args">Arguments sent with command</param>
        public void List(ISender sender, ArgumentList args)
        {
            args.ParseNone();

            var players = from p in Terraria.Main.player
                                   where p.active && !p.IsOp()
                                   select p.name;
            var ops = from p in Terraria.Main.player
                               where p.active && p.IsOp()
                               select p.name;

            var pn = players.Count();
            var on = ops.Count();

            if (on + pn == 0)
            {
                sender.Message("No players online.");
                return;
            }

            string ps = String.Empty;
            string os = String.Empty;

            if (pn > 0)
                ps = (on > 0 ? " | Players: " : "Players: ") + String.Join(", ", players);

            if (on > 0)
                os = "Ops: " + String.Join(", ", ops);

            sender.SendMessage(string.Concat(os, ps, " (", on + pn, "/", Netplay.MaxConnections, ")"), 255, 255, 240, 20);
        }
开发者ID:DeathCradle,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:36,代码来源:PlayerListCommand.cs

示例12: Execute

 public void Execute(ArgumentList arguments, TaskList tasklist, TagList tags, TagFolder folder)
 {
     ILister lister = new Lister();
     if (arguments.GetParameter(arguments.GetLength() - 1) == "--export")
         lister = new HtmlLister();
     lister.ListFiltered(tasklist.FilterTasks(arguments.GetParameter(1)), arguments.GetParameter(1));
 }
开发者ID:bogdanuifalean,项目名称:JuniorMind,代码行数:7,代码来源:FilterCommand.cs

示例13: TestPoint

        public static void TestPoint(Server server, ISender sender, ArgumentList args)
        {
            string param;
            Player player = server.GetPlayerByName(sender.Name);

            if (args.TryGetString(0, out param))
            {
                switch (param.ToUpper())
                {
                    case "LOBBY":
                        player.sendMessage("Teleporting to the lobby", Login.plugin.chatColor);
                        Login.plugin.TeleportPlayerToPoint(player, Login.LOBBY);
                        break;
                    case "VALIDATED":
                        player.sendMessage("Teleporting to the validated point", Login.plugin.chatColor);
                        Login.plugin.TeleportPlayerToPoint(player, Login.VALIDATED);
                        break;
                    default:
                        player.sendMessage("You must specify either lobby or validated", Login.plugin.chatColor);
                        break;
                }
            }
            else
                player.sendMessage("You must specify either lobby or validated", Login.plugin.chatColor);
        }
开发者ID:Erls-Corporation,项目名称:Login,代码行数:25,代码来源:Commands.cs

示例14: SetPoint

        public static void SetPoint(Server server, ISender sender, ArgumentList args)
        {
            string param;
            Player player = server.GetPlayerByName(sender.Name);

            if (args.TryGetString(0, out param))
            {
                switch (param.ToUpper())
                {
                    case "LOBBY":
                        player.PluginData["lobby"] = true;
                        player.sendMessage("Hit a block where you want the lobby to be", Login.plugin.chatColor);
                        break;
                    case "VALIDATED":
                        player.PluginData["validated"] = true;
                        player.sendMessage("Hit a block where you want the validated point to be", Login.plugin.chatColor);
                        break;
                    default:
                        player.sendMessage("You must specify either lobby or validated", Login.plugin.chatColor);
                        break;
                }
            }
            else
                player.sendMessage("You must specify either lobby or validated", Login.plugin.chatColor);
        }
开发者ID:Erls-Corporation,项目名称:Login,代码行数:25,代码来源:Commands.cs

示例15: NPCSpawning

        /// <summary>
        /// Enables or disables NPC spawning
        /// </summary>
        /// <param name="sender">Sending player</param>
        /// <param name="args">Arguments sent with command</param>
        public void NPCSpawning(ISender sender, ArgumentList args)
        {
            args.ParseNone();

            Core.StopNPCSpawning = !Core.StopNPCSpawning;
            sender.Message("NPC spawning is now " + (Core.StopNPCSpawning ? "off" : "on") + "!");
        }
开发者ID:DeathCradle,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:12,代码来源:NpcSpawningCommand.cs


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