public static void players(ConsoleSystem.Arg arg) { TextTable textTable = new TextTable(); textTable.AddColumn("id"); textTable.AddColumn("name"); textTable.AddColumn("ping"); textTable.AddColumn("snap"); textTable.AddColumn("updt"); textTable.AddColumn("posi"); textTable.AddColumn("dist"); foreach (BasePlayer basePlayer in BasePlayer.activePlayerList) { string userIDString = basePlayer.UserIDString; string str = basePlayer.displayName.ToString(); if (str.Length >= 14) { str = string.Concat(str.Substring(0, 14), ".."); } string str1 = str; int averagePing = Network.Net.sv.GetAveragePing(basePlayer.net.connection); string str2 = averagePing.ToString(); string str3 = basePlayer.GetQueuedUpdateCount(BasePlayer.NetworkQueue.Update).ToString(); string str4 = basePlayer.GetQueuedUpdateCount(BasePlayer.NetworkQueue.UpdateDistance).ToString(); textTable.AddRow(new string[] { userIDString, str1, str2, string.Empty, str3, string.Empty, str4 }); } arg.ReplyWith(textTable.ToString()); }
public static void print_assets(ConsoleSystem.Arg arg) { if (AssetPool.storage.Count == 0) { arg.ReplyWith("Asset pool is empty."); return; } string str = arg.GetString(0, string.Empty); TextTable textTable = new TextTable(); textTable.AddColumn("type"); textTable.AddColumn("allocated"); textTable.AddColumn("available"); foreach (KeyValuePair <Type, AssetPool.Pool> keyValuePair in AssetPool.storage) { string str1 = keyValuePair.Key.ToString(); string str2 = keyValuePair.Value.allocated.ToString(); string str3 = keyValuePair.Value.available.ToString(); if (!string.IsNullOrEmpty(str) && !str1.Contains(str, CompareOptions.IgnoreCase)) { continue; } textTable.AddRow(new string[] { str1, str2, str3 }); } arg.ReplyWith(textTable.ToString()); }
public static string teaminfo(Arg arg) { ulong num = arg.GetUInt64(0, 0uL); if (num == 0L) { BasePlayer player = ArgEx.GetPlayer(arg, 0); if (player == null) { return("Player not found"); } num = player.userID; } RelationshipManager.PlayerTeam playerTeam = RelationshipManager.ServerInstance.FindPlayersTeam(num); if (playerTeam == null) { return("Player is not in a team"); } TextTable textTable = new TextTable(); textTable.AddColumn("steamID"); textTable.AddColumn("username"); textTable.AddColumn("online"); textTable.AddColumn("leader"); foreach (ulong memberId in playerTeam.members) { bool flag = Network.Net.sv.connections.FirstOrDefault((Connection c) => c.connected && c.userid == memberId) != null; textTable.AddRow(memberId.ToString(), GetPlayerName(memberId), flag ? "x" : "", (memberId == playerTeam.teamLeader) ? "x" : ""); } return(textTable.ToString()); }
public static void players(Arg arg) { TextTable textTable = new TextTable(); textTable.AddColumn("id"); textTable.AddColumn("name"); textTable.AddColumn("ping"); textTable.AddColumn("snap"); textTable.AddColumn("updt"); textTable.AddColumn("posi"); textTable.AddColumn("dist"); foreach (BasePlayer activePlayer in BasePlayer.activePlayerList) { string userIDString = activePlayer.UserIDString; string text = activePlayer.displayName.ToString(); if (text.Length >= 14) { text = text.Substring(0, 14) + ".."; } string text2 = text; string text3 = Network.Net.sv.GetAveragePing(activePlayer.net.connection).ToString(); string text4 = activePlayer.GetQueuedUpdateCount(BasePlayer.NetworkQueue.Update).ToString(); string text5 = activePlayer.GetQueuedUpdateCount(BasePlayer.NetworkQueue.UpdateDistance).ToString(); textTable.AddRow(userIDString, text2, text3, string.Empty, text4, string.Empty, text5); } arg.ReplyWith(textTable.ToString()); }
public static void print_memory(ConsoleSystem.Arg arg) { if (Facepunch.Pool.directory.Count == 0) { arg.ReplyWith("Memory pool is empty."); return; } TextTable textTable = new TextTable(); textTable.AddColumn("type"); textTable.AddColumn("pooled"); textTable.AddColumn("active"); textTable.AddColumn("hits"); textTable.AddColumn("misses"); textTable.AddColumn("spills"); foreach (KeyValuePair <Type, Facepunch.Pool.ICollection> keyValuePair in from x in Facepunch.Pool.directory orderby x.Value.ItemsCreated descending select x) { string str = keyValuePair.Key.ToString().Replace("System.Collections.Generic.", ""); Facepunch.Pool.ICollection value = keyValuePair.Value; textTable.AddRow(new string[] { str, value.ItemsInStack.FormatNumberShort(), value.ItemsInUse.FormatNumberShort(), value.ItemsTaken.FormatNumberShort(), value.ItemsCreated.FormatNumberShort(), value.ItemsSpilled.FormatNumberShort() }); } arg.ReplyWith(textTable.ToString()); }
public static void scalars(ConsoleSystem.Arg args) { TextTable textTable = new TextTable(); textTable.AddColumn("Type"); textTable.AddColumn("Value"); string[] str = new string[] { "Player Fraction", null }; float single = SpawnHandler.PlayerFraction(); str[1] = single.ToString(); textTable.AddRow(str); string[] strArrays = new string[] { "Player Excess", null }; single = SpawnHandler.PlayerExcess(); strArrays[1] = single.ToString(); textTable.AddRow(strArrays); string[] str1 = new string[] { "Population Rate", null }; single = SpawnHandler.PlayerLerp(Spawn.min_rate, Spawn.max_rate); str1[1] = single.ToString(); textTable.AddRow(str1); string[] strArrays1 = new string[] { "Population Density", null }; single = SpawnHandler.PlayerLerp(Spawn.min_density, Spawn.max_density); strArrays1[1] = single.ToString(); textTable.AddRow(strArrays1); string[] str2 = new string[] { "Group Rate", null }; single = SpawnHandler.PlayerScale(Spawn.player_scale); str2[1] = single.ToString(); textTable.AddRow(str2); args.ReplyWith(textTable.ToString()); }
public static void print_assets(Arg arg) { if (AssetPool.storage.Count == 0) { arg.ReplyWith("Asset pool is empty."); return; } string @string = arg.GetString(0, string.Empty); TextTable textTable = new TextTable(); textTable.AddColumn("type"); textTable.AddColumn("allocated"); textTable.AddColumn("available"); foreach (KeyValuePair <Type, AssetPool.Pool> item in AssetPool.storage) { string text = item.Key.ToString(); string text2 = item.Value.allocated.ToString(); string text3 = item.Value.available.ToString(); if (string.IsNullOrEmpty(@string) || text.Contains(@string, CompareOptions.IgnoreCase)) { textTable.AddRow(text, text2, text3); } } arg.ReplyWith(textTable.ToString()); }
public void TextTable_NoHeaders() { TextTable table; table = new TextTable(); Assert.AreEqual("", table.ToString()); table = new TextTable(); table.AppendRow(1); Assert.AreEqual("1\r\n", table.ToString()); table = new TextTable(); table.AppendRow(1, 2); Assert.AreEqual("1 2\r\n", table.ToString()); table = new TextTable(); table.AppendRow(1, 2, 3); Assert.AreEqual("1 2 3\r\n", table.ToString()); table = new TextTable(); table.AppendRow(100); table.AppendRow(200, 201); table.AppendRow(300, 301, 302); Assert.AreEqual("100\r\n200 201\r\n300 301 302\r\n", table.ToString()); table = new TextTable(); table.AppendRow("a"); table.AppendRow(200, 201); table.AppendRow(300, 301, 302); Assert.AreEqual("a \r\n200 201\r\n300 301 302\r\n", table.ToString()); }
public static void print_prefabs(Arg arg) { PrefabPoolCollection pool = GameManager.server.pool; if (pool.storage.Count == 0) { arg.ReplyWith("Prefab pool is empty."); return; } string @string = arg.GetString(0, string.Empty); TextTable textTable = new TextTable(); textTable.AddColumn("id"); textTable.AddColumn("name"); textTable.AddColumn("count"); foreach (KeyValuePair <uint, PrefabPool> item in pool.storage) { string text = item.Key.ToString(); string text2 = StringPool.Get(item.Key); string text3 = item.Value.Count.ToString(); if (string.IsNullOrEmpty(@string) || text2.Contains(@string, CompareOptions.IgnoreCase)) { textTable.AddRow(text, Path.GetFileNameWithoutExtension(text2), text3); } } arg.ReplyWith(textTable.ToString()); }
public static void find_id(ConsoleSystem.Arg args) { uint num = args.GetUInt(0, 0); TextTable entityTable = Entity.GetEntityTable((Entity.EntityInfo info) => info.entityID == num); args.ReplyWith(entityTable.ToString()); }
public static string rpclog(Arg arg) { if (!rpclog_enabled) { return("RPC log is not enabled."); } List <Tuple <uint, ulong> > list = new List <Tuple <uint, ulong> >(); foreach (KeyValuePair <uint, TimeAverageValue> item in SingletonComponent <ServerMgr> .Instance.rpcHistory.dict) { list.Add(new Tuple <uint, ulong>(item.Key, item.Value.Calculate())); } TextTable textTable = new TextTable(); textTable.AddColumn("id"); textTable.AddColumn("name"); textTable.AddColumn("calls"); foreach (Tuple <uint, ulong> item2 in list.OrderByDescending((Tuple <uint, ulong> entry) => entry.Item2)) { if (item2.Item2 == 0L) { break; } string text = item2.Item1.ToString(); string text2 = StringPool.Get(item2.Item1); string text3 = item2.Item2.ToString(); textTable.AddRow(text, text2, text3); } return(textTable.ToString()); }
public static string packetlog(Arg arg) { if (!packetlog_enabled) { return("Packet log is not enabled."); } List <Tuple <Message.Type, ulong> > list = new List <Tuple <Message.Type, ulong> >(); foreach (KeyValuePair <Message.Type, TimeAverageValue> item in SingletonComponent <ServerMgr> .Instance.packetHistory.dict) { list.Add(new Tuple <Message.Type, ulong>(item.Key, item.Value.Calculate())); } TextTable textTable = new TextTable(); textTable.AddColumn("type"); textTable.AddColumn("calls"); foreach (Tuple <Message.Type, ulong> item2 in list.OrderByDescending((Tuple <Message.Type, ulong> entry) => entry.Item2)) { if (item2.Item2 == 0L) { break; } string text = item2.Item1.ToString(); string text2 = item2.Item2.ToString(); textTable.AddRow(text, text2); } return(textTable.ToString()); }
public static void print_approved_skins(ConsoleSystem.Arg arg) { if (!SteamServer.IsValid) { return; } if (SteamInventory.Definitions == null) { return; } TextTable textTable = new TextTable(); textTable.AddColumn("name"); textTable.AddColumn("itemshortname"); textTable.AddColumn("workshopid"); textTable.AddColumn("workshopdownload"); InventoryDef[] definitions = SteamInventory.Definitions; for (int i = 0; i < (int)definitions.Length; i++) { InventoryDef inventoryDef = definitions[i]; string name = inventoryDef.Name; string property = inventoryDef.GetProperty("itemshortname"); string str = inventoryDef.GetProperty("workshopid"); string property1 = inventoryDef.GetProperty("workshopdownload"); textTable.AddRow(new string[] { name, property, str, property1 }); } arg.ReplyWith(textTable.ToString()); }
private void ListCategoryItemsCommand(IPlayer player, string command, string[] args) { if (args.Length != 1) { player.Reply(string.Format(GetMessage("NotEnoughArguments", player.Id), 1)); } ItemCategory itemCategory = (ItemCategory)Enum.Parse(typeof(ItemCategory), args[0]); if (itemCategory.IsNull <ItemCategory>()) { player.Reply(GetMessage("InvalidCategory", player.Id)); } TextTable output = new TextTable(); output.AddColumns("Unique Id", "Shortname", "Category", "Vanilla Stack", "Custom Stack", "Multiplier"); foreach (ItemDefinition itemDefinition in ItemManager.GetItemDefinitions() .Where(itemDefinition => itemDefinition.category == itemCategory)) { ItemInfo itemInfo = GetIndexedItem(itemDefinition.category, itemDefinition.itemid); output.AddRow(itemDefinition.itemid.ToString(), itemDefinition.shortname, itemDefinition.category.ToString(), itemInfo.VanillaStackSize.ToString("N0"), Mathf.Clamp(GetStackSize(itemDefinition), 0, int.MaxValue).ToString("N0"), _config.CategoryStackMultipliers[itemDefinition.category.ToString()].ToString()); } player.Reply(output.ToString()); }
private void ItemSearchCommand(IPlayer player, string command, string[] args) { if (args.Length != 1) { player.Reply( string.Format(GetMessage("NotEnoughArguments", player.Id), 1)); } List <ItemDefinition> itemDefinitions = ItemManager.itemList.Where(itemDefinition => itemDefinition.displayName.english.Contains(args[0]) || itemDefinition.displayDescription.english.Contains(args[0]) || itemDefinition.shortname.Equals(args[0]) || itemDefinition.shortname.Contains(args[0])) .ToList(); TextTable output = new TextTable(); output.AddColumns("Unique Id", "Shortname", "Category", "Vanilla Stack", "Custom Stack"); foreach (ItemDefinition itemDefinition in itemDefinitions) { ItemInfo itemInfo = GetIndexedItem(itemDefinition.category, itemDefinition.itemid); output.AddRow(itemDefinition.itemid.ToString(), itemDefinition.shortname, itemDefinition.category.ToString(), itemInfo.VanillaStackSize.ToString("N0"), Mathf.Clamp(GetStackSize(itemDefinition), 0, int.MaxValue).ToString("N0")); } player.Reply(output.ToString()); }
private static void SaveComprCounters(Compressor compr, string destDir) { TextTable table = new TextTable { DefaultAlignment = HorizontalTextAlignment.Right, ColumnSpacing = 3, MaxWidth = int.MaxValue }; compr.ComputeCounterTotals(); int rownum = 0; int indent_prev = 0; foreach (var key in compr.Counters.Keys.Order()) { int indent = 4 * key.ToCharArray().Count(c => c == '|'); if (indent < indent_prev) { rownum++; } indent_prev = indent; table.SetCell(0, rownum, new string(' ', indent) + key.Split('|').Last(), alignment: HorizontalTextAlignment.Left); table.SetCell(1, rownum, Math.Round(compr.Counters[key], 3).ToString("#,0")); rownum++; } File.WriteAllText(Path.Combine(destDir, "counters.txt"), table.ToString()); }
public static void print_prefabs(ConsoleSystem.Arg arg) { PrefabPoolCollection prefabPoolCollection = GameManager.server.pool; if (prefabPoolCollection.storage.Count == 0) { arg.ReplyWith("Prefab pool is empty."); return; } string str = arg.GetString(0, string.Empty); TextTable textTable = new TextTable(); textTable.AddColumn("id"); textTable.AddColumn("name"); textTable.AddColumn("count"); foreach (KeyValuePair <uint, PrefabPool> keyValuePair in prefabPoolCollection.storage) { string str1 = keyValuePair.Key.ToString(); string str2 = StringPool.Get(keyValuePair.Key); string str3 = keyValuePair.Value.Count.ToString(); if (!string.IsNullOrEmpty(str) && !str2.Contains(str, CompareOptions.IgnoreCase)) { continue; } textTable.AddRow(new string[] { str1, Path.GetFileNameWithoutExtension(str2), str3 }); } arg.ReplyWith(textTable.ToString()); }
private void CommandGetComponents(IPlayer player, string command, string[] args) { var basePlayer = player.Object as BasePlayer; if (basePlayer == null) { return; } float radius; if (args.Length < 1 || !float.TryParse(args[0], out radius)) { radius = 5f; } var output = new List <Component>(); Vis.Components(basePlayer.transform.position, radius, output); var table = new TextTable(); table.AddColumns("name", "class"); foreach (var entry in output) { table.AddRow(entry.name, entry.GetType().FullName); } basePlayer.ConsoleMessage(table.ToString()); }
public static void find_id(Arg args) { uint filter = args.GetUInt(0); TextTable entityTable = GetEntityTable((EntityInfo info) => info.entityID == filter); args.ReplyWith(entityTable.ToString()); }
public static void find_entity(Arg args) { string filter = args.GetString(0); TextTable entityTable = GetEntityTable((EntityInfo info) => string.IsNullOrEmpty(filter) || info.entity.PrefabName.Contains(filter)); args.ReplyWith(entityTable.ToString()); }
public static void status(Arg arg) { string @string = arg.GetString(0); string text = string.Empty; if (@string.Length == 0) { text = text + "hostname: " + Server.hostname + "\n"; text = text + "version : " + 2306 + " secure (secure mode enabled, connected to Steam3)\n"; text = text + "map : " + Server.level + "\n"; text += $"players : {BasePlayer.activePlayerList.Count()} ({Server.maxplayers} max) ({SingletonComponent<ServerMgr>.Instance.connectionQueue.Queued} queued) ({SingletonComponent<ServerMgr>.Instance.connectionQueue.Joining} joining)\n\n"; } TextTable textTable = new TextTable(); textTable.AddColumn("id"); textTable.AddColumn("name"); textTable.AddColumn("ping"); textTable.AddColumn("connected"); textTable.AddColumn("addr"); textTable.AddColumn("owner"); textTable.AddColumn("violation"); textTable.AddColumn("kicks"); foreach (BasePlayer activePlayer in BasePlayer.activePlayerList) { try { if (!BaseEntityEx.IsValid(activePlayer)) { continue; } string userIDString = activePlayer.UserIDString; if (activePlayer.net.connection == null) { textTable.AddRow(userIDString, "NO CONNECTION"); continue; } string text2 = activePlayer.net.connection.ownerid.ToString(); string text3 = activePlayer.displayName.QuoteSafe(); string text4 = Network.Net.sv.GetAveragePing(activePlayer.net.connection).ToString(); string text5 = activePlayer.net.connection.ipaddress; string text6 = activePlayer.violationLevel.ToString("0.0"); string text7 = activePlayer.GetAntiHackKicks().ToString(); if (!arg.IsAdmin && !arg.IsRcon) { text5 = "xx.xxx.xx.xxx"; } string text8 = activePlayer.net.connection.GetSecondsConnected() + "s"; if (@string.Length <= 0 || text3.Contains(@string, CompareOptions.IgnoreCase) || userIDString.Contains(@string) || text2.Contains(@string) || text5.Contains(@string)) { textTable.AddRow(userIDString, text3, text4, text8, text5, (text2 == userIDString) ? string.Empty : text2, text6, text7); } } catch (Exception ex) { textTable.AddRow(activePlayer.UserIDString, ex.Message.QuoteSafe()); } } arg.ReplyWith(text + textTable.ToString()); }
public static void playerlistpos(Arg arg) { TextTable textTable = new TextTable(); textTable.AddColumns("SteamID", "DisplayName", "POS", "ROT"); foreach (BasePlayer activePlayer in BasePlayer.activePlayerList) { textTable.AddRow(activePlayer.userID.ToString(), activePlayer.displayName, activePlayer.transform.position.ToString(), activePlayer.transform.rotation.eulerAngles.ToString()); } arg.ReplyWith(textTable.ToString()); }
public static void find_self(Arg args) { BasePlayer basePlayer = ArgEx.Player(args); if (!(basePlayer == null) && basePlayer.net != null) { uint filter = basePlayer.net.ID; TextTable entityTable = GetEntityTable((EntityInfo info) => info.entityID == filter); args.ReplyWith(entityTable.ToString()); } }
public static void find_radius(Arg args) { BasePlayer player = ArgEx.Player(args); if (!(player == null)) { uint filter = args.GetUInt(0, 10u); TextTable entityTable = GetEntityTable((EntityInfo info) => Vector3.Distance(info.entity.transform.position, player.transform.position) <= (float)filter); args.ReplyWith(entityTable.ToString()); } }
private void ListCategoriesCommand(IPlayer player, string command, string[] args) { TextTable output = new TextTable(); output.AddColumns("Category Name", "Items In Category"); foreach (string category in Enum.GetNames(typeof(ItemCategory))) { output.AddRow(category, _data.ItemCategories[category].Count.ToString()); } player.Reply(output.ToString()); }
public static void scalars(Arg args) { TextTable textTable = new TextTable(); textTable.AddColumn("Type"); textTable.AddColumn("Value"); textTable.AddRow("Player Fraction", SpawnHandler.PlayerFraction().ToString()); textTable.AddRow("Player Excess", SpawnHandler.PlayerExcess().ToString()); textTable.AddRow("Population Rate", SpawnHandler.PlayerLerp(min_rate, max_rate).ToString()); textTable.AddRow("Population Density", SpawnHandler.PlayerLerp(min_density, max_density).ToString()); textTable.AddRow("Group Rate", SpawnHandler.PlayerScale(player_scale).ToString()); args.ReplyWith(textTable.ToString()); }
public static void find_radius(ConsoleSystem.Arg args) { BasePlayer basePlayer = args.Player(); if (basePlayer == null) { return; } uint num = args.GetUInt(0, 10); TextTable entityTable = Entity.GetEntityTable((Entity.EntityInfo info) => Vector3.Distance(info.entity.transform.position, basePlayer.transform.position) <= (float)((float)num)); args.ReplyWith(entityTable.ToString()); }
private void ListCategoriesCommand(IPlayer player, string command, string[] args) { TextTable output = new TextTable(); output.AddColumns("Category Name", "Items In Category"); foreach (string category in Enum.GetNames(typeof(ItemCategory))) { output.AddRow(category, ItemManager.itemList.Where(x => x.category.ToString() == category).Count().ToString()); } player.Reply(output.ToString()); }
public static void find_entity(ConsoleSystem.Arg args) { string str = args.GetString(0, ""); TextTable entityTable = Entity.GetEntityTable((Entity.EntityInfo info) => { if (string.IsNullOrEmpty(str)) { return(true); } return(info.entity.PrefabName.Contains(str)); }); args.ReplyWith(entityTable.ToString()); }
public static void aiDebug_LoadBalanceOverdueReportServer(ConsoleSystem.Arg args) { TextTable textTable = new TextTable(); textTable.AddColumn("type"); textTable.AddColumn("count"); textTable.AddColumn("overdue"); AI.AddLBTableEntry(ref textTable, "Default", LoadBalancer.defaultBalancer as LoadBalancedQueue); AI.AddLBTableEntry(ref textTable, "Ai Manager", AiManagerLoadBalancer.aiManagerLoadBalancer as LoadBalancedQueue); AI.AddLBTableEntry(ref textTable, "Ai Behaviour", AILoadBalancer.aiLoadBalancer as LoadBalancedQueue); AI.AddLBTableEntry(ref textTable, "Npc Senses", NPCSensesLoadBalancer.NpcSensesLoadBalancer as LoadBalancedQueue); AI.AddLBTableEntry(ref textTable, "Animal Senses", AnimalSensesLoadBalancer.animalSensesLoadBalancer as LoadBalancedQueue); args.ReplyWith(textTable.ToString()); }