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


C# ISender.Message方法代码示例

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


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

示例1: 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

示例2: WhoAmI

        private void WhoAmI(ISender sender, string args)
        {
            var player = sender as Player;
            if (player != null)
            {
                var sb = new StringBuilder();
                sb.Append("You are ");
                if (!player.IsAuthenticated()) sb.Append("not ");

                if (player.Op) sb.Append("an operator");
                else sb.Append("logged in");

                var groupName = String.Empty;
                if (Storage.IsAvailable)
                {
                    var grp = Storage.GetInheritedGroup(player);
                    if (grp != null) groupName = grp.Name;
                }

                if (!String.IsNullOrEmpty(groupName))
                {
                    sb.Append(" and are a part of the ");
                    sb.Append(groupName);
                    sb.Append(" group");
                }
                else sb.Append(" but not apart of any groups");

                sb.Append(".");
                sender.Message(sb.ToString(), Color.Orange);
            }
            else sender.Message("This command is for players only", Color.Red);
        }
开发者ID:carriercomm,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:32,代码来源:WhoAmICommand.cs

示例3: Auth

 /// <summary>
 /// Allows users to log in.
 /// </summary>
 /// <param name="sender">Sending player</param>
 /// <param name="password">Password for verification</param>
 public void Auth(ISender sender, string password)
 {
     if (sender is Player)
     {
         var player = sender as Player;
         if (Storage.IsAvailable)
         {
             var existing = Authentication.GetPlayer(sender.SenderName);
             if (existing != null)
             {
                 if (existing.ComparePassword(sender.SenderName, password))
                 {
                     Utils.NotifyAllOps(
                         String.Format("{0} successfully logged in.", player.name)
                     );
                     player.SendMessage("Successfully logged in.", Color.DarkGreen);
                     player.SetAuthentication(sender.SenderName, "tdsm");
                     player.SetOp(existing.Operator);
                 }
                 else
                 {
                     sender.Message("Login failed", Color.DarkRed);
                 }
             }
             else
             {
                 sender.Message("Login failed", Color.DarkRed);
             }
         }
         else
             sender.Message("This function is unavailable", Color.DarkRed);
     }
 }
开发者ID:DeathCradle,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:38,代码来源:OperatorCommand.cs

示例4: Exit

        /// <summary>
        /// Closes the Server all connections.
        /// </summary>
        /// <param name="sender">Sending player</param>
        /// <param name="args">Arguments sent with command</param>
        public void Exit(ISender sender, ArgumentList args)
        {
            var accessLevel = Core.Config.ExitAccessLevel;
            if (accessLevel == -1 && sender is Player)
            {
                sender.Message("You cannot perform that action.", 255, 238, 130, 238);
                return;
            }
            else if (!sender.HasAccessLevel((AccessLevel)accessLevel))
            {
                sender.Message("You cannot perform that action.", 255, 238, 130, 238);
                return;
            }

            string message;
            args.TryGetString(0, out message);

            if (String.IsNullOrEmpty(message))
                message = "Server is going down";

            //            args.ParseNone();

            Utils.NotifyAllOps("Exiting on request.");

            if (Netplay.anyClients)
            {
                for (var x = 0; x < Main.player.Length; x++)
                {
                    if (Main.player[x].active)
                    {
                        NetMessage.SendData((int)Packet.DISCONNECT, x, -1, message);

            #if CUSTOM_SOCKETS
                        var rc = Netplay.Clients[x];
                        if (rc != null && rc.Socket != null && rc.Socket is ClientConnection)
                        {
                            (rc.Socket as ClientConnection).Flush();
                        }
            #endif
                    }
                }

                //Prevent further connections
                Terraria.Netplay.Connection.Socket.StopListening();

                //                //Wait for total disconnection
                //                while (Netplay.anyClients)
                //                {
                //                    System.Threading.Thread.Sleep(100);
                //                }
            }

            Terraria.IO.WorldFile.saveWorld(false);
            Terraria.Netplay.disconnect = true;

            throw new OTA.Misc.ExitException(sender.SenderName + " requested that TDSM is to shutdown.");
        }
开发者ID:DeathCradle,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:62,代码来源:ExitCommand.cs

示例5: HardMode

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

            if (Main.hardMode)
                throw new CommandError("Hard mode is already enabled");

            sender.Message("Changing to hard mode...");
            WorldGen.IsGeneratingHardMode = true;
            Terraria.WorldGen.StartHardmode();
            while (WorldGen.IsGeneratingHardMode)
                System.Threading.Thread.Sleep(5);
            sender.Message("Hard mode is now enabled.");
        }
开发者ID:DeathCradle,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:19,代码来源:HardModeCommand.cs

示例6: 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

