本文整理汇总了C#中ISender.HasAccessLevel方法的典型用法代码示例。如果您正苦于以下问题:C# ISender.HasAccessLevel方法的具体用法?C# ISender.HasAccessLevel怎么用?C# ISender.HasAccessLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISender
的用法示例。
在下文中一共展示了ISender.HasAccessLevel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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.");
}