本文整理汇总了C#中TShockAPI.TSPlayer.HasPermission方法的典型用法代码示例。如果您正苦于以下问题:C# TSPlayer.HasPermission方法的具体用法?C# TSPlayer.HasPermission怎么用?C# TSPlayer.HasPermission使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TShockAPI.TSPlayer
的用法示例。
在下文中一共展示了TSPlayer.HasPermission方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ErrorMessage
/// <summary>
/// Handles error messages thrown by erroneous / lack of parameters by checking a player's group permissions.
/// </summary>
/// <param name="ply">The player executing the command.</param>
/// <returns>A string matching the error message.</returns>
public static string ErrorMessage(TSPlayer ply)
{
string error;
var list = new List<string>()
{
ply.HasPermission("key.change") ? "change" : null,
ply.HasPermission("key.reload") ? "reload" : null,
ply.HasPermission("key.mode") ? "mode" : null,
"list"
};
string valid = String.Join("/", list.FindAll(i => i != null));
error = String.Format("Invalid syntax! Proper syntax: {0}key <{1}> [type]", Commands.Specifier, valid);
return error;
}
示例2: CheckTilePermission
/// <summary>CheckTilePermission - Checks to see if a player has the ability to modify a tile at a given position.</summary>
/// <param name="player">player - The TSPlayer object.</param>
/// <param name="tileX">tileX - The x coordinate of the tile.</param>
/// <param name="tileY">tileY - The y coordinate of the tile.</param>
/// <param name="paint">paint - Whether or not the tile is paint.</param>
/// <returns>bool - True if the player should not be able to modify the tile.</returns>
public static bool CheckTilePermission(TSPlayer player, int tileX, int tileY, bool paint = false)
{
if ((!paint && !player.HasPermission(Permissions.canbuild)) ||
(paint && !player.HasPermission(Permissions.canpaint)))
{
if (((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - player.BPm) > 2000)
{
if (paint)
{
player.SendErrorMessage("You do not have permission to paint!");
}
else
{
player.SendErrorMessage("You do not have permission to build!");
}
player.BPm = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
}
return true;
}
if (!Regions.CanBuild(tileX, tileY, player))
{
if (((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - player.RPm) > 2000)
{
player.SendErrorMessage("This region is protected from changes.");
player.RPm = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
}
return true;
}
if (Config.DisableBuild)
{
if (!player.HasPermission(Permissions.antibuild))
{
if (((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - player.WPm) > 2000)
{
player.SendErrorMessage("The world is protected from changes.");
player.WPm = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
}
return true;
}
}
if (Config.SpawnProtection)
{
if (!player.HasPermission(Permissions.editspawn))
{
if (CheckSpawn(tileX, tileY))
{
if (((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - player.SPm) > 1000)
{
player.SendErrorMessage("Spawn is protected from changes.");
player.SPm = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
}
return true;
}
}
}
return false;
}