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


C# BasePlayer.IsAdmin方法代码示例

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


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

示例1: canExecute

 /*--------------------------------------------------------------//
 //		canExecute - check if the player has permission			//
 //--------------------------------------------------------------*/
 private bool canExecute(BasePlayer player)
 {
     if (!player.IsAdmin())			//if permissions system is not in use, check for admin
     {
         SendReply(player, "You do not have access to this command.");
         return false;
     }
     return true;
 }
开发者ID:anthok,项目名称:RustPlugins,代码行数:12,代码来源:WarzoneWipeday.cs

示例2: ChangeBuildingGrade

        void ChangeBuildingGrade(BasePlayer player, bool increment)
        {
            if (!player.IsAdmin())
            {
                SendReply(player, "<color=red>Only admins may use that command</color>");
                return;
            }

            var initial_block = GetTargetBuildingBlock(player);
            if (!initial_block)
            {
                SendReply(player, "<color=red>You are not looking at a building block!</color>");
                return;
            }

            var all_blocks = new HashSet<BuildingBlock>();
            all_blocks.Add(initial_block);

            Action<BuildingBlock> queue_attached_blocks = null;
            queue_attached_blocks = (building_block) =>
            {
                foreach (var collider in Physics.OverlapSphere(building_block.transform.position, 3.5f))
                {
                    var next_block = collider.GetComponentInParent<BuildingBlock>();
                    if (!next_block || !all_blocks.Add(next_block)) continue;
                    queue_attached_blocks(next_block);
                }
            };
            queue_attached_blocks(initial_block);

            foreach (var building_block in all_blocks)
            {
                var target_grade = NextBlockGrade(building_block, increment ? 1 : -1);
                if (target_grade == (int)building_block.grade) continue;

                building_block.SetGrade((BuildingGrade.Enum)target_grade);
                building_block.SetHealthToMax();
                building_block.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
            }
        }
开发者ID:SteveKnowless,项目名称:Rust,代码行数:40,代码来源:BuildingGrades.cs

示例3: OnPlayerRespawned

        private void OnPlayerRespawned(BasePlayer player)
        {
            if (playerTeam.ContainsKey(player.userID))
            {
                if (playerTeam[player.userID] == Team.SPECTATOR || (isAdminExempt && player.IsAdmin())) return;    //By-pass item giving if player is admin or spectator
                if (persistence_mode)
                {

                }
                else {
                try
                {
                    // Spawns Database functionality
                    if (SpawnsDatabase != null)
                    {
                        var loadFile1Status = SpawnsDatabase.Call("loadSpawnfile", (string) Config["TeamOneSpawnfile"]);
                        var loadFile2Status = SpawnsDatabase.Call("loadSpawnfile", (string) Config["TeamTwoSpawnfile"]);
                        if (loadFile1Status is string || loadFile2Status is string )
                        {
                            PrintWarning("Correct spawn files not found.");
                        }
                        else
                        {
                            Vector3 spawnPoint = (Vector3)GetSpawnPoint(player);
                            ForcePlayerPosition(player, spawnPoint);
                            Puts("{0} spawned using Spawns Database, to position {1}", player.displayName, spawnPoint.ToString());
                        }
                    }
                } catch (InvalidCastException ex)
                {
                    PrintWarning("InvalidCastException on Spawns Database. Please report to plugin developer.");
                }
                }
                //Puts("Entered OnPlayerRespawned. Player team is " + playerTeam[player.userID].ToString());
                if (!persistence_mode)
                {
                    player.inventory.Strip();
                }
                var common_item_wear = (Dictionary<string, object>) Config["common_items_wear"];
                foreach (var item in common_item_wear)
                {
                    GiveItem(player, item.Key, (int) item.Value, player.inventory.containerWear);
                }
                var common_item_belt = (Dictionary<string, object>) Config["common_items_belt"];
                foreach (var item in common_item_belt)
                {
                    GiveItem(player, item.Key, (int) item.Value, player.inventory.containerBelt);
                }
                var common_item_main = (Dictionary<string, object>) Config["common_items_main"];
                foreach (var item in common_item_main)
                {
                    GiveItem(player, item.Key, (int) item.Value, player.inventory.containerMain);
                }
                if (playerTeam[player.userID] == Team.ONE)
                {
                    GiveItem(player, TeamOneShirt, 1, player.inventory.containerWear);
                }
                else if (playerTeam[player.userID] == Team.TWO)
                {
                    GiveItem(player, TeamTwoShirt, 1, player.inventory.containerWear);
                }

            }
            else
            {
                OnPlayerInit(player);
            }
        }
