本文整理汇总了C#中ConsoleSystem.Player方法的典型用法代码示例。如果您正苦于以下问题:C# ConsoleSystem.Player方法的具体用法?C# ConsoleSystem.Player怎么用?C# ConsoleSystem.Player使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConsoleSystem
的用法示例。
在下文中一共展示了ConsoleSystem.Player方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConsoleGroup
private void ConsoleGroup(ConsoleSystem.Arg arg)
{
if (!PermissionsLoaded(arg)) return;
if (!IsAdmin(arg.Player())) return;
if (!arg.HasArgs(2))
{
Reply(arg.connection, "CommandUsageGroup");
return;
}
var mode = arg.GetString(0);
var name = arg.GetString(1);
if (mode.Equals("add"))
{
if (permission.GroupExists(name))
{
Reply(arg.connection, "GroupAlreadyExists", name);
return;
}
permission.CreateGroup(name, arg.GetString(2), arg.GetInt(3));
Reply(arg.connection, "GroupCreated", name);
}
else if (mode.Equals("remove"))
{
if (!permission.GroupExists(name))
{
Reply(arg.connection, "GroupNotFound", name);
return;
}
permission.RemoveGroup(name);
Reply(arg.connection, "GroupDeleted", name);
}
else if (mode.Equals("set"))
{
if (!permission.GroupExists(name))
{
Reply(arg.connection, "GroupNotFound", name);
return;
}
permission.SetGroupTitle(name, arg.GetString(2));
permission.SetGroupRank(name, arg.GetInt(3));
Reply(arg.connection, "GroupChanged", name);
}
else if (mode.Equals("parent"))
{
if (!permission.GroupExists(name))
{
Reply(arg.connection, "GroupNotFound", name);
return;
}
var parent = arg.GetString(2);
if (!string.IsNullOrEmpty(parent) && !permission.GroupExists(parent))
{
Reply(arg.connection, "GroupParentNotFound", parent);
return;
}
if (permission.SetGroupParent(name, parent))
Reply(arg.connection, "GroupParentChanged", name, parent);
else
Reply(arg.connection, "GroupParentNotChanged", name);
}
}
示例2: cmdList
private void cmdList(ConsoleSystem.Arg arg)
{
var sb = new StringBuilder();
var queryTeamOne = from player in playerTeam
where player.Value == Team.ONE
select player;
var queryTeamTwo = from player in playerTeam
where player.Value == Team.TWO
select player;
sb.Append("Team ONE:\n");
sb.Append("KILLS\t\tDEATHS\t\tPLAYER\n");
foreach (var player in queryTeamOne)
{
var playerID = player.Key;
int playerKills = -1;
int playerDeaths = -1;
if (playerStats.ContainsKey(playerID))
{
var stats = playerStats[playerID];
playerKills = stats.kills;
playerDeaths = stats.deaths;
}
var Bplayer = BasePlayer.FindByID(playerID);
sb.Append(playerKills.ToString().PadLeft(5));
sb.Append("\t\t");
sb.Append(playerDeaths.ToString().PadLeft(6));
sb.Append("\t\t");
sb.Append(Bplayer.displayName);
sb.Append("\n");
}
sb.Append("\n");
sb.Append("Team TWO:\n");
sb.Append("KILLS\t\tDEATHS\t\tPLAYER\n");
foreach (var player in queryTeamTwo)
{
var playerID = player.Key;
int playerKills = -1;
int playerDeaths = -1;
if (playerStats.ContainsKey(playerID))
{
var stats = playerStats[playerID];
playerKills = stats.kills;
playerDeaths = stats.deaths;
}
var Bplayer = BasePlayer.FindByID(playerID);
sb.Append(playerKills.ToString().PadLeft(5));
sb.Append("\t\t");
sb.Append(playerDeaths.ToString().PadLeft(6));
sb.Append("\t\t");
sb.Append(Bplayer.displayName);
sb.Append("\n");
}
PrintToConsole(arg.Player(), sb.ToString());
}
示例3: cmdVersion
private void cmdVersion(ConsoleSystem.Arg arg)
{
PrintToConsole(arg.Player(), Version.ToString());
}
示例4: OnRunCommand
private object OnRunCommand(ConsoleSystem.Arg arg)
{
if (arg?.cmd == null) return null;
if (arg.cmd.namefull != "chat.say") return null;
if (arg.connection != null)
{
if (arg.Player() == null) return true;
var rustCovalence = Libraries.Covalence.RustCovalenceProvider.Instance;
var livePlayer = rustCovalence.PlayerManager.GetOnlinePlayer(arg.connection.userid.ToString());
if (rustCovalence.CommandSystem.HandleChatMessage(livePlayer, arg.GetString(0))) return true;
}
// Get the args
var str = arg.GetString(0, "text");
if (str.Length == 0) return null;
// Is it a chat command?
if (str[0] == '/' || str[0] == '!')
{
// Get the message
var message = str.Substring(1);
// Parse it
string cmd;
string[] args;
ParseChatCommand(message, out cmd, out args);
if (cmd == null) return null;
// Handle it
var player = arg.connection.player as BasePlayer;
if (player == null)
Interface.Oxide.LogDebug("Player is actually a {0}!", arg.connection.player.GetType());
else
if (!cmdlib.HandleChatCommand(player, cmd, args)) ReplyWith(player.net.connection, "UnknownCommand", cmd);
// Handled
arg.ReplyWith(string.Empty);
return true;
}
// Default behavior
return null;
}
示例5: cmdHelp
private void cmdHelp(ConsoleSystem.Arg arg)
{
var sb = new StringBuilder();
sb.Append("TeamBattlefield Console Commands:\n\n");
sb.Append("tbf.list\t\t\tLists Teams and Disconnect Times of players.\n");
sb.Append("tbf.assign <PartialPlayerName> [one/two/spectator]\t\t\tAssigns player to team.\n");
sb.Append("tbf.purge\t\t\tRemoves players from all teams if they're been disconnected for more than 5 minutes.\n");
sb.Append("tbf.version\t\t\tPrints current version number of plugin.\n");
PrintToConsole(arg.Player(), sb.ToString());
}
示例6: cmdConsoleCount
void cmdConsoleCount(ConsoleSystem.Arg arg)
{
if (arg.Player() && !arg.Player().IsAdmin()) { SendReply(arg, "You need to be admin to use that command"); return; }
if (arg.Args == null || arg.Args.Length < 2) { SendReply(arg, "cc.count \"Deployable Item Name\" all => all the deployable items"); SendReply(arg, "cc.count \"Deployable Item Name\" world optional:XX => all the items that are not connected to a construction in XX radius (default is 3 meters)"); return; }
if (arg.Args[1] != "world" && arg.Args[1] != "all") { SendReply(arg, "cc.count \"Deployable Item Name\" all => all the deployable items"); SendReply(arg, "cc.count \"Deployable Item Name\" world optional:XX => all the items that are not connected to a construction in XX radius (default is 3 meters)"); return; }
switch (arg.Args[0].ToLower())
{
default:
string shortname = arg.Args[0].ToLower();
if (displaynameToShortname.ContainsKey(shortname))
shortname = displaynameToShortname[shortname];
else if (!displaynameToShortname.ContainsValue(shortname))
{
SendReply(arg, string.Format("{0} is not a valid item name", arg.Args[0]));
return;
}
Item newItem = ItemManager.CreateByName(shortname, 1);
if (newItem == null)
{
SendReply(arg, "Couldn't find this item, this shouldnt show ever ...");
return;
}
if (newItem.info.GetComponent<ItemModDeployable>() == null)
{
SendReply(arg, "This is not a item mod deployable item, this shouldnt show ever ...");
return;
}
Deployable deployable = newItem.info.GetComponent<ItemModDeployable>().entityPrefab.Get().GetComponent<Deployable>();
if (deployable == null)
{
SendReply(arg, "This is not a deployable item, this shouldnt show ever ...");
return;
}
string deployablename = deployable.gameObject.name + ".prefab";
bool shouldForce = (arg.Args[1] == "all") ? true : false;
float eraseRadius = 0.5f;
if (arg.Args.Length > 2) float.TryParse(arg.Args[2], out eraseRadius);
int cleared = 0;
foreach (Deployable deployed in UnityEngine.Resources.FindObjectsOfTypeAll<Deployable>())
{
var realEntity = deployed.GetComponent<BaseNetworkable>().net;
if (realEntity == null) continue;
if (deployed.gameObject.name.EndsWith(deployablename))
{
if (shouldRemove(deployed, shouldForce, eraseRadius))
{
cleared++;
}
}
}
SendReply(arg, string.Format("{1}: Found {0} entities that matchs your search", cleared.ToString(), shortname));
break;
}
}
示例7: cmdConsoleKitClose
void cmdConsoleKitClose(ConsoleSystem.Arg arg)
{
if (arg.connection == null)
{
SendReply(arg, "You can't use this command from the server console");
return;
}
DestroyAllGUI(arg.Player());
}
示例8: OnRunCommand
/////////////////////////////////////////
// OnRunCommand(ConsoleSystem.Arg arg)
// Called when a user executes a command
/////////////////////////////////////////
private object OnRunCommand(ConsoleSystem.Arg arg)
{
if (arg.Player() == null) return null;
if (arg.cmd?.name == null) return null;
if (arg.cmd.name == "kill" && HasPlayerFlag(arg.Player(), ZoneFlags.NoSuicide))
{
SendMessage(arg.Player(), "You are not allowed to suicide here");
return false;
}
return null;
}
示例9: Command
// chat.say().Hooks.Chat()
public static void Command(ConsoleSystem.Arg arg)
{
Player player = Server.GetPlayer(arg.Player());
string[] args = arg.ArgsStr.Substring(2, arg.ArgsStr.Length - 3).Replace("\\", "").Split(new string[]{ " " }, StringSplitOptions.None);
CommandEvent cmd = new CommandEvent(player, args);
if (cmd.cmd == "")
return;
foreach (KeyValuePair<string, BasePlugin> pl in PluginLoader.GetInstance().Plugins) {
ChatCommand[] commands = pl.Value.chatCommands.getChatCommands(cmd.cmd);
foreach (ChatCommand chatCmd in commands) {
if (chatCmd.callback == null)
continue;
CommandPermissionEvent permission = new CommandPermissionEvent(player, args, chatCmd);
OnCommandPermission.OnNext(permission);
if (permission.blocked) {
player.Message(permission.Reply);
continue;
}
try {
chatCmd.callback(cmd.args, player);
} catch (Exception ex) {
Logger.LogError(chatCmd.plugin.FormatException(ex));
}
}
}
OnCommand.OnNext(cmd);
if (cmd.Reply != "")
arg.ReplyWith(cmd.Reply);
}
示例10: ccmdZone
private void ccmdZone(ConsoleSystem.Arg arg)
{
var player = arg.Player();
if (!hasPermission(player, PermZone)) { SendMessage(player, "You don't have access to this command"); return; }
var zoneId = arg.GetString(0);
ZoneDefinition zoneDefinition;
if (!arg.HasArgs(3) || !ZoneDefinitions.TryGetValue(zoneId, out zoneDefinition)) { SendMessage(player, "Zone Id not found or Too few arguments: zone <zoneid> <arg> <value>"); return; }
var args = new string[arg.Args.Length - 1];
Array.Copy(arg.Args, 1, args, 0, args.Length);
UpdateZoneDefinition(zoneDefinition, args, player);
RefreshZone(zoneId);
//SaveData();
//ShowZone(player, zoneId);
}
示例11: OnPlayerChat
/////////////////////////////////////////
// OnPlayerChat(ConsoleSystem.Arg arg)
// Called when a user writes something in the chat, doesn't take in count the commands
/////////////////////////////////////////
private object OnPlayerChat(ConsoleSystem.Arg arg)
{
if (arg.Player() == null) return null;
if (HasPlayerFlag(arg.Player(), ZoneFlags.NoChat))
{
SendMessage(arg.Player(), "You are not allowed to chat here");
return false;
}
return null;
}
示例12: ChatConsoleCommand
private void ChatConsoleCommand(ConsoleSystem.Arg arg)
{
if (arg.Player() == null)
{
StringBuilder builder = new StringBuilder();
foreach (string value in arg.Args)
{
builder.Append(value);
builder.Append(" ");
}
string msg = string.Format("<size=16><color=lime>Server:</color><color=aqua> " + builder.ToString() + "</color></size>");
PrintToChat(msg);
msg = "";
return;
}
else
{
arg.ReplyWith("<color=red>No permission!</color>");
return;
}
}
示例13: ConsoleRevoke
private void ConsoleRevoke(ConsoleSystem.Arg arg)
{
if (!PermissionsLoaded(arg)) return;
if (!IsAdmin(arg.Player())) return;
if (!arg.HasArgs(3))
{
Reply(arg.connection, "CommandUsageRevoke");
return;
}
var mode = arg.GetString(0);
var name = arg.GetString(1);
var perm = arg.GetString(2);
if (!permission.PermissionExists(perm))
{
Reply(arg.connection, "PermissionNotFound", perm);
return;
}
if (mode.Equals("group"))
{
if (!permission.GroupExists(name))
{
Reply(arg.connection, "GroupNotFound", name);
return;
}
permission.RevokeGroupPermission(name, perm);
Reply(arg.connection, "GroupPermissionRevoked", name, perm);
}
else if (mode.Equals("user"))
{
var player = FindPlayer(name);
if (player == null && !permission.UserIdValid(name))
{
Reply(arg.connection, "UserNotFound", name);
return;
}
var userId = name;
if (player != null)
{
userId = player.UserIDString;
name = player.displayName;
permission.UpdateNickname(userId, name);
}
permission.RevokeUserPermission(userId, perm);
Reply(arg.connection, "UserPermissionRevoked", $"{name} ({userId})", perm);
}
}
示例14: ConsoleUserGroup
private void ConsoleUserGroup(ConsoleSystem.Arg arg)
{
if (!PermissionsLoaded(arg)) return;
if (!IsAdmin(arg.Player())) return;
if (!arg.HasArgs(3))
{
Reply(arg.connection, "CommandUsageUserGroup");
return;
}
var mode = arg.GetString(0);
var name = arg.GetString(1);
var group = arg.GetString(2);
var player = FindPlayer(name);
if (player == null && !permission.UserIdValid(name))
{
Reply(arg.connection, "UserNotFound", name);
return;
}
var userId = name;
if (player != null)
{
userId = player.UserIDString;
name = player.displayName;
permission.UpdateNickname(userId, name);
name += $"({userId})";
}
if (!permission.GroupExists(group))
{
Reply(arg.connection, "GroupNotFound", name);
return;
}
if (mode.Equals("add"))
{
permission.AddUserGroup(userId, group);
Reply(arg.connection, "UserAddedToGroup", name, group);
}
else if (mode.Equals("remove"))
{
permission.RemoveUserGroup(userId, group);
Reply(arg.connection, "UserRemovedFromGroup", name, group);
}
}
示例15: cmdUnload
private void cmdUnload(ConsoleSystem.Arg arg)
{
if (arg.Player() != null && !arg.Player().IsAdmin()) return;
// Check arg 1 exists
if (!arg.HasArgs())
{
arg.ReplyWith("Syntax: oxide.unload *|<pluginname>+");
return;
}
if (arg.GetString(0).Equals("*"))
{
Interface.Oxide.UnloadAllPlugins();
return;
}
foreach (var name in arg.Args)
{
if (string.IsNullOrEmpty(name)) continue;
// Unload
Interface.Oxide.UnloadPlugin(name);
}
}