本文整理汇总了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);
}
示例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);
}
示例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);
}
}
示例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.");
}
示例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.");
}
示例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");
}
示例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);
}
}
}
示例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);
}
示例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") + "!");
}
示例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");
}
}
示例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") + "!");
}
示例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");
}
示例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");
}
示例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);
}
}
示例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);
}
}