开发者ID:bodyweightenergy,项目名称:TeamBattlefield,代码行数:68,代码来源:TeamBattlefield.cs

示例4: OnPlayerInit

 //private void OnPlayerAttack(BasePlayer player, HitInfo hitInfo)
 //{
 //    Puts("OnPlayerAttack() called.");  //for debug purposes
 //    if (hitInfo.HitEntity is BasePlayer && hitInfo.Initiator is BasePlayer)
 //    {
 //        var victimPlayer = (BasePlayer) hitInfo.HitEntity;
 //        //float damageScale = 1.0f;
 //        var sb = new StringBuilder();
 //        if (player == null || hitInfo == null) return;
 //        var attackerPlayer = (BasePlayer)hitInfo.Initiator;
 //        var victimID = victimPlayer.userID;
 //        var attackerID = attackerPlayer.userID;
 //        if (playerTeam.ContainsKey(victimID) && playerTeam.ContainsKey(attackerID))
 //        {
 //            if (victimID != attackerID)  //Don't modify if attack is suicide
 //            {
 //                if (playerTeam[victimID] == playerTeam[attackerID]) // Modify damage if both attacker and victim are on same team
 //                {
 //                    hitInfo.damageTypes.ScaleAll(damageScale);
 //                    sb.Append("Friendly Fire!");
 //                }
 //            }
 //        }
 //        SendReply(hitInfo.Initiator as BasePlayer, sb.ToString());
 //    }
 //}
 //private void IOnBasePlayerAttacked(BasePlayer player, HitInfo hitInfo)
 //{
 //    Puts("IOnBasePlayerAttacked() was called.");
 //}
 private void OnPlayerInit(BasePlayer player)
 {
     Team team = getTeamForBalance();
     if (player.IsAdmin() && isAdminExempt) { team = Team.SPECTATOR; }    // By-pass team assignment if player is admin
     if(persistence_mode)
     {
         if(!playerTeam.ContainsKey(player.userID))
         {
             AssignPlayerToTeam(player, team);
         }
     }
     else {
         AssignPlayerToTeam(player, team);
     }
     if (!playerStats.ContainsKey(player.userID)) { playerStats.Add(player.userID, new PlayerStats()); }
     OnPlayerRespawned(player);
 }
开发者ID:bodyweightenergy,项目名称:TeamBattlefield,代码行数:47,代码来源:TeamBattlefield.cs

示例5: LevelUpChatHandler

 private void LevelUpChatHandler(BasePlayer player, string[] args, RPGInfo rpgInfo)
 {
     if (!player.IsAdmin()) return;
     var callerPlayer = player;
     int commandArgs = args.Length - 1;
     if (commandArgs > 2 && commandArgs < 1)
         InvalidCommand(player, args);
     else
     {
         int levelIndex = 1;
         if (commandArgs  == 2)
         {
             levelIndex = 2;
             string playerToSearch = args[1].ToLower();
             var activePlayerList = BasePlayer.activePlayerList;
             var playersFound = (from basePlayer in activePlayerList let displayName = basePlayer.displayName.ToLower() where displayName.Equals(playerToSearch) select basePlayer).ToDictionary(basePlayer => basePlayer.displayName);
             if (playersFound.Count > 1)
             {
                 var playerFoundNames = String.Join(",", playersFound.Select(basePlayer => basePlayer.Key).ToArray());
                 ChatMessage(callerPlayer, String.Format("Multiple players found. {0}", playerFoundNames));
                 return;
             }
             if (playersFound.Count == 0)
             {
                 ChatMessage(callerPlayer, "No player found with that name!");
                 return;
             }
             player = playersFound.First().Value;
             rpgInfo = RPGInfo(player);
         }
         int desiredLevel;
         if (!Int32.TryParse(args[levelIndex], out desiredLevel))
         {
             InvalidCommand(callerPlayer, args);
             return;
         }
         if (desiredLevel <= rpgInfo.Level) return;
         LevelUpPlayer(rpgInfo, desiredLevel);
         NotifyLevelUp(player, rpgInfo);
         if (callerPlayer != player)
             ChatMessage(callerPlayer, String.Format("Player {0} lvlup to {1}", player, desiredLevel));
     }
 }
