本文整理汇总了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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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));
}
}
示例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>");
}
}
}
}
}
}
示例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;
}
示例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)
{
//.........这里部分代码省略.........
示例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":
//.........这里部分代码省略.........