示例7: Ban

 /// <summary>
 /// Bans a user from the server.
 /// </summary>
 /// <param name="sender">Sending entity</param>
 /// <param name="args">Arguments sent with command</param>
 public static void Ban(ISender sender, string player)
 {
     if (sender is ConsoleSender)
     {
         if (String.IsNullOrEmpty(player))
         {
             Tools.WriteLine("Usage: ban <player>");
         }
         else
         {
             bool found = false;
             var lowered = player.ToLower();
             for (int i = 0; i < 255; i++)
             {
                 if (Main.player[i].active && Main.player[i].name.ToLower() == lowered)
                 {
                     Callbacks.NetplayCallback.AddBan(i);
                     NetMessage.SendData(2, i, -1, "Banned from server.", 0, 0f, 0f, 0f, 0);
                     found = true;
                 }
             }
             if (!found) sender.Message("Failed to find a player by the name of {0}", player);
         }
     }
 }
开发者ID:VanixxGraphix,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:30,代码来源:DefaultCommands.cs

示例8: 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

示例9: 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

示例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: 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

示例12: Dawn

        /// <summary>
        /// Changes the time to dawn
        /// </summary>
        /// <param name="sender">Sending entity</param>
        /// <param name="args">Arguments sent with command</param>
        public static void Dawn(ISender sender, ArgumentList args)
        {
            Main.dayTime = true;
            Main.time = 0.0;
            NetMessage.SendData(7, -1, -1, String.Empty, 0, 0f, 0f, 0f, 0);

            sender.Message("Time set to dawn");
        }
开发者ID:claudiofreda,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:13,代码来源:DefaultCommands.cs

示例13: Clear

 //TODO sort commands in alphabetical order.
 /// <summary>
 /// Clears the console text.
 /// </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();
     }
     else
         sender.Message("clear: This is a console only command");
 }
开发者ID:tylerjwatson,项目名称:Open-Terraria-API,代码行数:15,代码来源:DefaultCommands.cs

示例14: DeopPlayer

        /// <summary>
        /// De-OPs a given Player.
        /// </summary>
        /// <param name="sender">Sending player</param>
        /// <param name="args">Arguments sent with command</param>
        public void DeopPlayer(ISender sender, ArgumentList args)
        {
            var playerName = args.GetString(0);
            if (Storage.IsAvailable)
            {
                var existing = Authentication.GetPlayer(playerName);
                if (existing != null)
                {
                    if (!existing.Operator)
                        throw new CommandError("Player is not an operator");

                    var player = Tools.GetPlayerByName(playerName);
                    if (player != null)
                    {
                        player.SendMessage("Your server operator privledges have been revoked.", Color.DarkRed);
                        player.SetOp(false);
                        player.SetAuthentication(null, "tdsm");
                    }

                    if (Authentication.UpdatePlayer(playerName, null, false))
                    {
                        sender.Message("Deop success", Color.DarkGreen);
                    }
                    else
                    {
                        sender.Message("Failed to deop player", Color.DarkRed);
                    }
                }
                else
                {
                    sender.SendMessage("No user found by " + playerName);
                }
            }
            else
            {
                if (Core.Ops.Contains(playerName))
                {
                    var player = Tools.GetPlayerByName(playerName);
                    if (player != null)
                    {
                        player.SendMessage("Your server operator privledges have been revoked.", Color.Green);
                        player.SetOp(false);
                        player.SetAuthentication(null, "tdsm");
                    }

                    Utils.NotifyAllOps("De-Opping " + playerName + " [" + sender.SenderName + "]", true);
                    Core.Ops.Remove(playerName, true);

                    if (!Core.Ops.Save())
                    {
                        Utils.NotifyAllOps("Failed to save op list [" + sender.SenderName + "]", true);
                    }
                }
                else
                    sender.SendMessage("No user found by " + playerName);
            }
        }
开发者ID:DeathCradle,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:62,代码来源:OperatorCommand.cs

示例15: Kick

        /// <summary>
        /// Kicks a given Player from the server
        /// </summary>
        /// <param name="sender">Sending player</param>
        /// <param name="args">Arguments sent with command</param>
        public void Kick(ISender sender, ArgumentList args)
        {
            if (args.TryPop("-s"))
            {
                int s;
                args.ParseOne(out s);

                var slot = Terraria.Netplay.Clients[s];

                #if TDSMServer
                if (slot.State() != SlotState.VACANT)
                {
                slot.Kick("You have been kicked by " + sender.SenderName + ".");

                var player = Main.player[s];
                if (player != null && player.name != null)
                NewNetMessage.SendData(25, -1, -1, player.name + " has been kicked by " + sender.SenderName + ".", 255);
                }
                else
                {
                sender.Message("Kick slot is empty");
                }
                #else
                NetMessage.SendData(2, slot.Id, -1, "Kicked from server.", 0, 0f, 0f, 0f, 0, 0, 0);
                #endif
            }
            else
            {
                Player player;
                args.ParseOne<Player>(out player);

                if (player.name == null)
                {
                    sender.Message("Kick player name is not set.");
                    return;
                }

                player.Kick("You have been kicked by " + sender.SenderName + ".");
                NetMessage.SendData(25, -1, -1, player.name + " has been kicked by " + sender.SenderName + ".", 255);
            }
        }
开发者ID:DeathCradle,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:46,代码来源:KickCommand.cs


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