开发者ID:Zloplay,项目名称:hunt,代码行数:43,代码来源:HuntRPG.cs

示例6: OnPlayerInput

        //Oxide Hook
        void OnPlayerInput(BasePlayer player, InputState input)
        {
            if (this.allowAdminRotate && player.IsAdmin() && player.GetActiveItem() != null && player.GetActiveItem().info.shortname.Equals("hammer"))
            {
                if (input.WasJustPressed(BUTTON.FIRE_PRIMARY))
                {
                    RaycastHit hit;
                    if (Physics.Raycast(player.eyes.position, (player.eyes.rotation * Vector3.forward), out hit, 2f, Layers.Server.Buildings))
                    {
                        BaseEntity baseEntity = hit.collider.gameObject.ToBaseEntity();
                        if (baseEntity != null)
                        {
                            BuildingBlock block = baseEntity.GetComponent<BuildingBlock>();
                            if (block != null && block.blockDefinition.canRotate && !this.instanceIDs.Contains(block.GetInstanceID()))
                            {
                                block.SetFlag(BaseEntity.Flags.Reserved1, true);
                                addBlockToLists(block.GetInstanceID(), DateTime.Now.AddMinutes(-this.amountOfMinutesAfterUpgrade).ToString());

                                int remainingSeconds = timerInterval - DateTime.Now.Subtract(lastTimerTick).Seconds;
                                SendReply(player, "<color=green>You can now rotate this " + block.blockDefinition.info.name.english + " for " + remainingSeconds +  " seconds.</color>");
                            }
                        }
                    }
                }
            }
        }
开发者ID:SHOrdr,项目名称:Rust,代码行数:27,代码来源:RotateOnUpgrade.cs

示例7: canExecute

		/*--------------------------------------------------------------//
		//		canExecute - check if the player has permission			//
		//--------------------------------------------------------------*/
		private bool canExecute(BasePlayer player)
		{
			if ((bool)Config["UsePermissions"])	//check if permissions system is in use
			{
				if (!permission.UserHasPermission(player.userID.ToString(), "CanCallHeli")) 
				{
					SendReply(player, "You do not have permission for this command.");
					return false;
				}
			}
			else
			{
				if (!player.IsAdmin())			//if permissions system is not in use, check for admin
				{
					SendReply(player, "You do not have access to this command.");
					return false;
				}
			}
			return true;
		}
开发者ID:koenrad,项目名称:Oxide-2.0-Plugins,代码行数:23,代码来源:HeliControl.cs

