- Timestamp:
- Nov 9, 2021, 6:28:33 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/AllocsCommands/Commands/ListKnownPlayers.cs
r359 r369 1 using System;2 1 using System.Collections.Generic; 3 2 using AllocsFixes.PersistentData; … … 14 13 " 2. listknownplayers -online\n" + 15 14 " 3. listknownplayers -notbanned\n" + 16 " 4. listknownplayers <player name / steamid>\n" +15 " 4. listknownplayers <player name / userid>\n" + 17 16 "1. Lists all players that have ever been online\n" + 18 17 "2. Lists only the players that are currently online\n" + 19 18 "3. Lists only the players that are not banned\n" + 20 "4. Lists all players whose name contains the given string or matches the given SteamID";19 "4. Lists all players whose name contains the given string or matches the given UserID"; 21 20 } 22 21 … … 31 30 bool notBannedOnly = false; 32 31 string nameFilter = string.Empty; 33 bool isSteamId = false;32 PlatformUserIdentifierAbs userIdFilter = null; 34 33 35 34 if (_params.Count == 1) { 36 long steamid;37 35 if (_params [0].EqualsCaseInsensitive ("-online")) { 38 36 onlineOnly = true; 39 37 } else if (_params [0].EqualsCaseInsensitive ("-notbanned")) { 40 38 notBannedOnly = true; 41 } else if ( _params [0].Length == 17 && long.TryParse (_params [0], out steamid)) {42 isSteamId = true;39 } else if (PlatformUserIdentifierAbs.TryFromCombinedString (_params [0], out userIdFilter)) { 40 // if true nothing to do, set by the out parameter 43 41 } else { 44 42 nameFilter = _params [0]; … … 46 44 } 47 45 48 if ( isSteamId) {49 Player p = PersistentContainer.Instance.Players [ _params [0], false];46 if (userIdFilter != null) { 47 Player p = PersistentContainer.Instance.Players [userIdFilter, false]; 50 48 51 49 if (p != null) { 52 SdtdConsole.Instance.Output (string.Format ( 53 "{0}. {1}, id={2}, steamid={3}, online={4}, ip={5}, playtime={6} m, seen={7}", 54 0, p.Name, p.EntityID, _params [0], p.IsOnline, p.IP, 55 p.TotalPlayTime / 60, 56 p.LastOnline.ToString ("yyyy-MM-dd HH:mm")) 50 SdtdConsole.Instance.Output ( 51 $"{0}. {p.Name}, id={p.EntityID}, steamid={_params [0]}, online={p.IsOnline}, ip={p.IP}, playtime={p.TotalPlayTime / 60} m, seen={p.LastOnline:yyyy-MM-dd HH:mm}" 57 52 ); 58 53 } else { 59 SdtdConsole.Instance.Output ( string.Format ("SteamID {0} unknown!", _params [0]));54 SdtdConsole.Instance.Output ($"SteamID {_params [0]} unknown!"); 60 55 } 61 56 } else { 62 57 int num = 0; 63 foreach (KeyValuePair< string, Player> kvp in PersistentContainer.Instance.Players.Dict) {58 foreach (KeyValuePair<PlatformUserIdentifierAbs, Player> kvp in PersistentContainer.Instance.Players.Dict) { 64 59 Player p = kvp.Value; 65 60 66 61 if ( 67 62 (!onlineOnly || p.IsOnline) 68 && (!notBannedOnly || !admTools.IsBanned (kvp.Key ))63 && (!notBannedOnly || !admTools.IsBanned (kvp.Key, out _, out _)) 69 64 && (nameFilter.Length == 0 || p.Name.ContainsCaseInsensitive (nameFilter)) 70 65 ) { 71 SdtdConsole.Instance.Output (string.Format ( 72 "{0}. {1}, id={2}, steamid={3}, online={4}, ip={5}, playtime={6} m, seen={7}", 73 ++num, p.Name, p.EntityID, kvp.Key, p.IsOnline, p.IP, 74 p.TotalPlayTime / 60, 75 p.LastOnline.ToString ("yyyy-MM-dd HH:mm")) 66 SdtdConsole.Instance.Output ( 67 $"{++num}. {p.Name}, id={p.EntityID}, steamid={kvp.Key}, online={p.IsOnline}, ip={p.IP}, playtime={p.TotalPlayTime / 60} m, seen={p.LastOnline:yyyy-MM-dd HH:mm}" 76 68 ); 77 69 } 78 70 } 79 71 80 SdtdConsole.Instance.Output ( "Total of " + PersistentContainer.Instance.Players.Count + "known");72 SdtdConsole.Instance.Output ($"Total of {PersistentContainer.Instance.Players.Count} known"); 81 73 } 82 74 }
Note:
See TracChangeset
for help on using the changeset viewer.