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


C# TSPlayer.HasPermission方法代码示例

本文整理汇总了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;
        }
开发者ID:Enerdy,项目名称:KeyChanger,代码行数:20,代码来源:Utils.cs

示例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;
        }
开发者ID:NyxStudios,项目名称:TShock,代码行数:66,代码来源:TShock.cs


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