- Timestamp:
- Oct 29, 2019, 11:20:45 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/AllocsCommands/Commands/ListKnownPlayers.cs
r332 r359 26 26 27 27 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) { 28 try { 29 AdminTools admTools = GameManager.Instance.adminTools; 28 AdminTools admTools = GameManager.Instance.adminTools; 30 29 31 32 33 34 30 bool onlineOnly = false; 31 bool notBannedOnly = false; 32 string nameFilter = string.Empty; 33 bool isSteamId = false; 35 34 36 if (_params.Count == 1) { 37 long steamid; 38 if (_params [0].EqualsCaseInsensitive ("-online")) { 39 onlineOnly = true; 40 } else if (_params [0].EqualsCaseInsensitive ("-notbanned")) { 41 notBannedOnly = true; 42 } else if (_params [0].Length == 17 && long.TryParse (_params [0], out steamid)) { 43 isSteamId = true; 44 } else { 45 nameFilter = _params [0]; 35 if (_params.Count == 1) { 36 long steamid; 37 if (_params [0].EqualsCaseInsensitive ("-online")) { 38 onlineOnly = true; 39 } else if (_params [0].EqualsCaseInsensitive ("-notbanned")) { 40 notBannedOnly = true; 41 } else if (_params [0].Length == 17 && long.TryParse (_params [0], out steamid)) { 42 isSteamId = true; 43 } else { 44 nameFilter = _params [0]; 45 } 46 } 47 48 if (isSteamId) { 49 Player p = PersistentContainer.Instance.Players [_params [0], false]; 50 51 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")) 57 ); 58 } else { 59 SdtdConsole.Instance.Output (string.Format ("SteamID {0} unknown!", _params [0])); 60 } 61 } else { 62 int num = 0; 63 foreach (KeyValuePair<string, Player> kvp in PersistentContainer.Instance.Players.Dict) { 64 Player p = kvp.Value; 65 66 if ( 67 (!onlineOnly || p.IsOnline) 68 && (!notBannedOnly || !admTools.IsBanned (kvp.Key)) 69 && (nameFilter.Length == 0 || p.Name.ContainsCaseInsensitive (nameFilter)) 70 ) { 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")) 76 ); 46 77 } 47 78 } 48 79 49 if (isSteamId) { 50 Player p = PersistentContainer.Instance.Players [_params [0], false]; 51 52 if (p != null) { 53 SdtdConsole.Instance.Output (string.Format ( 54 "{0}. {1}, id={2}, steamid={3}, online={4}, ip={5}, playtime={6} m, seen={7}", 55 0, p.Name, p.EntityID, _params [0], p.IsOnline, p.IP, 56 p.TotalPlayTime / 60, 57 p.LastOnline.ToString ("yyyy-MM-dd HH:mm")) 58 ); 59 } else { 60 SdtdConsole.Instance.Output (string.Format ("SteamID {0} unknown!", _params [0])); 61 } 62 } else { 63 int num = 0; 64 foreach (KeyValuePair<string, Player> kvp in PersistentContainer.Instance.Players.Dict) { 65 Player p = kvp.Value; 66 67 if ( 68 (!onlineOnly || p.IsOnline) 69 && (!notBannedOnly || !admTools.IsBanned (kvp.Key)) 70 && (nameFilter.Length == 0 || p.Name.ContainsCaseInsensitive (nameFilter)) 71 ) { 72 SdtdConsole.Instance.Output (string.Format ( 73 "{0}. {1}, id={2}, steamid={3}, online={4}, ip={5}, playtime={6} m, seen={7}", 74 ++num, p.Name, p.EntityID, kvp.Key, p.IsOnline, p.IP, 75 p.TotalPlayTime / 60, 76 p.LastOnline.ToString ("yyyy-MM-dd HH:mm")) 77 ); 78 } 79 } 80 81 SdtdConsole.Instance.Output ("Total of " + PersistentContainer.Instance.Players.Count + " known"); 82 } 83 } catch (Exception e) { 84 Log.Out ("Error in ListKnownPlayers.Run: " + e); 80 SdtdConsole.Instance.Output ("Total of " + PersistentContainer.Instance.Players.Count + " known"); 85 81 } 86 82 }
Note:
See TracChangeset
for help on using the changeset viewer.