示例8: cmdChatSky

        void cmdChatSky(BasePlayer player, string command, string[] args)
        {
            if (args.Length > 0)
            {
                if (args[0] == "join")
                {
                    EventJoin(player);
                }
                else if (args[0] == "leave")
                {
                    EventCommandLeave(player);
                }
                else if (args[0] == "info")
                {
                    skyInfo(player);
                }
                else if (args[0] == "reward")
                {
                    EventReward(player);
                }
                else if (args[0] == "help")
                {
                    if (player.IsAdmin())
                    {
                        PrintChat(player, "/sky settings set position");
                        PrintChat(player, "/sky settings get position");

                        PrintChat(player, "/sky admin lobby");
                        PrintChat(player, "/sky admin start");
                        PrintChat(player, "/sky admin end");
                        PrintChat(player, "/sky admin cleanup");
                        PrintChat(player, "/sky admin spawn");
                        PrintChat(player, "/sky admin winner-test");
                    }

                    PrintChat(player, "/sky join");
                    PrintChat(player, "/sky leave");
                    PrintChat(player, "/sky info");
                }
                else if (args[0] == "admin")
                {
                    if (player.IsAdmin())
                    {
                        if (args.Length > 1)
                        {
                            switch (args[1])
                            {
                                case "goto-position":
                                    TeleportPlayerPosition(player, getEventPosition());
                                    break;

                                case "winner-test":
                                    weGotaWinner(player);
                                    break;

                                case "lobby":
                                    eventOpenLobby(false);
                                    break;

                                case "cleanup":
                                    clearGUI();
                                    eventCleanupForced();

                                    var objects = UnityEngine.GameObject.FindObjectsOfType<EventWinner>();

                                    if (objects != null)
                                    {
                                        foreach (EventWinner gameObj in objects)
                                        {
                                            if (gameObj != null)
                                            {
                                                UnityEngine.GameObject.Destroy(gameObj);
                                            }
                                        }
                                    }
                                    break;

                                case "movedown":
                                    //spawnSkyEvent();
                                    moveSkyEventDown();
                                    PrintChat(player, "Moved SkyEvent platform down");
                                    break;

                                case "moveup":
                                    //spawnSkyEvent();
                                    moveSkyEventUp();
                                    PrintChat(player, "Moved SkyEvent platform up");
                                    break;

                                case "test":
                                    timer.Once(1, () =>
                                    {
                                        var winners = GameObject.FindObjectsOfType<EventWinner>();

                                        if (winners != null)
                                        {
                                            foreach (EventWinner gameObj in winners)
                                            {
                                                if (gameObj != null)
                                                {
//.........这里部分代码省略.........
开发者ID:danniehansen,项目名称:EdgePlugins,代码行数:101,代码来源:SkyEvent.cs

示例9: cmdROF

        private void cmdROF(BasePlayer player, string command, string[] args)
        {
            if (!player.IsAdmin() || args.Length == 0)
            {
                SendReply(player, "/rof onplayer <opt:playername> - Calls a event on your position, or the player specified");
                SendReply(player, "/rof onplayer_extreme <opt:playername> - Starts a extreme event on your position, or the player specified");
                SendReply(player, "/rof onplayer_mild <opt:playername> - Starts a optimal event on your position, or the player specified");
                SendReply(player, "/rof barrage - Fire a barrage of rockets from your position");
                SendReply(player, "/rof random - Calls a event at a random postion");
                SendReply(player, "/rof intervals <amount> - Change the time between events");
                SendReply(player, "/rof damagescale <amount> - Change the damage scale");
                SendReply(player, "/rof togglemsg - Toggle public event broadcast");
                return;
            }
                

            switch (args[0].ToLower())
            {
                case "onplayer":
                    if (args.Length == 2)
                    {
                        if (StartOnPlayer(args[1], configData.z_IntensitySettings.Settings_Optimal))
                            SendReply(player, "Event called on " + args[1] + "'s position");
                        else
                            SendReply(player, "No player found with that name");
                    }
                    else
                    {
                        StartRainOfFire(player.transform.position, configData.z_IntensitySettings.Settings_Optimal);
                        SendReply(player, "Event called on your position");
                    }
                    break;

                case "onplayer_extreme":
                    if (args.Length == 2)
                    {
                        if (StartOnPlayer(args[1], configData.z_IntensitySettings.Settings_Extreme))
                            SendReply(player, "Extreme event called on " + args[1] + "'s position");
                        else
                            SendReply(player, "No player found with that name");
                    }
                    else
                    {
                        StartRainOfFire(player.transform.position, configData.z_IntensitySettings.Settings_Extreme);
                        SendReply(player, "Extreme event called on your position");
                    }
                    break;

                case "onplayer_mild":
                    if (args.Length == 2)
                    {
                        if (StartOnPlayer(args[1], configData.z_IntensitySettings.Settings_Mild))
                            SendReply(player, "Mild event called on " + args[1] + "'s position");
                        else
                            SendReply(player, "No player found with that name");
                    }
                    else
                    {
                        StartRainOfFire(player.transform.position, configData.z_IntensitySettings.Settings_Mild);
                        SendReply(player, "Mild event called on your position");
                    }
                    break;

                case "barrage":
                    StartBarrage(player.eyes.position + player.eyes.HeadForward() * 1f, player.eyes.HeadForward());
                    break;

                case "random":
                    StartRandomOnMap();
                    SendReply(player, "Event called on random position");
                    break;

                case "intervals":
                    if (args.Length > 1)
                    {
                        int newIntervals;
                        bool isValid;
                        isValid = int.TryParse(args[1], out newIntervals);

                        if (isValid)
                        {
                            if (newIntervals >= 4 || newIntervals == 0)
                            {
                                SetIntervals(newIntervals);
                                SendReply(player, $"Event intervals set to {newIntervals} minutes");
                                StopTimer();
                                StartEventTimer();
                            }
                            else
                            {
                                SendReply(player, $"Event intervals under 4 minutes are not allowed");
                            }
                        }
                        else
                        {
                            SendReply(player, "Invalid parameter '" + args[1] + "'");
                        }
                    }
                    break;
                case "droprate":
//.........这里部分代码省略.........
开发者ID:Arkoudaphobia,项目名称:ArkoudaphobiaConfig,代码行数:101,代码来源:RainOfFire.cs


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