|
1 | | -using Rocket.API; |
2 | | -using Rocket.API.Extensions; |
3 | | -using Rocket.Unturned.Chat; |
4 | | -using SDG.Unturned; |
5 | | -using Steamworks; |
6 | | -using System; |
7 | | -using System.Collections.Generic; |
8 | | -using UnityEngine; |
9 | | - |
10 | | -namespace PlayerInfoLibrary |
11 | | -{ |
12 | | - public class CommandInvestigate : IRocketCommand |
13 | | - { |
14 | | - internal static readonly string syntax = "<\"Player name\" | SteamID> [page]"; |
15 | | - internal static readonly string help = "Returns info for players matching the search quarry."; |
16 | | - public List<string> Aliases |
17 | | - { |
18 | | - get { return new List<string>(); } |
19 | | - } |
20 | | - |
21 | | - public AllowedCaller AllowedCaller |
22 | | - { |
23 | | - get { return AllowedCaller.Both; } |
24 | | - } |
25 | | - |
26 | | - public string Help |
27 | | - { |
28 | | - get { return help; } |
29 | | - } |
30 | | - |
31 | | - public string Name |
32 | | - { |
33 | | - get { return "investigate"; } |
34 | | - } |
35 | | - |
36 | | - public List<string> Permissions |
37 | | - { |
38 | | - get { return new List<string> { "PlayerInfoLib.Ivestigate" }; } |
39 | | - } |
40 | | - |
41 | | - public string Syntax |
42 | | - { |
43 | | - get { return syntax; } |
44 | | - } |
45 | | - |
46 | | - public void Execute(IRocketPlayer caller, string[] command) |
47 | | - { |
48 | | - if (command.Length == 0) |
49 | | - { |
50 | | - UnturnedChat.Say(caller, PlayerInfoLib.Instance.Translate("investigate_help")); |
51 | | - } |
52 | | - CSteamID cSteamID; |
53 | | - uint totalRecods = 1; |
54 | | - uint? page = 1; |
55 | | - uint start = 0; |
56 | | - uint perPage = caller is ConsolePlayer ? 10u : 4u; |
57 | | - List<PlayerData> pInfo = new List<PlayerData>(); |
58 | | - if (command.Length >= 1) |
59 | | - { |
60 | | - if (command.Length ==2) |
61 | | - { |
62 | | - page = command.GetUInt32Parameter(1); |
63 | | - if (page == null || page == 0) |
64 | | - { |
65 | | - UnturnedChat.Say(caller, PlayerInfoLib.Instance.Translate("invalid_page")); |
66 | | - return; |
67 | | - } |
68 | | - } |
69 | | - if (command.Length > 2) |
70 | | - { |
71 | | - UnturnedChat.Say(caller, PlayerInfoLib.Instance.Translate("too_many_parameters")); |
72 | | - return; |
73 | | - } |
74 | | - // Is what is entered in the command a SteamID64 number? |
75 | | - if (command[0].isCSteamID(out cSteamID)) |
76 | | - { |
77 | | - PlayerData pData = PlayerInfoLib.Database.QueryById(cSteamID); |
78 | | - if(pData.IsValid()) |
79 | | - pInfo.Add(pData); |
80 | | - } |
81 | | - else if(Parser.checkIP(command[0])) |
82 | | - { |
83 | | - pInfo = PlayerInfoLib.Database.QueryByName(command[0], QueryType.IP, out totalRecods, true, (uint)page, perPage); |
84 | | - } |
85 | | - else |
86 | | - { |
87 | | - pInfo = PlayerInfoLib.Database.QueryByName(command[0], QueryType.Both, out totalRecods, true, (uint)page, perPage); |
88 | | - } |
89 | | - if (pInfo.Count > 0) |
90 | | - { |
91 | | - start = ((uint)page - 1) * perPage; |
92 | | - UnturnedChat.Say(caller, PlayerInfoLib.Instance.Translate("number_of_records_found", totalRecods, command[0], page, Math.Ceiling(totalRecods / (float)perPage)), Color.red); |
93 | | - foreach (PlayerData pData in pInfo) |
94 | | - { |
95 | | - start++; |
96 | | - if (pData.IsLocal()) |
97 | | - { |
98 | | - UnturnedChat.Say(caller, string.Format("{0}: {1} [{2}] ({3}), IP: {4}, Local: {5}, IsVip: {6}", start, caller is ConsolePlayer ? pData.CharacterName : pData.CharacterName.Truncate(12), caller is ConsolePlayer ? pData.SteamName : pData.SteamName.Truncate(12), pData.SteamID, pData.IP, pData.IsLocal(), pData.IsVip()), Color.yellow); |
99 | | - UnturnedChat.Say(caller, string.Format("Seen: {0}, TT: {1}, Cleaned:{2}:{3}", pData.LastLoginLocal, pData.TotalPlayime.FormatTotalTime(), pData.CleanedBuildables, pData.CleanedPlayerData), Color.yellow); |
100 | | - } |
101 | | - else |
102 | | - { |
103 | | - UnturnedChat.Say(caller, string.Format("{0}: {1} [{2}] ({3}), IP: {4}, Local: {5}", start, caller is ConsolePlayer ? pData.CharacterName : pData.CharacterName.Truncate(12), caller is ConsolePlayer ? pData.SteamName : pData.SteamName.Truncate(12), pData.SteamID, pData.IP, pData.IsLocal()), Color.yellow); |
104 | | - UnturnedChat.Say(caller, string.Format("Seen: {0}, TT: {1}, on: {2}:{3}", pData.LastLoginLocal, pData.TotalPlayime.FormatTotalTime(), pData.LastServerID, pData.LastServerName), Color.yellow); |
105 | | - } |
106 | | - } |
107 | | - } |
108 | | - else |
109 | | - { |
110 | | - UnturnedChat.Say(caller, "No players found by that name."); |
111 | | - return; |
112 | | - } |
113 | | - } |
114 | | - } |
115 | | - } |
116 | | -} |
| 1 | +using Rocket.API; |
| 2 | +using Rocket.API.Extensions; |
| 3 | +using Rocket.Unturned.Chat; |
| 4 | +using SDG.Unturned; |
| 5 | +using Steamworks; |
| 6 | +using System; |
| 7 | +using System.Collections.Generic; |
| 8 | +using UnityEngine; |
| 9 | + |
| 10 | +namespace PlayerInfoLibrary |
| 11 | +{ |
| 12 | + public class CommandInvestigate : IRocketCommand |
| 13 | + { |
| 14 | + internal static readonly string syntax = "<\"Player name\" | SteamID> [page]"; |
| 15 | + internal static readonly string help = "Returns info for players matching the search quarry."; |
| 16 | + public List<string> Aliases |
| 17 | + { |
| 18 | + get { return new List<string>(); } |
| 19 | + } |
| 20 | + |
| 21 | + public AllowedCaller AllowedCaller |
| 22 | + { |
| 23 | + get { return AllowedCaller.Both; } |
| 24 | + } |
| 25 | + |
| 26 | + public string Help |
| 27 | + { |
| 28 | + get { return help; } |
| 29 | + } |
| 30 | + |
| 31 | + public string Name |
| 32 | + { |
| 33 | + get { return "investigate"; } |
| 34 | + } |
| 35 | + |
| 36 | + public List<string> Permissions |
| 37 | + { |
| 38 | + get { return new List<string> { "PlayerInfoLib.Ivestigate" }; } |
| 39 | + } |
| 40 | + |
| 41 | + public string Syntax |
| 42 | + { |
| 43 | + get { return syntax; } |
| 44 | + } |
| 45 | + |
| 46 | + public void Execute(IRocketPlayer caller, string[] command) |
| 47 | + { |
| 48 | + if (command.Length == 0) |
| 49 | + { |
| 50 | + UnturnedChat.Say(caller, PlayerInfoLib.Instance.Translate("investigate_help")); |
| 51 | + } |
| 52 | + CSteamID cSteamID; |
| 53 | + uint totalRecods = 1; |
| 54 | + uint? page = 1; |
| 55 | + uint start = 0; |
| 56 | + uint perPage = caller is ConsolePlayer ? 10u : 4u; |
| 57 | + List<PlayerData> pInfo = new List<PlayerData>(); |
| 58 | + if (command.Length >= 1) |
| 59 | + { |
| 60 | + if (command.Length ==2) |
| 61 | + { |
| 62 | + page = command.GetUInt32Parameter(1); |
| 63 | + if (page == null || page == 0) |
| 64 | + { |
| 65 | + UnturnedChat.Say(caller, PlayerInfoLib.Instance.Translate("invalid_page")); |
| 66 | + return; |
| 67 | + } |
| 68 | + } |
| 69 | + if (command.Length > 2) |
| 70 | + { |
| 71 | + UnturnedChat.Say(caller, PlayerInfoLib.Instance.Translate("too_many_parameters")); |
| 72 | + return; |
| 73 | + } |
| 74 | + // Is what is entered in the command a SteamID64 number? |
| 75 | + if (command[0].isCSteamID(out cSteamID)) |
| 76 | + { |
| 77 | + PlayerData pData = PlayerInfoLib.Database.QueryById(cSteamID); |
| 78 | + if(pData.IsValid()) |
| 79 | + pInfo.Add(pData); |
| 80 | + } |
| 81 | + else if(Parser.checkIP(command[0])) |
| 82 | + { |
| 83 | + pInfo = PlayerInfoLib.Database.QueryByName(command[0], QueryType.IP, out totalRecods, true, (uint)page, perPage); |
| 84 | + } |
| 85 | + else |
| 86 | + { |
| 87 | + pInfo = PlayerInfoLib.Database.QueryByName(command[0], QueryType.Both, out totalRecods, true, (uint)page, perPage); |
| 88 | + } |
| 89 | + if (pInfo.Count > 0) |
| 90 | + { |
| 91 | + start = ((uint)page - 1) * perPage; |
| 92 | + UnturnedChat.Say(caller, PlayerInfoLib.Instance.Translate("number_of_records_found", totalRecods, command[0], page, Math.Ceiling(totalRecods / (float)perPage)), Color.red); |
| 93 | + foreach (PlayerData pData in pInfo) |
| 94 | + { |
| 95 | + start++; |
| 96 | + if (pData.IsLocal()) |
| 97 | + { |
| 98 | + UnturnedChat.Say(caller, string.Format("{0}: {1} [{2}] ({3}), IP: {4}, Local: {5}, IsVip: {6}", start, caller is ConsolePlayer ? pData.CharacterName : pData.CharacterName.Truncate(12), caller is ConsolePlayer ? pData.SteamName : pData.SteamName.Truncate(12), pData.SteamID, pData.IP, pData.IsLocal(), pData.IsVip()), Color.yellow); |
| 99 | + UnturnedChat.Say(caller, string.Format("Seen: {0}, TT: {1}, Cleaned:{2}:{3}", pData.LastLoginLocal, pData.TotalPlayime.FormatTotalTime(), pData.CleanedBuildables, pData.CleanedPlayerData), Color.yellow); |
| 100 | + } |
| 101 | + else |
| 102 | + { |
| 103 | + UnturnedChat.Say(caller, string.Format("{0}: {1} [{2}] ({3}), IP: {4}, Local: {5}", start, caller is ConsolePlayer ? pData.CharacterName : pData.CharacterName.Truncate(12), caller is ConsolePlayer ? pData.SteamName : pData.SteamName.Truncate(12), pData.SteamID, pData.IP, pData.IsLocal()), Color.yellow); |
| 104 | + UnturnedChat.Say(caller, string.Format("Seen: {0}, TT: {1}, on: {2}:{3}", pData.LastLoginLocal, pData.TotalPlayime.FormatTotalTime(), pData.LastServerID, pData.LastServerName), Color.yellow); |
| 105 | + } |
| 106 | + } |
| 107 | + } |
| 108 | + else |
| 109 | + { |
| 110 | + UnturnedChat.Say(caller, "No players found by that name."); |
| 111 | + return; |
| 112 | + } |
| 113 | + } |
| 114 | + } |
| 115 | + } |
| 116 | +} |
0 commit comments