· 5 years ago · Mar 01, 2020, 11:46 PM
1/*
2 SourcePawn is Copyright (C) 2006-2008 AlliedModders LLC. All rights reserved.
3 SourceMod is Copyright (C) 2006-2008 AlliedModders LLC. All rights reserved.
4 Pawn and SMALL are Copyright (C) 1997-2008 ITB CompuPhase.
5 Source is Copyright (C) Valve Corporation.
6 All trademarks are property of their respective owners.
7 This program is free software: you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation, either version 3 of the License, or (at your
10 option) any later version.
11 This program is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
15 You should have received a copy of the GNU General Public License along
16 with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#include <sourcemod>
20#include <multicolors>
21
22#pragma semicolon 1
23#pragma newdecls required
24
25enum
26{
27 Arg_Steam2ID,
28 Arg_Steam3ID,
29 Arg_Steam32ID,
30 Arg_Steam64ID,
31 Arg_Name,
32 Arg_IP,
33}
34
35// Cvars
36ConVar g_cvarPrintChat;
37ConVar g_cvarPrintConsole;
38ConVar g_cvarPrintServer;
39
40// Cvars Buffer
41int g_iPrintChat;
42int g_iPrintConsole;
43int g_iPrintServer;
44
45Database g_hDatabase = null;
46
47public Plugin myinfo = {
48 name = "Player Info Recorder",
49 author = "Mis",
50 description = "Saves info about each player that connects to the server in a database.",
51 version = "0.1.0",
52 url = "https://github.com/misdocumeno/"
53};
54
55////////////////////////////////////////////////////////////////
56// Stock Functions
57////////////////////////////////////////////////////////////////
58
59public void OnPluginStart()
60{
61 // ConVars
62 g_cvarPrintChat = CreateConVar("db_playerrecord_printchat", "0", "Set whether the command response should be seen in the chat.", FCVAR_NOTIFY, true, 0.0, true, 1.0);
63 g_cvarPrintConsole = CreateConVar("db_playerrecord_printconsole", "1", "Set whether the command response should be seen in the client console.", FCVAR_NOTIFY, true, 0.0, true, 1.0);
64 g_cvarPrintServer = CreateConVar("db_playerrecord_printserver", "0", "Set whether the command response should be seen in the server console.", FCVAR_NOTIFY, true, 0.0, true, 1.0);
65
66 g_iPrintChat = GetConVarInt(g_cvarPrintChat);
67 g_iPrintConsole = GetConVarInt(g_cvarPrintConsole);
68 g_iPrintServer = GetConVarInt(g_cvarPrintServer);
69
70 HookConVarChange(g_cvarPrintChat, OnConVarChange);
71 HookConVarChange(g_cvarPrintConsole, OnConVarChange);
72 HookConVarChange(g_cvarPrintServer, OnConVarChange);
73
74 // Info commands
75 RegAdminCmd("sm_playerinfo", OnPlayerInfoCMD, ADMFLAG_UNBAN, "Shows names, all types of SteamID and IPs seen with a given SteamID of any type, IP or name.");
76 RegAdminCmd("sm_nameinfo", OnNameInfoCMD, ADMFLAG_UNBAN, "Shows names, all types of SteamID and IPs seen with a given name.");
77 RegAdminCmd("sm_ipinfo", OnIpInfoCMD, ADMFLAG_UNBAN, "Shows names, all types of SteamID and IPs of all players who have joined the server from the given IP.");
78 RegAdminCmd("sm_steamid2info", OnSteamId2InfoCMD, ADMFLAG_UNBAN, "Shows last name, all types of SteamID and last seen IP explicitly searching with a SteamID2.");
79 RegAdminCmd("sm_steamid3info", OnSteamId3InfoCMD, ADMFLAG_UNBAN, "Shows last name, all types of SteamID and last seen IP explicitly searching with a SteamID3.");
80 RegAdminCmd("sm_steamid64info", OnSteamId64InfoCMD, ADMFLAG_UNBAN, "Shows last name, all types of SteamID, and last seen IP explicitly searching with a SteamID64.");
81
82 // History commands
83 RegAdminCmd("sm_playerall", OnPlayerAllCMD, ADMFLAG_UNBAN, "Shows a history of all names, all types of SteamID and all IPs of a given SteamID of any type, IP or name.");
84 RegAdminCmd("sm_namenames", OnNameNamesCMD, ADMFLAG_UNBAN, "Shows a history of all names that a player had searching with one of his names.");
85 RegAdminCmd("sm_steamid2names", OnSteamId2NamesCMD, ADMFLAG_UNBAN, "Shows a history of all names a player had searching with a SteamID2.");
86 RegAdminCmd("sm_steamid3names", OnSteamId3NamesCMD, ADMFLAG_UNBAN, "Shows a history of all names a player had searching with a SteamID3.");
87 RegAdminCmd("sm_steamid64names", OnSteamId64NamesCMD, ADMFLAG_UNBAN, "Shows a history of all names a player had searching with a SteamID64.");
88 RegAdminCmd("sm_nameips", OnNameIpsCMD, ADMFLAG_UNBAN, "Shows a history of all IPs connected with the given name.");
89 RegAdminCmd("sm_steamid2ips", OnSteamId2IpsCMD, ADMFLAG_UNBAN, "Shows a history of all IPs from where a SteamID2 was connected.");
90 RegAdminCmd("sm_steamid3ips", OnSteamId3IpsCMD, ADMFLAG_UNBAN, "Shows a history of all IPs from where a SteamID3 was connected.");
91 RegAdminCmd("sm_steamid64ips", OnSteamId64IpsCMD, ADMFLAG_UNBAN, "Shows a history of all IPs from where a SteamID64 was connected.");
92 RegAdminCmd("sm_ipall", OnIpAllCMD, ADMFLAG_UNBAN, "Shows a history of all types of SteamID and their respective names seen on an IP.");
93
94 HookEvent("player_changename", OnPlayerChangeName_Event, EventHookMode_Post);
95
96 Database.Connect(SQL_FirstConnect, "PlayerRecord");
97}
98
99public void OnConVarChange(Handle convar, const char[] oldValue, const char[] newValue)
100{
101 if (convar == g_cvarPrintChat)
102 g_iPrintChat = GetConVarInt(g_cvarPrintChat);
103 else if (convar == g_cvarPrintConsole)
104 g_iPrintConsole = GetConVarInt(g_cvarPrintConsole);
105 else if (convar == g_cvarPrintServer)
106 g_iPrintServer = GetConVarInt(g_cvarPrintServer);
107}
108
109public void OnClientAuthorized(int client)
110{
111 char sIP[16];
112 char sUserName[MAX_NAME_LENGTH];
113 int iAccountId = GetSteamAccountID(client);
114 bool bValidIP = GetClientIP(client, sIP, sizeof(sIP));
115 bool bValidName = GetClientName(client, sUserName, sizeof(sUserName));
116
117 if (iAccountId != 0 && bValidIP && bValidName)
118 {
119 char query[256];
120
121 g_hDatabase.Format(query, sizeof(query), "INSERT INTO "
122 ..."`Players`(`AccountID`, `IP`, `Name`) "
123 ..."VALUES ('%i', '%s', '%s') ON DUPLICATE KEY UPDATE "
124 ..."`Date` = CURRENT_TIMESTAMP", iAccountId, sIP, sUserName);
125
126 g_hDatabase.Query(SQL_CreateAndInsertQuery, query);
127 }
128}
129
130public Action OnPlayerChangeName_Event(Event event, const char[] name, bool dontBroadcast)
131{
132 int userid = event.GetInt("userid");
133 int client = GetClientOfUserId(userid);
134
135 char sIP[16];
136 char sUserName[MAX_NAME_LENGTH];
137 int iAccountId = GetSteamAccountID(client);
138 bool bValidIP = GetClientIP(client, sIP, sizeof(sIP));
139 event.GetString("newname", sUserName, sizeof(sUserName));
140
141 if (iAccountId != 0 && bValidIP)
142 {
143 char query[256];
144
145 g_hDatabase.Format(query, sizeof(query), "INSERT INTO "
146 ..."`Players`(`AccountID`, `IP`, `Name`) "
147 ..."VALUES ('%i', '%s', '%s') ON DUPLICATE KEY UPDATE "
148 ..."`Date` = CURRENT_TIMESTAMP", iAccountId, sIP, sUserName);
149
150 g_hDatabase.Query(SQL_CreateAndInsertQuery, query);
151 }
152}
153
154////////////////////////////////////////////////////////////////
155// Commands Functions
156////////////////////////////////////////////////////////////////
157
158static Action OnPlayerInfoCMD(int client, any args)
159{
160 if (args != 1)
161 {
162 if (g_iPrintChat == 1 || client)
163 CPrintToChat(client, "[{green}!{default}] {blue}Usage: {default}sm_playerinfo {olive}<name/SteamID/IP>");
164 if (g_iPrintConsole == 1)
165 PrintToConsole(client, "[!] Usage: sm_playerinfo <name/SteamID/IP>");
166 if (g_iPrintServer == 1)
167 PrintToServer("[!] Usage: sm_playerinfo <name/SteamID/IP>");
168 }
169 else
170 {
171 if (g_iPrintChat == 1 || client)
172 CPrintToChat(client, "{blue}[{green}!{blue}] {default}Searching...");
173 if (g_iPrintConsole == 1)
174 PrintToConsole(client, "[!] Searching...");
175 if (g_iPrintServer == 1)
176 PrintToServer("[!] Searching...");
177 }
178
179 int iAccountId;
180
181 char arg[256];
182 GetCmdArg(1, arg, sizeof(arg));
183
184 if (GetArgType(arg) == Arg_Steam2ID)
185 iAccountId = GetAccountIdByAny(client, arg, Arg_Steam2ID);
186 else if (GetArgType(arg) == Arg_Steam3ID)
187 iAccountId = GetAccountIdByAny(client, arg, Arg_Steam3ID);
188 else if (GetArgType(arg) == Arg_Steam32ID)
189 iAccountId = GetAccountIdByAny(client, arg, Arg_Steam32ID);
190 else if (GetArgType(arg) == Arg_Steam64ID)
191 iAccountId = GetAccountIdByAny(client, arg, Arg_Steam64ID);
192 else if (GetArgType(arg) == Arg_Name)
193 iAccountId = GetAccountIdByAny(client, arg, Arg_Steam64ID);
194
195 char query[256];
196
197 if (GetArgType(arg) == Arg_Name)
198 g_hDatabase.Format(query, sizeof(query), "SELECT Name, IP, AccountID FROM Players WHERE Name LIKE '%s' GROUP BY `Players`.`AccountID` ORDER BY `Players`.`Date`", arg);
199 else if (GetArgType(arg) == Arg_IP)
200 g_hDatabase.Format(query, sizeof(query), "SELECT Name, IP, AccountID FROM Players WHERE IP = '%s' GROUP BY `Players`.`AccountID` ORDER BY `Players`.`Date`", arg);
201 else
202 g_hDatabase.Format(query, sizeof(query), "SELECT Name, IP, AccountID FROM Players WHERE AccountID = '%i' ORDER BY `Players`.`Date` DESC LIMIT 1", iAccountId);
203
204 int userid = GetClientUserId(client);
205
206 DataPack hPlayerInfoPack = new DataPack();
207 hPlayerInfoPack.WriteString(arg);
208 hPlayerInfoPack.WriteCell(userid);
209 hPlayerInfoPack.WriteCell(GetArgType(arg));
210
211 g_hDatabase.Query(OnInfoQuery, query, hPlayerInfoPack);
212
213 return Plugin_Handled;
214}
215
216static Action OnNameInfoCMD(int client, any args)
217{
218 if (args != 1)
219 {
220 if (g_iPrintChat == 1 || client)
221 CPrintToChat(client, "[{green}!{default}] {blue}Usage: {default}sm_nameinfo {olive}<name>");
222 if (g_iPrintConsole == 1)
223 PrintToConsole(client, "[!] Usage: sm_nameinfo <name>");
224 if (g_iPrintServer == 1)
225 PrintToServer("[!] Usage: sm_nameinfo <name>");
226 }
227 else
228 {
229 if (g_iPrintChat == 1 || client)
230 CPrintToChat(client, "{blue}[{green}!{blue}] {default}Searching...");
231 if (g_iPrintConsole == 1)
232 PrintToConsole(client, "[!] Searching...");
233 if (g_iPrintServer == 1)
234 PrintToServer("[!] Searching...");
235 }
236
237 char arg[256];
238 GetCmdArg(1, arg, sizeof(arg));
239
240 char query[256];
241 g_hDatabase.Format(query, sizeof(query), "SELECT Name, IP, AccountID FROM Players WHERE Name LIKE '%s' GROUP BY `Players`.`AccountID` ORDER BY `Players`.`Date`", arg);
242
243 int userid = GetClientUserId(client);
244
245 DataPack hPlayerInfoPack = new DataPack();
246 hPlayerInfoPack.WriteString(arg);
247 hPlayerInfoPack.WriteCell(userid);
248 hPlayerInfoPack.WriteCell(Arg_Name);
249
250 g_hDatabase.Query(OnInfoQuery, query, hPlayerInfoPack);
251
252 return Plugin_Handled;
253}
254
255static Action OnIpInfoCMD(int client, any args)
256{
257 if (args != 1)
258 {
259 if (g_iPrintChat == 1 || client)
260 CPrintToChat(client, "[{green}!{default}] {blue}Usage: {default}sm_ipinfo {olive}<IP>");
261 if (g_iPrintConsole == 1)
262 PrintToConsole(client, "[!] Usage: sm_ipinfo <IP>");
263 if (g_iPrintServer == 1)
264 PrintToServer("[!] Usage: sm_ipinfo <IP>");
265 }
266 else
267 {
268 if (g_iPrintChat == 1 || client)
269 CPrintToChat(client, "{blue}[{green}!{blue}] {default}Searching...");
270 if (g_iPrintConsole == 1)
271 PrintToConsole(client, "[!] Searching...");
272 if (g_iPrintServer == 1)
273 PrintToServer("[!] Searching...");
274 }
275
276 char arg[256];
277 GetCmdArg(1, arg, sizeof(arg));
278
279 char query[256];
280 g_hDatabase.Format(query, sizeof(query), "SELECT Name, IP, AccountID FROM Players WHERE IP = '%s' GROUP BY `Players`.`AccountID` ORDER BY `Players`.`Date`", arg);
281
282 int userid = GetClientUserId(client);
283
284 DataPack hPlayerInfoPack = new DataPack();
285 hPlayerInfoPack.WriteString(arg);
286 hPlayerInfoPack.WriteCell(userid);
287 hPlayerInfoPack.WriteCell(Arg_IP);
288
289 g_hDatabase.Query(OnInfoQuery, query, hPlayerInfoPack);
290
291 return Plugin_Handled;
292}
293
294static Action OnSteamId2InfoCMD(int client, any args)
295{
296 if (args != 1)
297 {
298 if (g_iPrintChat == 1 || client)
299 CPrintToChat(client, "[{green}!{default}] {blue}Usage: {default}sm_steamid2info {olive}<SteamID2>");
300 if (g_iPrintConsole == 1)
301 PrintToConsole(client, "[!] Usage: sm_steamid2info <SteamID2>");
302 if (g_iPrintServer == 1)
303 PrintToServer("[!] Usage: sm_steamid2info <SteamID2>");
304 }
305 else
306 {
307 if (g_iPrintChat == 1 || client)
308 CPrintToChat(client, "{blue}[{green}!{blue}] {default}Searching...");
309 if (g_iPrintConsole == 1)
310 PrintToConsole(client, "[!] Searching...");
311 if (g_iPrintServer == 1)
312 PrintToServer("[!] Searching...");
313 }
314
315 int iAccountId;
316
317 char arg[256];
318 GetCmdArg(1, arg, sizeof(arg));
319
320 iAccountId = GetAccountIdByAny(client, arg, Arg_Steam2ID);
321
322 char query[256];
323 g_hDatabase.Format(query, sizeof(query), "SELECT Name, IP, AccountID FROM Players WHERE AccountID = '%i' ORDER BY `Players`.`Date` DESC LIMIT 1", iAccountId);
324
325 int userid = GetClientUserId(client);
326
327 DataPack hPlayerInfoPack = new DataPack();
328 hPlayerInfoPack.WriteString(arg);
329 hPlayerInfoPack.WriteCell(userid);
330 hPlayerInfoPack.WriteCell(Arg_Steam2ID);
331
332 g_hDatabase.Query(OnInfoQuery, query, hPlayerInfoPack);
333
334 return Plugin_Handled;
335}
336
337static Action OnSteamId3InfoCMD(int client, any args)
338{
339 if (args != 1)
340 {
341 if (g_iPrintChat == 1 || client)
342 CPrintToChat(client, "[{green}!{default}] {blue}Usage: {default}sm_steamid3info {olive}<SteamID3>");
343 if (g_iPrintConsole == 1)
344 PrintToConsole(client, "[!] Usage: sm_steamid3info <SteamID3>");
345 if (g_iPrintServer == 1)
346 PrintToServer("[!] Usage: sm_steamid3info <SteamID3>");
347 }
348 else
349 {
350 if (g_iPrintChat == 1 || client)
351 CPrintToChat(client, "{blue}[{green}!{blue}] {default}Searching...");
352 if (g_iPrintConsole == 1)
353 PrintToConsole(client, "[!] Searching...");
354 if (g_iPrintServer == 1)
355 PrintToServer("[!] Searching...");
356 }
357
358 int iAccountId;
359
360 char arg[256];
361 GetCmdArg(1, arg, sizeof(arg));
362
363 iAccountId = GetAccountIdByAny(client, arg, Arg_Steam3ID);
364
365 char query[256];
366 g_hDatabase.Format(query, sizeof(query), "SELECT Name, IP, AccountID FROM Players WHERE AccountID = '%i' ORDER BY `Players`.`Date` DESC LIMIT 1", iAccountId);
367
368 int userid = GetClientUserId(client);
369
370 DataPack hPlayerInfoPack = new DataPack();
371 hPlayerInfoPack.WriteString(arg);
372 hPlayerInfoPack.WriteCell(userid);
373 hPlayerInfoPack.WriteCell(Arg_Steam3ID);
374
375 g_hDatabase.Query(OnInfoQuery, query, hPlayerInfoPack);
376
377 return Plugin_Handled;
378}
379
380static Action OnSteamId64InfoCMD(int client, any args)
381{
382 if (args != 1)
383 {
384 if (g_iPrintChat == 1 || client)
385 CPrintToChat(client, "[{green}!{default}] {blue}Usage: {default}sm_steamid64info {olive}<SteamID64>");
386 if (g_iPrintConsole == 1)
387 PrintToConsole(client, "[!] Usage: sm_steamid64info <SteamID64>");
388 if (g_iPrintServer == 1)
389 PrintToServer("[!] Usage: sm_steamid64info <SteamID64>");
390 }
391 else
392 {
393 if (g_iPrintChat == 1 || client)
394 CPrintToChat(client, "{blue}[{green}!{blue}] {default}Searching...");
395 if (g_iPrintConsole == 1)
396 PrintToConsole(client, "[!] Searching...");
397 if (g_iPrintServer == 1)
398 PrintToServer("[!] Searching...");
399 }
400
401 int iAccountId;
402
403 char arg[256];
404 GetCmdArg(1, arg, sizeof(arg));
405
406 iAccountId = GetAccountIdByAny(client, arg, Arg_Steam64ID);
407
408 char query[256];
409 g_hDatabase.Format(query, sizeof(query), "SELECT Name, IP, AccountID FROM Players WHERE AccountID = '%i' ORDER BY `Players`.`Date` DESC LIMIT 1", iAccountId);
410
411 int userid = GetClientUserId(client);
412
413 DataPack hPlayerInfoPack = new DataPack();
414 hPlayerInfoPack.WriteString(arg);
415 hPlayerInfoPack.WriteCell(userid);
416 hPlayerInfoPack.WriteCell(Arg_Steam64ID);
417
418 g_hDatabase.Query(OnInfoQuery, query, hPlayerInfoPack);
419
420 return Plugin_Handled;
421}
422
423////////////////////////////////////////////////////////////////
424
425static Action OnPlayerAllCMD(int client, any args)
426{
427 if (args != 1)
428 {
429 if (g_iPrintChat == 1 || client)
430 CPrintToChat(client, "[{green}!{default}] {blue}Usage: {default}sm_playerall {olive}<name/SteamID/IP>");
431 if (g_iPrintConsole == 1)
432 PrintToConsole(client, "[!] Usage: sm_playerall <name/SteamID/IP>");
433 if (g_iPrintServer == 1)
434 PrintToServer("[!] Usage: sm_playerall <name/SteamID/IP>");
435 }
436 else
437 {
438 if (g_iPrintChat == 1 || client)
439 CPrintToChat(client, "{blue}[{green}!{blue}] {default}Searching...");
440 if (g_iPrintConsole == 1)
441 PrintToConsole(client, "[!] Searching...");
442 if (g_iPrintServer == 1)
443 PrintToServer("[!] Searching...");
444 }
445
446 int iAccountId;
447
448 char arg[256];
449 GetCmdArg(1, arg, sizeof(arg));
450
451 if (GetArgType(arg) == Arg_Steam2ID)
452 iAccountId = GetAccountIdByAny(client, arg, Arg_Steam2ID);
453 else if (GetArgType(arg) == Arg_Steam3ID)
454 iAccountId = GetAccountIdByAny(client, arg, Arg_Steam3ID);
455 else if (GetArgType(arg) == Arg_Steam32ID)
456 iAccountId = GetAccountIdByAny(client, arg, Arg_Steam32ID);
457 else if (GetArgType(arg) == Arg_Steam64ID)
458 iAccountId = GetAccountIdByAny(client, arg, Arg_Steam64ID);
459 else if (GetArgType(arg) == Arg_Name)
460 iAccountId = GetAccountIdByAny(client, arg, Arg_Steam64ID);
461
462 char query[256];
463
464 if (GetArgType(arg) == Arg_Name)
465 g_hDatabase.Format(query, sizeof(query), "SELECT Name, IP, AccountID FROM Players WHERE Name LIKE '%s' ORDER BY `Players`.`Date` DESC", arg);
466 else if (GetArgType(arg) == Arg_IP)
467 g_hDatabase.Format(query, sizeof(query), "SELECT Name, IP, AccountID FROM Players WHERE IP = '%s' ORDER BY `Players`.`Date` DESC", arg);
468 else
469 g_hDatabase.Format(query, sizeof(query), "SELECT Name, IP, AccountID FROM Players WHERE AccountID = '%i' ORDER BY `Players`.`Date` DESC", iAccountId);
470
471 int userid = GetClientUserId(client);
472
473 DataPack hHistoryAllPack = new DataPack();
474 hHistoryAllPack.WriteString(arg);
475 hHistoryAllPack.WriteCell(userid);
476 hHistoryAllPack.WriteCell(GetArgType(arg));
477
478 g_hDatabase.Query(OnHistoryAllQuery, query, hHistoryAllPack);
479
480 return Plugin_Handled;
481}
482
483static Action OnNameNamesCMD(int client, any args)
484{
485 if (args != 1)
486 {
487 if (g_iPrintChat == 1 || client)
488 CPrintToChat(client, "[{green}!{default}] {blue}Usage: {default}sm_namenames {olive}<name>");
489 if (g_iPrintConsole == 1)
490 PrintToConsole(client, "[!] Usage: sm_namenames <name>");
491 if (g_iPrintServer == 1)
492 PrintToServer("[!] Usage: sm_namenames <name>");
493 }
494 else
495 {
496 if (g_iPrintChat == 1 || client)
497 CPrintToChat(client, "{blue}[{green}!{blue}] {default}Searching...");
498 if (g_iPrintConsole == 1)
499 PrintToConsole(client, "[!] Searching...");
500 if (g_iPrintServer == 1)
501 PrintToServer("[!] Searching...");
502 }
503
504 char arg[256];
505 GetCmdArg(1, arg, sizeof(arg));
506
507 char query[256];
508 g_hDatabase.Format(query, sizeof(query), "SELECT AccountId FROM Players WHERE Name LIKE '%s'", arg);
509
510 int userid = GetClientUserId(client);
511
512 DataPack hNameOrIpPack = new DataPack();
513 hNameOrIpPack.WriteCell(userid);
514 hNameOrIpPack.WriteString(arg);
515
516 g_hDatabase.Query(OnNameNamesGotAccountIdCMD, query, hNameOrIpPack);
517
518 return Plugin_Handled;
519}
520
521static Action OnSteamId2NamesCMD(int client, any args)
522{
523 if (args != 1)
524 {
525 if (g_iPrintChat == 1 || client)
526 CPrintToChat(client, "[{green}!{default}] {blue}Usage: {default}sm_steamid2names {olive}<Steam2ID>");
527 if (g_iPrintConsole == 1)
528 PrintToConsole(client, "[!] Usage: sm_steamid2names <Steam2ID>");
529 if (g_iPrintServer == 1)
530 PrintToServer("[!] Usage: sm_steamid2names <Steam2ID>");
531 }
532 else
533 {
534 if (g_iPrintChat == 1 || client)
535 CPrintToChat(client, "{blue}[{green}!{blue}] {default}Searching...");
536 if (g_iPrintConsole == 1)
537 PrintToConsole(client, "[!] Searching...");
538 if (g_iPrintServer == 1)
539 PrintToServer("[!] Searching...");
540 }
541
542 int iAccountId;
543
544 char arg[256];
545 GetCmdArg(1, arg, sizeof(arg));
546
547 iAccountId = GetAccountIdByAny(client, arg, Arg_Steam2ID);
548
549 char query[256];
550 g_hDatabase.Format(query, sizeof(query), "SELECT DISTINCT Name FROM Players WHERE AccountID = '%i'", iAccountId);
551
552 int userid = GetClientUserId(client);
553
554 DataPack hNameOrIpPack = new DataPack();
555 hNameOrIpPack.WriteCell(userid);
556 hNameOrIpPack.WriteCell(Arg_Name);
557
558 g_hDatabase.Query(OnHistoryQuery, query, hNameOrIpPack);
559
560 return Plugin_Handled;
561}
562
563static Action OnSteamId3NamesCMD(int client, any args)
564{
565 if (args != 1)
566 {
567 if (g_iPrintChat == 1 || client)
568 CPrintToChat(client, "[{green}!{default}] {blue}Usage: {default}sm_steamid3names {olive}<Steam3ID>");
569 if (g_iPrintConsole == 1)
570 PrintToConsole(client, "[!] Usage: sm_steamid3names <Steam3ID>");
571 if (g_iPrintServer == 1)
572 PrintToServer("[!] Usage: sm_steamid3names <Steam3ID>");
573 }
574 else
575 {
576 if (g_iPrintChat == 1 || client)
577 CPrintToChat(client, "{blue}[{green}!{blue}] {default}Searching...");
578 if (g_iPrintConsole == 1)
579 PrintToConsole(client, "[!] Searching...");
580 if (g_iPrintServer == 1)
581 PrintToServer("[!] Searching...");
582 }
583
584 int iAccountId;
585
586 char arg[256];
587 GetCmdArg(1, arg, sizeof(arg));
588
589 iAccountId = GetAccountIdByAny(client, arg, Arg_Steam3ID);
590
591 char query[256];
592 g_hDatabase.Format(query, sizeof(query), "SELECT DISTINCT Name FROM Players WHERE AccountID = '%i'", iAccountId);
593
594 int userid = GetClientUserId(client);
595
596 DataPack hNameOrIpPack = new DataPack();
597 hNameOrIpPack.WriteCell(userid);
598 hNameOrIpPack.WriteCell(Arg_Name);
599
600 g_hDatabase.Query(OnHistoryQuery, query, hNameOrIpPack);
601
602 return Plugin_Handled;
603}
604
605static Action OnSteamId64NamesCMD(int client, any args)
606{
607 if (args != 1)
608 {
609 if (g_iPrintChat == 1 || client)
610 CPrintToChat(client, "[{green}!{default}] {blue}Usage: {default}sm_steamid64names {olive}<Steam64ID>");
611 if (g_iPrintConsole == 1)
612 PrintToConsole(client, "[!] Usage: sm_steamid64names <Steam64ID>");
613 if (g_iPrintServer == 1)
614 PrintToServer("[!] Usage: sm_steamid64names <Steam64ID>");
615 }
616 else
617 {
618 if (g_iPrintChat == 1 || client)
619 CPrintToChat(client, "{blue}[{green}!{blue}] {default}Searching...");
620 if (g_iPrintConsole == 1)
621 PrintToConsole(client, "[!] Searching...");
622 if (g_iPrintServer == 1)
623 PrintToServer("[!] Searching...");
624 }
625
626 int iAccountId;
627
628 char arg[256];
629 GetCmdArg(1, arg, sizeof(arg));
630
631 iAccountId = GetAccountIdByAny(client, arg, Arg_Steam64ID);
632
633 char query[256];
634 g_hDatabase.Format(query, sizeof(query), "SELECT DISTINCT Name FROM Players WHERE AccountID = '%i'", iAccountId);
635
636 int userid = GetClientUserId(client);
637
638 DataPack hNameOrIpPack = new DataPack();
639 hNameOrIpPack.WriteCell(userid);
640 hNameOrIpPack.WriteCell(Arg_Name);
641
642 g_hDatabase.Query(OnHistoryQuery, query, hNameOrIpPack);
643
644 return Plugin_Handled;
645}
646
647static Action OnNameIpsCMD(int client, any args)
648{
649 if (args != 1)
650 {
651 if (g_iPrintChat == 1 || client)
652 CPrintToChat(client, "[{green}!{default}] {blue}Usage: {default}sm_nameips {olive}<name>");
653 if (g_iPrintConsole == 1)
654 PrintToConsole(client, "[!] Usage: sm_nameips <name>");
655 if (g_iPrintServer == 1)
656 PrintToServer("[!] Usage: sm_nameips <name>");
657 }
658 else
659 {
660 if (g_iPrintChat == 1 || client)
661 CPrintToChat(client, "{blue}[{green}!{blue}] {default}Searching...");
662 if (g_iPrintConsole == 1)
663 PrintToConsole(client, "[!] Searching...");
664 if (g_iPrintServer == 1)
665 PrintToServer("[!] Searching...");
666 }
667
668 char arg[256];
669 GetCmdArg(1, arg, sizeof(arg));
670
671 char query[256];
672 g_hDatabase.Format(query, sizeof(query), "SELECT DISTINCT IP FROM Players WHERE Name LIKE '%s'", arg);
673
674 int userid = GetClientUserId(client);
675
676 DataPack hNameOrIpPack = new DataPack();
677 hNameOrIpPack.WriteCell(userid);
678 hNameOrIpPack.WriteCell(Arg_IP);
679
680 g_hDatabase.Query(OnHistoryQuery, query, hNameOrIpPack);
681
682 return Plugin_Handled;
683}
684
685static Action OnSteamId2IpsCMD(int client, any args)
686{
687 if (args != 1)
688 {
689 if (g_iPrintChat == 1 || client)
690 CPrintToChat(client, "[{green}!{default}] {blue}Usage: {default}sm_steamid2ips {olive}<Steam2ID>");
691 if (g_iPrintConsole == 1)
692 PrintToConsole(client, "[!] Usage: sm_steamid2ips <Steam2ID>");
693 if (g_iPrintServer == 1)
694 PrintToServer("[!] Usage: sm_steamid2ips <Steam2ID>");
695 }
696 else
697 {
698 if (g_iPrintChat == 1 || client)
699 CPrintToChat(client, "{blue}[{green}!{blue}] {default}Searching...");
700 if (g_iPrintConsole == 1)
701 PrintToConsole(client, "[!] Searching...");
702 if (g_iPrintServer == 1)
703 PrintToServer("[!] Searching...");
704 }
705
706 int iAccountId;
707
708 char arg[256];
709 GetCmdArg(1, arg, sizeof(arg));
710
711 iAccountId = GetAccountIdByAny(client, arg, Arg_Steam2ID);
712
713 char query[256];
714 g_hDatabase.Format(query, sizeof(query), "SELECT DISTINCT IP FROM Players WHERE AccountID = '%i'", iAccountId);
715
716 int userid = GetClientUserId(client);
717
718 DataPack hNameOrIpPack = new DataPack();
719 hNameOrIpPack.WriteCell(userid);
720 hNameOrIpPack.WriteCell(Arg_IP);
721
722 g_hDatabase.Query(OnHistoryQuery, query, hNameOrIpPack);
723
724 return Plugin_Handled;
725}
726
727static Action OnSteamId3IpsCMD(int client, any args)
728{
729 if (args != 1)
730 {
731 if (g_iPrintChat == 1 || client)
732 CPrintToChat(client, "[{green}!{default}] {blue}Usage: {default}sm_steamid3ips {olive}<Steam3ID>");
733 if (g_iPrintConsole == 1)
734 PrintToConsole(client, "[!] Usage: sm_steamid3ips <Steam3ID>");
735 if (g_iPrintServer == 1)
736 PrintToServer("[!] Usage: sm_steamid3ips <Steam3ID>");
737 }
738 else
739 {
740 if (g_iPrintChat == 1 || client)
741 CPrintToChat(client, "{blue}[{green}!{blue}] {default}Searching...");
742 if (g_iPrintConsole == 1)
743 PrintToConsole(client, "[!] Searching...");
744 if (g_iPrintServer == 1)
745 PrintToServer("[!] Searching...");
746 }
747
748 int iAccountId;
749
750 char arg[256];
751 GetCmdArg(1, arg, sizeof(arg));
752
753 iAccountId = GetAccountIdByAny(client, arg, Arg_Steam3ID);
754
755 char query[256];
756 g_hDatabase.Format(query, sizeof(query), "SELECT DISTINCT IP FROM Players WHERE AccountID = '%i'", iAccountId);
757
758 int userid = GetClientUserId(client);
759
760 DataPack hNameOrIpPack = new DataPack();
761 hNameOrIpPack.WriteCell(userid);
762 hNameOrIpPack.WriteCell(Arg_IP);
763
764 g_hDatabase.Query(OnHistoryQuery, query, hNameOrIpPack);
765
766 return Plugin_Handled;
767}
768
769static Action OnSteamId64IpsCMD(int client, any args)
770{
771 if (args != 1)
772 {
773 if (g_iPrintChat == 1 || client)
774 CPrintToChat(client, "[{green}!{default}] {blue}Usage: {default}sm_steamid64ips {olive}<Steam64ID>");
775 if (g_iPrintConsole == 1)
776 PrintToConsole(client, "[!] Usage: sm_steamid64ips <Steam64ID>");
777 if (g_iPrintServer == 1)
778 PrintToServer("[!] Usage: sm_steamid64ips <Steam64ID>");
779 }
780 else
781 {
782 if (g_iPrintChat == 1 || client)
783 CPrintToChat(client, "{blue}[{green}!{blue}] {default}Searching...");
784 if (g_iPrintConsole == 1)
785 PrintToConsole(client, "[!] Searching...");
786 if (g_iPrintServer == 1)
787 PrintToServer("[!] Searching...");
788 }
789
790 int iAccountId;
791
792 char arg[256];
793 GetCmdArg(1, arg, sizeof(arg));
794
795 iAccountId = GetAccountIdByAny(client, arg, Arg_Steam64ID);
796
797 char query[256];
798 g_hDatabase.Format(query, sizeof(query), "SELECT DISTINCT IP FROM Players WHERE AccountID = '%i'", iAccountId);
799
800 int userid = GetClientUserId(client);
801
802 DataPack hNameOrIpPack = new DataPack();
803 hNameOrIpPack.WriteCell(userid);
804 hNameOrIpPack.WriteCell(Arg_IP);
805
806 g_hDatabase.Query(OnHistoryQuery, query, hNameOrIpPack);
807
808 return Plugin_Handled;
809}
810
811static Action OnIpAllCMD(int client, any args)
812{
813 if (args != 1)
814 {
815 if (g_iPrintChat == 1 || client)
816 CPrintToChat(client, "[{green}!{default}] {blue}Usage: {default}sm_ipall {olive}<IP>");
817 if (g_iPrintConsole == 1)
818 PrintToConsole(client, "[!] Usage: sm_ipall <IP>");
819 if (g_iPrintServer == 1)
820 PrintToServer("[!] Usage: sm_ipall <IP>");
821 }
822 else
823 {
824 if (g_iPrintChat == 1 || client)
825 CPrintToChat(client, "{blue}[{green}!{blue}] {default}Searching...");
826 if (g_iPrintConsole == 1)
827 PrintToConsole(client, "[!] Searching...");
828 if (g_iPrintServer == 1)
829 PrintToServer("[!] Searching...");
830 }
831
832 char arg[256];
833 GetCmdArg(1, arg, sizeof(arg));
834
835 char query[256];
836 g_hDatabase.Format(query, sizeof(query), "SELECT DISTINCT Name, AccountId FROM Players WHERE IP = '%s'", arg);
837
838 int userid = GetClientUserId(client);
839
840 DataPack hSteamIdPack = new DataPack();
841 hSteamIdPack.WriteCell(userid);
842
843 g_hDatabase.Query(OnHistoryIpQuery, query, hSteamIdPack);
844
845 return Plugin_Handled;
846}
847
848////////////////////////////////////////////////////////////////
849// SQL Query Functions
850////////////////////////////////////////////////////////////////
851
852public void SQL_FirstConnect(Database db, const char[] error, any data)
853{
854 if (db == null || error[0] != '\0')
855 {
856 LogError("Database connect failure: %s", error);
857 return;
858 }
859
860 g_hDatabase = db;
861
862 g_hDatabase.SetCharset("utf8mb4");
863
864 g_hDatabase.Query(SQL_CreateAndInsertQuery, "CREATE TABLE IF NOT EXISTS `Players`("
865 ..."`IndexID` INT(1) NOT NULL AUTO_INCREMENT, "
866 ..."`Date` TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, "
867 ..."`AccountID` INT(1) NOT NULL, "
868 ..."`IP` varchar(16) NOT NULL, "
869 ..."`Name` varchar(256) NOT NULL, "
870 ..."UNIQUE INDEX `authId_IP_Name`(`AccountID`, `IP`, `Name`), "
871 ..."PRIMARY KEY(IndexID)"
872 ...") COLLATE 'utf8mb4_unicode_ci' ENGINE = InnoDB ROW_FORMAT = COMPRESSED;");
873
874 //g_hDatabase.Query(SQL_CreateAndInsertQuery, "SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));");
875}
876
877public void OnInfoQuery(Database db, DBResultSet results, const char[] sError, DataPack hPlayerInfoPack)
878{
879 char arg[256];
880 hPlayerInfoPack.Reset();
881 hPlayerInfoPack.ReadString(arg, sizeof(arg));
882 int userid = hPlayerInfoPack.ReadCell();
883 int iArgType = hPlayerInfoPack.ReadCell();
884 delete hPlayerInfoPack;
885
886 int client = GetClientOfUserId(userid);
887
888 if(db == null || results == null || sError[0] != '\0')
889 {
890 LogError("Database query failure: %s", sError);
891 return;
892 }
893
894 DataPack hInfoQuery = new DataPack();
895 int iRowAmount;
896
897 while (results.FetchRow())
898 {
899 char sNameBuffer1[MAX_NAME_LENGTH];
900 char sIPBuffer1[16];
901 char sAccountIdBuffer1[32];
902
903 results.FetchString(0, sNameBuffer1, sizeof(sNameBuffer1));
904 results.FetchString(1, sIPBuffer1, sizeof(sIPBuffer1));
905 results.FetchString(2, sAccountIdBuffer1, sizeof(sAccountIdBuffer1));
906
907 hInfoQuery.WriteString(sNameBuffer1);
908 hInfoQuery.WriteString(sIPBuffer1);
909 hInfoQuery.WriteString(sAccountIdBuffer1);
910
911 iRowAmount++;
912 }
913
914 if (results.RowCount != 0)
915 {
916 if (g_iPrintChat == 1 || client)
917 CPrintToChat(client, "[{green}!{default}]{blue}========================={default}[{green}!{default}]");
918 if (g_iPrintConsole == 1 || client)
919 PrintToConsole(client, "[!]=========================[!]");
920 if (g_iPrintServer == 1)
921 PrintToServer("[!]=========================[!]");
922
923 hInfoQuery.Reset();
924
925 for (int i = 0; i < iRowAmount; i++)
926 {
927 if (i != 0)
928 CPrintToChat(client, "{green}----------");
929
930 char sNameBuffer2[MAX_NAME_LENGTH];
931 char sIPBuffer2[16];
932 char sAccountIdBuffer2[32];
933 hInfoQuery.ReadString(sNameBuffer2, sizeof(sNameBuffer2));
934 hInfoQuery.ReadString(sIPBuffer2, sizeof(sIPBuffer2));
935 hInfoQuery.ReadString(sAccountIdBuffer2, sizeof(sAccountIdBuffer2));
936
937 int iAccountId = StringToInt(sAccountIdBuffer2);
938
939 char sSteamId2[32];
940 char sSteamId3[32];
941 char sSteamId64[64];
942
943 GetSteamId2ByAccountId(iAccountId, sSteamId2, sizeof(sSteamId2));
944 GetSteamId3ByAccountId(iAccountId, sSteamId3, sizeof(sSteamId3));
945 GetSteamId64ByAccountId(iAccountId, sSteamId64, sizeof(sSteamId64));
946
947 if (iArgType == Arg_Name || iArgType == Arg_IP)
948 {
949 if (g_iPrintChat == 1 || client)
950 {
951 CPrintToChat(client, "{default}Name {green}- {olive}%s", sNameBuffer2);
952 CPrintToChat(client, "{default}SteamID2 {green}- {olive}%s", sSteamId2);
953 CPrintToChat(client, "{default}SteamID3 {green}- {olive}%s", sSteamId3);
954 CPrintToChat(client, "{default}SteamID64 {green}- {olive}%s", sSteamId64);
955 CPrintToChat(client, "{default}IP {green}- {olive}%s", sIPBuffer2);
956 }
957
958 if (g_iPrintConsole == 1 || client)
959 {
960 PrintToConsole(client, "Name - %s", sNameBuffer2);
961 PrintToConsole(client, "SteamID2 - %s", sSteamId2);
962 PrintToConsole(client, "SteamID3 - %s", sSteamId3);
963 PrintToConsole(client, "SteamID64 - %s", sSteamId64);
964 PrintToConsole(client, "IP - %s", sIPBuffer2);
965 }
966
967 if (g_iPrintServer == 1)
968 {
969 PrintToServer("Name - %s", sNameBuffer2);
970 PrintToServer("SteamID2 - %s", sSteamId2);
971 PrintToServer("SteamID3 - %s", sSteamId3);
972 PrintToServer("SteamID64 - %s", sSteamId64);
973 PrintToServer("IP - %s", sIPBuffer2);
974 }
975 }
976 else
977 {
978 if (g_iPrintChat == 1 || client)
979 {
980 CPrintToChat(client, "{default}Last Name {green}- {olive}%s", sNameBuffer2);
981 CPrintToChat(client, "{default}SteamID2 {green}- {olive}%s", sSteamId2);
982 CPrintToChat(client, "{default}SteamID3 {green}- {olive}%s", sSteamId3);
983 CPrintToChat(client, "{default}SteamID64 {green}- {olive}%s", sSteamId64);
984 CPrintToChat(client, "{default}Last IP {green}- {olive}%s", sIPBuffer2);
985 }
986
987 if (g_iPrintConsole == 1)
988 {
989 PrintToConsole(client, "Last Name - %s", sNameBuffer2);
990 PrintToConsole(client, "SteamID2 - %s", sSteamId2);
991 PrintToConsole(client, "SteamID3 - %s", sSteamId3);
992 PrintToConsole(client, "SteamID64 - %s", sSteamId64);
993 PrintToConsole(client, "Last IP - %s", sIPBuffer2);
994 }
995
996 if (g_iPrintServer == 1)
997 {
998 PrintToServer("Last Name - %s", sNameBuffer2);
999 PrintToServer("SteamID2 - %s", sSteamId2);
1000 PrintToServer("SteamID3 - %s", sSteamId3);
1001 PrintToServer("SteamID64 - %s", sSteamId64);
1002 PrintToServer("Last IP - %s", sIPBuffer2);
1003 }
1004 }
1005 }
1006
1007 if (g_iPrintChat == 1 || client)
1008 CPrintToChat(client, "[{green}!{default}]{blue}========================={default}[{green}!{default}]");
1009 if (g_iPrintConsole == 1 || client)
1010 PrintToConsole(client, "[!]=========================[!]");
1011 if (g_iPrintServer == 1)
1012 PrintToServer("[!]=========================[!]");
1013 }
1014 else
1015 {
1016 if (iArgType == Arg_Name)
1017 {
1018 char query[256];
1019 g_hDatabase.Format(query, sizeof(query), "SELECT Name, IP, AccountID FROM Players WHERE Name LIKE '%%%s' GROUP BY `Players`.`AccountID` ORDER BY `Players`.`Date`", arg);
1020
1021 hPlayerInfoPack = new DataPack();
1022 hPlayerInfoPack.WriteString(arg);
1023 hPlayerInfoPack.WriteCell(userid);
1024
1025 g_hDatabase.Query(OnInfoQueryRetry1, query, hPlayerInfoPack);
1026 }
1027 else
1028 {
1029 if (g_iPrintChat == 1 || client)
1030 CPrintToChat(client, "[{green}!{default}] {red}No player found");
1031 if (g_iPrintConsole == 1)
1032 PrintToConsole(client, "[!] No player found");
1033 if (g_iPrintServer == 1)
1034 PrintToServer("[!] No player found");
1035 }
1036 }
1037
1038 delete hInfoQuery;
1039}
1040
1041public void OnInfoQueryRetry1(Database db, DBResultSet results, const char[] sError, DataPack hPlayerInfoPack)
1042{
1043 char arg[256];
1044 hPlayerInfoPack.Reset();
1045 hPlayerInfoPack.ReadString(arg, sizeof(arg));
1046 int userid = hPlayerInfoPack.ReadCell();
1047 delete hPlayerInfoPack;
1048
1049 int client = GetClientOfUserId(userid);
1050
1051 if(db == null || results == null || sError[0] != '\0')
1052 {
1053 LogError("Database query failure: %s", sError);
1054 return;
1055 }
1056
1057 DataPack hInfoQuery = new DataPack();
1058 int iRowAmount;
1059
1060 while (results.FetchRow())
1061 {
1062 char sNameBuffer1[MAX_NAME_LENGTH];
1063 char sIPBuffer1[16];
1064 char sAccountIdBuffer1[32];
1065
1066 results.FetchString(0, sNameBuffer1, sizeof(sNameBuffer1));
1067 results.FetchString(1, sIPBuffer1, sizeof(sIPBuffer1));
1068 results.FetchString(2, sAccountIdBuffer1, sizeof(sAccountIdBuffer1));
1069
1070 hInfoQuery.WriteString(sNameBuffer1);
1071 hInfoQuery.WriteString(sIPBuffer1);
1072 hInfoQuery.WriteString(sAccountIdBuffer1);
1073
1074 iRowAmount++;
1075 }
1076
1077 if (results.RowCount != 0)
1078 {
1079 if (g_iPrintChat == 1 || client)
1080 CPrintToChat(client, "[{green}!{default}]{blue}========================={default}[{green}!{default}]");
1081 if (g_iPrintConsole == 1 || client)
1082 PrintToConsole(client, "[!]=========================[!]");
1083 if (g_iPrintServer == 1)
1084 PrintToServer("[!]=========================[!]");
1085
1086 hInfoQuery.Reset();
1087
1088 for (int i = 0; i < iRowAmount; i++)
1089 {
1090 if (i != 0)
1091 CPrintToChat(client, "{green}----------");
1092
1093 char sNameBuffer2[MAX_NAME_LENGTH];
1094 char sIPBuffer2[16];
1095 char sAccountIdBuffer2[32];
1096 hInfoQuery.ReadString(sNameBuffer2, sizeof(sNameBuffer2));
1097 hInfoQuery.ReadString(sIPBuffer2, sizeof(sIPBuffer2));
1098 hInfoQuery.ReadString(sAccountIdBuffer2, sizeof(sAccountIdBuffer2));
1099
1100 int iAccountId = StringToInt(sAccountIdBuffer2);
1101
1102 char sSteamId2[32];
1103 char sSteamId3[32];
1104 char sSteamId64[64];
1105
1106 GetSteamId2ByAccountId(iAccountId, sSteamId2, sizeof(sSteamId2));
1107 GetSteamId3ByAccountId(iAccountId, sSteamId3, sizeof(sSteamId3));
1108 GetSteamId64ByAccountId(iAccountId, sSteamId64, sizeof(sSteamId64));
1109
1110 if (g_iPrintChat == 1 || client)
1111 {
1112 CPrintToChat(client, "{default}Name {green}- {olive}%s", sNameBuffer2);
1113 CPrintToChat(client, "{default}SteamID2 {green}- {olive}%s", sSteamId2);
1114 CPrintToChat(client, "{default}SteamID3 {green}- {olive}%s", sSteamId3);
1115 CPrintToChat(client, "{default}SteamID64 {green}- {olive}%s", sSteamId64);
1116 CPrintToChat(client, "{default}IP {green}- {olive}%s", sIPBuffer2);
1117 }
1118
1119 if (g_iPrintConsole == 1 || client)
1120 {
1121 PrintToConsole(client, "Name - %s", sNameBuffer2);
1122 PrintToConsole(client, "SteamID2 - %s", sSteamId2);
1123 PrintToConsole(client, "SteamID3 - %s", sSteamId3);
1124 PrintToConsole(client, "SteamID64 - %s", sSteamId64);
1125 PrintToConsole(client, "IP - %s", sIPBuffer2);
1126 }
1127
1128 if (g_iPrintServer == 1)
1129 {
1130 PrintToServer("Name - %s", sNameBuffer2);
1131 PrintToServer("SteamID2 - %s", sSteamId2);
1132 PrintToServer("SteamID3 - %s", sSteamId3);
1133 PrintToServer("SteamID64 - %s", sSteamId64);
1134 PrintToServer("IP - %s", sIPBuffer2);
1135 }
1136 }
1137
1138 if (g_iPrintChat == 1 || client)
1139 CPrintToChat(client, "[{green}!{default}]{blue}========================={default}[{green}!{default}]");
1140 if (g_iPrintConsole == 1 || client)
1141 PrintToConsole(client, "[!]=========================[!]");
1142 if (g_iPrintServer == 1)
1143 PrintToServer("[!]=========================[!]");
1144 }
1145 else
1146 {
1147 char query[256];
1148 g_hDatabase.Format(query, sizeof(query), "SELECT Name, IP, AccountID FROM Players WHERE Name LIKE '%s%' GROUP BY `Players`.`AccountID` ORDER BY `Players`.`Date`", arg);
1149
1150 hPlayerInfoPack = new DataPack();
1151 hPlayerInfoPack.WriteString(arg);
1152 hPlayerInfoPack.WriteCell(userid);
1153
1154 g_hDatabase.Query(OnInfoQueryRetry2, query, hPlayerInfoPack);
1155 }
1156
1157 delete hInfoQuery;
1158}
1159
1160public void OnInfoQueryRetry2(Database db, DBResultSet results, const char[] sError, DataPack hPlayerInfoPack)
1161{
1162 char arg[256];
1163 hPlayerInfoPack.Reset();
1164 hPlayerInfoPack.ReadString(arg, sizeof(arg));
1165 int userid = hPlayerInfoPack.ReadCell();
1166 delete hPlayerInfoPack;
1167
1168 int client = GetClientOfUserId(userid);
1169
1170 if(db == null || results == null || sError[0] != '\0')
1171 {
1172 LogError("Database query failure: %s", sError);
1173 return;
1174 }
1175
1176 if(db == null || results == null || sError[0] != '\0')
1177 {
1178 LogError("Database query failure: %s", sError);
1179 return;
1180 }
1181
1182 DataPack hInfoQuery = new DataPack();
1183 int iRowAmount;
1184
1185 while (results.FetchRow())
1186 {
1187 char sNameBuffer1[MAX_NAME_LENGTH];
1188 char sIPBuffer1[16];
1189 char sAccountIdBuffer1[32];
1190
1191 results.FetchString(0, sNameBuffer1, sizeof(sNameBuffer1));
1192 results.FetchString(1, sIPBuffer1, sizeof(sIPBuffer1));
1193 results.FetchString(2, sAccountIdBuffer1, sizeof(sAccountIdBuffer1));
1194
1195 hInfoQuery.WriteString(sNameBuffer1);
1196 hInfoQuery.WriteString(sIPBuffer1);
1197 hInfoQuery.WriteString(sAccountIdBuffer1);
1198
1199 iRowAmount++;
1200 }
1201
1202 if (results.RowCount != 0)
1203 {
1204 if (g_iPrintChat == 1 || client)
1205 CPrintToChat(client, "[{green}!{default}]{blue}========================={default}[{green}!{default}]");
1206 if (g_iPrintConsole == 1 || client)
1207 PrintToConsole(client, "[!]=========================[!]");
1208 if (g_iPrintServer == 1)
1209 PrintToServer("[!]=========================[!]");
1210
1211 hInfoQuery.Reset();
1212
1213 for (int i = 0; i < iRowAmount; i++)
1214 {
1215 if (i != 0)
1216 CPrintToChat(client, "{green}----------");
1217
1218 char sNameBuffer2[MAX_NAME_LENGTH];
1219 char sIPBuffer2[16];
1220 char sAccountIdBuffer2[32];
1221 hInfoQuery.ReadString(sNameBuffer2, sizeof(sNameBuffer2));
1222 hInfoQuery.ReadString(sIPBuffer2, sizeof(sIPBuffer2));
1223 hInfoQuery.ReadString(sAccountIdBuffer2, sizeof(sAccountIdBuffer2));
1224
1225 int iAccountId = StringToInt(sAccountIdBuffer2);
1226
1227 char sSteamId2[32];
1228 char sSteamId3[32];
1229 char sSteamId64[64];
1230
1231 GetSteamId2ByAccountId(iAccountId, sSteamId2, sizeof(sSteamId2));
1232 GetSteamId3ByAccountId(iAccountId, sSteamId3, sizeof(sSteamId3));
1233 GetSteamId64ByAccountId(iAccountId, sSteamId64, sizeof(sSteamId64));
1234
1235 if (g_iPrintChat == 1 || client)
1236 {
1237 CPrintToChat(client, "{default}Name {green}- {olive}%s", sNameBuffer2);
1238 CPrintToChat(client, "{default}SteamID2 {green}- {olive}%s", sSteamId2);
1239 CPrintToChat(client, "{default}SteamID3 {green}- {olive}%s", sSteamId3);
1240 CPrintToChat(client, "{default}SteamID64 {green}- {olive}%s", sSteamId64);
1241 CPrintToChat(client, "{default}IP {green}- {olive}%s", sIPBuffer2);
1242 }
1243
1244 if (g_iPrintConsole == 1 || client)
1245 {
1246 PrintToConsole(client, "Name - %s", sNameBuffer2);
1247 PrintToConsole(client, "SteamID2 - %s", sSteamId2);
1248 PrintToConsole(client, "SteamID3 - %s", sSteamId3);
1249 PrintToConsole(client, "SteamID64 - %s", sSteamId64);
1250 PrintToConsole(client, "IP - %s", sIPBuffer2);
1251 }
1252
1253 if (g_iPrintServer == 1)
1254 {
1255 PrintToServer("Name - %s", sNameBuffer2);
1256 PrintToServer("SteamID2 - %s", sSteamId2);
1257 PrintToServer("SteamID3 - %s", sSteamId3);
1258 PrintToServer("SteamID64 - %s", sSteamId64);
1259 PrintToServer("IP - %s", sIPBuffer2);
1260 }
1261 }
1262
1263 if (g_iPrintChat == 1 || client)
1264 CPrintToChat(client, "[{green}!{default}]{blue}========================={default}[{green}!{default}]");
1265 if (g_iPrintConsole == 1 || client)
1266 PrintToConsole(client, "[!]=========================[!]");
1267 if (g_iPrintServer == 1)
1268 PrintToServer("[!]=========================[!]");
1269 }
1270 else
1271 {
1272 char query[256];
1273 g_hDatabase.Format(query, sizeof(query), "SELECT Name, IP, AccountID FROM Players WHERE Name LIKE '%%%s%%' GROUP BY `Players`.`AccountID` ORDER BY `Players`.`Date`", arg);
1274
1275 hPlayerInfoPack = new DataPack();
1276 hPlayerInfoPack.WriteString(arg);
1277 hPlayerInfoPack.WriteCell(userid);
1278
1279 g_hDatabase.Query(OnInfoQueryRetry3, query, hPlayerInfoPack);
1280 }
1281
1282 delete hInfoQuery;
1283}
1284
1285public void OnInfoQueryRetry3(Database db, DBResultSet results, const char[] sError, DataPack hPlayerInfoPack)
1286{
1287 char arg[256];
1288 hPlayerInfoPack.Reset();
1289 hPlayerInfoPack.ReadString(arg, sizeof(arg));
1290 int userid = hPlayerInfoPack.ReadCell();
1291 delete hPlayerInfoPack;
1292
1293 int client = GetClientOfUserId(userid);
1294
1295 if(db == null || results == null || sError[0] != '\0')
1296 {
1297 LogError("Database query failure: %s", sError);
1298 return;
1299 }
1300
1301 if(db == null || results == null || sError[0] != '\0')
1302 {
1303 LogError("Database query failure: %s", sError);
1304 return;
1305 }
1306
1307 DataPack hInfoQuery = new DataPack();
1308 int iRowAmount;
1309
1310 while (results.FetchRow())
1311 {
1312 char sNameBuffer1[MAX_NAME_LENGTH];
1313 char sIPBuffer1[16];
1314 char sAccountIdBuffer1[32];
1315
1316 results.FetchString(0, sNameBuffer1, sizeof(sNameBuffer1));
1317 results.FetchString(1, sIPBuffer1, sizeof(sIPBuffer1));
1318 results.FetchString(2, sAccountIdBuffer1, sizeof(sAccountIdBuffer1));
1319
1320 hInfoQuery.WriteString(sNameBuffer1);
1321 hInfoQuery.WriteString(sIPBuffer1);
1322 hInfoQuery.WriteString(sAccountIdBuffer1);
1323
1324 iRowAmount++;
1325 }
1326
1327 if (results.RowCount != 0)
1328 {
1329 if (g_iPrintChat == 1 || client)
1330 CPrintToChat(client, "[{green}!{default}]{blue}========================={default}[{green}!{default}]");
1331 if (g_iPrintConsole == 1 || client)
1332 PrintToConsole(client, "[!]=========================[!]");
1333 if (g_iPrintServer == 1)
1334 PrintToServer("[!]=========================[!]");
1335
1336 hInfoQuery.Reset();
1337
1338 for (int i = 0; i < iRowAmount; i++)
1339 {
1340 if (i != 0)
1341 CPrintToChat(client, "{green}----------");
1342
1343 char sNameBuffer2[MAX_NAME_LENGTH];
1344 char sIPBuffer2[16];
1345 char sAccountIdBuffer2[32];
1346 hInfoQuery.ReadString(sNameBuffer2, sizeof(sNameBuffer2));
1347 hInfoQuery.ReadString(sIPBuffer2, sizeof(sIPBuffer2));
1348 hInfoQuery.ReadString(sAccountIdBuffer2, sizeof(sAccountIdBuffer2));
1349
1350 int iAccountId = StringToInt(sAccountIdBuffer2);
1351
1352 char sSteamId2[32];
1353 char sSteamId3[32];
1354 char sSteamId64[64];
1355
1356 GetSteamId2ByAccountId(iAccountId, sSteamId2, sizeof(sSteamId2));
1357 GetSteamId3ByAccountId(iAccountId, sSteamId3, sizeof(sSteamId3));
1358 GetSteamId64ByAccountId(iAccountId, sSteamId64, sizeof(sSteamId64));
1359
1360 if (g_iPrintChat == 1 || client)
1361 {
1362 CPrintToChat(client, "{default}Name {green}- {olive}%s", sNameBuffer2);
1363 CPrintToChat(client, "{default}SteamID2 {green}- {olive}%s", sSteamId2);
1364 CPrintToChat(client, "{default}SteamID3 {green}- {olive}%s", sSteamId3);
1365 CPrintToChat(client, "{default}SteamID64 {green}- {olive}%s", sSteamId64);
1366 CPrintToChat(client, "{default}IP {green}- {olive}%s", sIPBuffer2);
1367 }
1368
1369 if (g_iPrintConsole == 1 || client)
1370 {
1371 PrintToConsole(client, "Name - %s", sNameBuffer2);
1372 PrintToConsole(client, "SteamID2 - %s", sSteamId2);
1373 PrintToConsole(client, "SteamID3 - %s", sSteamId3);
1374 PrintToConsole(client, "SteamID64 - %s", sSteamId64);
1375 PrintToConsole(client, "IP - %s", sIPBuffer2);
1376 }
1377
1378 if (g_iPrintServer == 1)
1379 {
1380 PrintToServer("Name - %s", sNameBuffer2);
1381 PrintToServer("SteamID2 - %s", sSteamId2);
1382 PrintToServer("SteamID3 - %s", sSteamId3);
1383 PrintToServer("SteamID64 - %s", sSteamId64);
1384 PrintToServer("IP - %s", sIPBuffer2);
1385 }
1386 }
1387
1388 if (g_iPrintChat == 1 || client)
1389 CPrintToChat(client, "[{green}!{default}]{blue}========================={default}[{green}!{default}]");
1390 if (g_iPrintConsole == 1 || client)
1391 PrintToConsole(client, "[!]=========================[!]");
1392 if (g_iPrintServer == 1)
1393 PrintToServer("[!]=========================[!]");
1394 }
1395 else
1396 {
1397 if (g_iPrintChat == 1 || client)
1398 CPrintToChat(client, "[{green}!{default}] {red}No player found");
1399 if (g_iPrintConsole == 1)
1400 PrintToConsole(client, "[!] No player found");
1401 if (g_iPrintServer == 1)
1402 PrintToServer("[!] No player found");
1403 }
1404
1405 delete hInfoQuery;
1406}
1407
1408////////////////////////////////////////////////////////////////
1409
1410public void OnNameNamesGotAccountIdCMD(Database db, DBResultSet results, const char[] sError, DataPack hNameOrIpPack)
1411{
1412 hNameOrIpPack.Reset();
1413 int userid = hNameOrIpPack.ReadCell();
1414 char arg[MAX_NAME_LENGTH];
1415 hNameOrIpPack.ReadString(arg, sizeof(arg));
1416 delete hNameOrIpPack;
1417
1418 char sAccountId[32];
1419
1420 while (results.FetchRow())
1421 results.FetchString(0, sAccountId, sizeof(sAccountId));
1422
1423 hNameOrIpPack = new DataPack();
1424 hNameOrIpPack.WriteCell(userid);
1425 hNameOrIpPack.WriteString(arg);
1426
1427 if (results.RowCount != 0)
1428 {
1429 char query[256];
1430 g_hDatabase.Format(query, sizeof(query), "SELECT DISTINCT Name FROM Players WHERE AccountID = '%s'", sAccountId);
1431
1432 g_hDatabase.Query(OnHistoryQuery, query, hNameOrIpPack);
1433 }
1434 else
1435 {
1436 char query[256];
1437 g_hDatabase.Format(query, sizeof(query), "SELECT AccountId FROM Players WHERE Name LIKE '%%%s'", arg);
1438
1439 g_hDatabase.Query(OnNameNamesGotAccountIdCMDRetry1, query, hNameOrIpPack);
1440 }
1441}
1442
1443public void OnNameNamesGotAccountIdCMDRetry1(Database db, DBResultSet results, const char[] sError, DataPack hNameOrIpPack)
1444{
1445 hNameOrIpPack.Reset();
1446 int userid = hNameOrIpPack.ReadCell();
1447 char arg[MAX_NAME_LENGTH];
1448 hNameOrIpPack.ReadString(arg, sizeof(arg));
1449 delete hNameOrIpPack;
1450
1451 if(db == null || results == null || sError[0] != '\0')
1452 {
1453 LogError("Database query failure: %s", sError);
1454 return;
1455 }
1456
1457 char sAccountId[32];
1458
1459 while (results.FetchRow())
1460 results.FetchString(0, sAccountId, sizeof(sAccountId));
1461
1462 hNameOrIpPack = new DataPack();
1463 hNameOrIpPack.WriteCell(userid);
1464 hNameOrIpPack.WriteString(arg);
1465
1466
1467 if (results.RowCount != 0)
1468 {
1469 char query[256];
1470 g_hDatabase.Format(query, sizeof(query), "SELECT DISTINCT Name FROM Players WHERE AccountID = '%s'", sAccountId);
1471
1472 g_hDatabase.Query(OnHistoryQuery, query, hNameOrIpPack);
1473 }
1474 else
1475 {
1476 char query[256];
1477 g_hDatabase.Format(query, sizeof(query), "SELECT AccountId FROM Players WHERE Name LIKE '%s%'", arg);
1478
1479 g_hDatabase.Query(OnNameNamesGotAccountIdCMDRetry2, query, hNameOrIpPack);
1480 }
1481}
1482
1483public void OnNameNamesGotAccountIdCMDRetry2(Database db, DBResultSet results, const char[] sError, DataPack hNameOrIpPack)
1484{
1485 hNameOrIpPack.Reset();
1486 int userid = hNameOrIpPack.ReadCell();
1487 char arg[MAX_NAME_LENGTH];
1488 hNameOrIpPack.ReadString(arg, sizeof(arg));
1489
1490 delete hNameOrIpPack;
1491
1492 if(db == null || results == null || sError[0] != '\0')
1493 {
1494 LogError("Database query failure: %s", sError);
1495 return;
1496 }
1497
1498 if(db == null || results == null || sError[0] != '\0')
1499 {
1500 LogError("Database query failure: %s", sError);
1501 return;
1502 }
1503
1504 char sAccountId[32];
1505
1506 while (results.FetchRow())
1507 results.FetchString(0, sAccountId, sizeof(sAccountId));
1508
1509 hNameOrIpPack = new DataPack();
1510 hNameOrIpPack.WriteCell(userid);
1511 hNameOrIpPack.WriteString(arg);
1512
1513
1514 if (results.RowCount != 0)
1515 {
1516 char query[256];
1517 g_hDatabase.Format(query, sizeof(query), "SELECT DISTINCT Name FROM Players WHERE AccountID = '%s'", sAccountId);
1518
1519 g_hDatabase.Query(OnHistoryQuery, query, hNameOrIpPack);
1520 }
1521 else
1522 {
1523 char query[256];
1524 g_hDatabase.Format(query, sizeof(query), "SELECT AccountId FROM Players WHERE Name LIKE '%%%s%%'", arg);
1525
1526 g_hDatabase.Query(OnNameNamesGotAccountIdCMDRetry3, query, hNameOrIpPack);
1527 }
1528}
1529
1530public void OnNameNamesGotAccountIdCMDRetry3(Database db, DBResultSet results, const char[] sError, DataPack hNameOrIpPack)
1531{
1532 hNameOrIpPack.Reset();
1533 int userid = hNameOrIpPack.ReadCell();
1534 char arg[MAX_NAME_LENGTH];
1535 hNameOrIpPack.ReadString(arg, sizeof(arg));
1536 delete hNameOrIpPack;
1537
1538 int client = GetClientOfUserId(userid);
1539
1540 if(db == null || results == null || sError[0] != '\0')
1541 {
1542 LogError("Database query failure: %s", sError);
1543 return;
1544 }
1545
1546 if(db == null || results == null || sError[0] != '\0')
1547 {
1548 LogError("Database query failure: %s", sError);
1549 return;
1550 }
1551
1552 char sAccountId[32];
1553
1554 while (results.FetchRow())
1555 results.FetchString(0, sAccountId, sizeof(sAccountId));
1556
1557 hNameOrIpPack = new DataPack();
1558 hNameOrIpPack.WriteCell(userid);
1559
1560 if (results.RowCount != 0)
1561 {
1562 char query[256];
1563 g_hDatabase.Format(query, sizeof(query), "SELECT DISTINCT Name FROM Players WHERE AccountID = '%s'", sAccountId);
1564
1565 g_hDatabase.Query(OnHistoryQuery, query, hNameOrIpPack);
1566 }
1567 else
1568 {
1569 if (g_iPrintChat == 1 || client)
1570 CPrintToChat(client, "[{green}!{default}] {red}No player found");
1571 if (g_iPrintConsole == 1)
1572 PrintToConsole(client, "[!] No player found");
1573 if (g_iPrintServer == 1)
1574 PrintToServer("[!] No player found");
1575 }
1576}
1577
1578////////////////////////////////////////////////////////////////
1579
1580public void OnHistoryQuery(Database db, DBResultSet results, const char[] sError, DataPack hNameOrIpPack)
1581{
1582 hNameOrIpPack.Reset();
1583 int userid = hNameOrIpPack.ReadCell();
1584 delete hNameOrIpPack;
1585
1586 int client = GetClientOfUserId(userid);
1587
1588 if(db == null || results == null || sError[0] != '\0')
1589 {
1590 LogError("Database query failure: %s", sError);
1591 return;
1592 }
1593
1594 if (!client)
1595 return;
1596
1597 DataPack hNameOrIpHistory = new DataPack();
1598 int iNameOrIpHistoryAmount;
1599
1600 while (results.FetchRow())
1601 {
1602 char sNameOrIpBuffer1[MAX_NAME_LENGTH];
1603 results.FetchString(0, sNameOrIpBuffer1, sizeof(sNameOrIpBuffer1));
1604 hNameOrIpHistory.WriteString(sNameOrIpBuffer1);
1605 iNameOrIpHistoryAmount++;
1606 }
1607
1608 if (results.RowCount > 0)
1609 {
1610 hNameOrIpHistory.Reset();
1611
1612 if (g_iPrintChat == 1 || client)
1613 CPrintToChat(client, "[{green}!{default}]{blue}========================={default}[{green}!{default}]");
1614 if (g_iPrintConsole == 1 || client)
1615 PrintToConsole(client, "[!]=========================[!]");
1616 if (g_iPrintServer == 1)
1617 PrintToServer("[!]=========================[!]");
1618
1619 for (int i = 0; i < iNameOrIpHistoryAmount; i++)
1620 {
1621 char sNameOrIpBuffer2[MAX_NAME_LENGTH];
1622 hNameOrIpHistory.ReadString(sNameOrIpBuffer2, sizeof(sNameOrIpBuffer2));
1623
1624 if (g_iPrintChat == 1 || client)
1625 CPrintToChat(client, "{olive}%s", sNameOrIpBuffer2);
1626 if (g_iPrintConsole == 1)
1627 PrintToConsole(client, "%s", sNameOrIpBuffer2);
1628 if (g_iPrintServer == 1)
1629 PrintToServer("%s", sNameOrIpBuffer2);
1630 }
1631
1632 if (g_iPrintChat == 1 || client)
1633 CPrintToChat(client, "[{green}!{default}]{blue}========================={default}[{green}!{default}]");
1634 if (g_iPrintConsole == 1 || client)
1635 PrintToConsole(client, "[!]=========================[!]");
1636 if (g_iPrintServer == 1)
1637 PrintToServer("[!]=========================[!]");
1638 }
1639 else
1640 {
1641 if (g_iPrintChat == 1 || client)
1642 CPrintToChat(client, "[{green}!{default}] {red}No player found");
1643 if (g_iPrintConsole == 1)
1644 PrintToConsole(client, "[!] No player found");
1645 if (g_iPrintServer == 1)
1646 PrintToServer("[!] No player found");
1647 }
1648
1649 delete hNameOrIpHistory;
1650}
1651
1652////////////////////////////////////////////////////////////////
1653
1654public void OnHistoryIpQuery(Database db, DBResultSet results, const char[] sError, DataPack hSteamIdPack)
1655{
1656 hSteamIdPack.Reset();
1657 int userid = hSteamIdPack.ReadCell();
1658 delete hSteamIdPack;
1659
1660 int client = GetClientOfUserId(userid);
1661
1662 if(db == null || results == null || sError[0] != '\0')
1663 {
1664 LogError("Database query failure: %s", sError);
1665 return;
1666 }
1667
1668 if (!client)
1669 return;
1670
1671 DataPack hSteamIdHistory = new DataPack();
1672 int iSteamIdHistoryAmount;
1673
1674 while (results.FetchRow())
1675 {
1676 char sNameBuffer1[32];
1677 results.FetchString(0, sNameBuffer1, sizeof(sNameBuffer1));
1678 hSteamIdHistory.WriteString(sNameBuffer1);
1679
1680 char sSteamIdBuffer1[32];
1681 results.FetchString(1, sSteamIdBuffer1, sizeof(sSteamIdBuffer1));
1682 hSteamIdHistory.WriteString(sSteamIdBuffer1);
1683
1684 iSteamIdHistoryAmount++;
1685 }
1686
1687 if (results.RowCount > 0)
1688 {
1689 hSteamIdHistory.Reset();
1690
1691 if (g_iPrintChat == 1 || client)
1692 CPrintToChat(client, "[{green}!{default}]{blue}========================={default}[{green}!{default}]");
1693 if (g_iPrintConsole == 1 || client)
1694 PrintToConsole(client, "[!]=========================[!]");
1695 if (g_iPrintServer == 1)
1696 PrintToServer("[!]=========================[!]");
1697
1698 for (int i = 0; i < iSteamIdHistoryAmount; i++)
1699 {
1700 if (i != 0)
1701 {
1702 if (g_iPrintChat == 1 || client)
1703 CPrintToChat(client, "{green}----------");
1704 if (g_iPrintConsole == 1)
1705 PrintToConsole(client, "----------");
1706 if (g_iPrintServer == 1)
1707 PrintToServer("----------");
1708 }
1709
1710 char sNameBuffer2[MAX_NAME_LENGTH];
1711 hSteamIdHistory.ReadString(sNameBuffer2, sizeof(sNameBuffer2));
1712 char sSteamIdBuffer2[MAX_NAME_LENGTH];
1713 hSteamIdHistory.ReadString(sSteamIdBuffer2, sizeof(sSteamIdBuffer2));
1714
1715 int iAccountId = StringToInt(sSteamIdBuffer2);
1716 char sSteamId2[32];
1717 char sSteamId3[32];
1718 char sSteamId64[64];
1719
1720 GetSteamId2ByAccountId(iAccountId, sSteamId2, sizeof(sSteamId2));
1721 GetSteamId3ByAccountId(iAccountId, sSteamId3, sizeof(sSteamId3));
1722 GetSteamId64ByAccountId(iAccountId, sSteamId64, sizeof(sSteamId64));
1723
1724 if (g_iPrintChat == 1 || client)
1725 {
1726 CPrintToChat(client, "Name: {olive}%s"
1727 ..."\n{default}SteamId2: {olive}%s"
1728 ..."\n{default}SteamId3: {olive}%s"
1729 ..."\n{default}SteamId64: {olive}%s", sNameBuffer2, sSteamId2, sSteamId3, sSteamId64);
1730 }
1731
1732 if (g_iPrintConsole == 1)
1733 {
1734 PrintToConsole(client, "Name: %s"
1735 ..."\nSteamId2: %s"
1736 ..."\nSteamId3: %s"
1737 ..."\nSteamId64: %s", sNameBuffer2, sSteamId2, sSteamId3, sSteamId64);
1738 }
1739
1740 if (g_iPrintServer == 1)
1741 {
1742 PrintToServer("Name: %s"
1743 ..."\nSteamId2: %s"
1744 ..."\nSteamId3: %s"
1745 ..."\nSteamId64: %s", sNameBuffer2, sSteamId2, sSteamId3, sSteamId64);
1746 }
1747 }
1748
1749 if (g_iPrintChat == 1 || client)
1750 CPrintToChat(client, "[{green}!{default}]{blue}========================={default}[{green}!{default}]");
1751 if (g_iPrintConsole == 1 || client)
1752 PrintToConsole(client, "[!]=========================[!]");
1753 if (g_iPrintServer == 1)
1754 PrintToServer("[!]=========================[!]");
1755 }
1756 else
1757 {
1758 if (g_iPrintChat == 1 || client)
1759 CPrintToChat(client, "[{green}!{default}] {red}No player found");
1760 if (g_iPrintConsole == 1)
1761 PrintToConsole(client, "[!] No player found");
1762 if (g_iPrintServer == 1)
1763 PrintToServer("[!] No player found");
1764 }
1765
1766 delete hSteamIdHistory;
1767}
1768
1769////////////////////////////////////////////////////////////////
1770
1771public void OnHistoryAllQuery(Database db, DBResultSet results, const char[] sError, DataPack hHistoryAllPack)
1772{
1773 char arg[256];
1774 hHistoryAllPack.Reset();
1775 hHistoryAllPack.ReadString(arg, sizeof(arg));
1776 int userid = hHistoryAllPack.ReadCell();
1777 int iArgType = hHistoryAllPack.ReadCell();
1778 delete hHistoryAllPack;
1779
1780 int client = GetClientOfUserId(userid);
1781
1782 if(db == null || results == null || sError[0] != '\0')
1783 {
1784 LogError("Database query failure: %s", sError);
1785 return;
1786 }
1787
1788 if (!client)
1789 return;
1790
1791 DataPack hAllHistory = new DataPack();
1792 int iAllHistoryAmount;
1793
1794 while (results.FetchRow())
1795 {
1796 char sNameBuffer1[MAX_NAME_LENGTH];
1797 char sIPBuffer1[16];
1798 char sAccountIdBuffer1[32];
1799
1800 results.FetchString(0, sNameBuffer1, sizeof(sNameBuffer1));
1801 results.FetchString(1, sIPBuffer1, sizeof(sIPBuffer1));
1802 results.FetchString(2, sAccountIdBuffer1, sizeof(sAccountIdBuffer1));
1803
1804 hAllHistory.WriteString(sNameBuffer1);
1805 hAllHistory.WriteString(sIPBuffer1);
1806 hAllHistory.WriteString(sAccountIdBuffer1);
1807 iAllHistoryAmount++;
1808 }
1809
1810 if (results.RowCount != 0)
1811 {
1812 if (g_iPrintChat == 1 || client)
1813 CPrintToChat(client, "[{green}!{default}]{blue}========================={default}[{green}!{default}]");
1814 if (g_iPrintConsole == 1)
1815 PrintToConsole(client, "[!]=========================[!]");
1816 if (g_iPrintServer == 1)
1817 PrintToServer("[!]=========================[!]");
1818
1819 hAllHistory.Reset();
1820
1821 for (int i = 0; i < iAllHistoryAmount; i++)
1822 {
1823 if (i != 0)
1824 {
1825 if (g_iPrintChat == 1 || client)
1826 CPrintToChat(client, "{green}----------");
1827 if (g_iPrintConsole == 1)
1828 PrintToConsole(client, "----------");
1829 if (g_iPrintServer == 1)
1830 PrintToServer("----------");
1831 }
1832
1833 char sNameBuffer2[MAX_NAME_LENGTH];
1834 char sIPBuffer2[16];
1835 char sAccountIdBuffer2[32];
1836 hAllHistory.ReadString(sNameBuffer2, sizeof(sNameBuffer2));
1837 hAllHistory.ReadString(sIPBuffer2, sizeof(sIPBuffer2));
1838 hAllHistory.ReadString(sAccountIdBuffer2, sizeof(sAccountIdBuffer2));
1839
1840 int iAccountId = StringToInt(sAccountIdBuffer2);
1841
1842 char sSteamId2[32];
1843 char sSteamId3[32];
1844 char sSteamId64[64];
1845
1846 GetSteamId2ByAccountId(iAccountId, sSteamId2, sizeof(sSteamId2));
1847 GetSteamId3ByAccountId(iAccountId, sSteamId3, sizeof(sSteamId3));
1848 GetSteamId64ByAccountId(iAccountId, sSteamId64, sizeof(sSteamId64));
1849
1850 if (g_iPrintChat == 1 || client)
1851 {
1852 CPrintToChat(client, "{default}Name: {olive}%s", sNameBuffer2);
1853 CPrintToChat(client, "{default}SteamId2: {olive}%s", sSteamId2);
1854 CPrintToChat(client, "{default}SteamId3: {olive}%s", sSteamId3);
1855 CPrintToChat(client, "{default}SteamId64: {olive}%s", sSteamId64);
1856 CPrintToChat(client, "{default}IP: {olive}%s", sIPBuffer2);
1857 }
1858
1859 if (g_iPrintConsole == 1)
1860 {
1861 PrintToConsole(client, "Name: %s", sNameBuffer2);
1862 PrintToConsole(client, "SteamId2: %s", sSteamId2);
1863 PrintToConsole(client, "SteamId3: %s", sSteamId3);
1864 PrintToConsole(client, "SteamId64: %s", sSteamId64);
1865 PrintToConsole(client, "IP: %s", sIPBuffer2);
1866 }
1867
1868 if (g_iPrintServer == 1)
1869 {
1870 PrintToServer("Name: %s", sNameBuffer2);
1871 PrintToServer("SteamId2: %s", sSteamId2);
1872 PrintToServer("SteamId3: %s", sSteamId3);
1873 PrintToServer("SteamId64: %s", sSteamId64);
1874 PrintToServer("IP: %s", sIPBuffer2);
1875 }
1876 }
1877
1878 if (g_iPrintChat == 1 || client)
1879 CPrintToChat(client, "[{green}!{default}]{blue}========================={default}[{green}!{default}]");
1880 if (g_iPrintConsole == 1)
1881 PrintToConsole(client, "[!]=========================[!]");
1882 if (g_iPrintServer == 1)
1883 PrintToServer("[!]=========================[!]");
1884 }
1885 else
1886 {
1887 if (iArgType == Arg_Name)
1888 {
1889 char query[256];
1890 g_hDatabase.Format(query, sizeof(query), "SELECT Name, IP, AccountID FROM Players WHERE Name LIKE '%%%s' ORDER BY `Players`.`Date` DESC", arg);
1891
1892 hHistoryAllPack = new DataPack();
1893 hHistoryAllPack.WriteCell(userid);
1894 hHistoryAllPack.WriteString(arg);
1895
1896 g_hDatabase.Query(OnInfoQueryRetry1, query, hHistoryAllPack);
1897 }
1898 else
1899 {
1900 if (g_iPrintChat == 1 || client)
1901 CPrintToChat(client, "[{green}!{default}] {red}No player found");
1902 if (g_iPrintConsole == 1)
1903 PrintToConsole(client, "[!] No player found");
1904 if (g_iPrintServer == 1)
1905 PrintToServer("[!] No player found");
1906 }
1907 }
1908
1909 delete hAllHistory;
1910}
1911
1912public void OnHistoryAllQueryRetry1(Database db, DBResultSet results, const char[] sError, DataPack hHistoryAllPack)
1913{
1914 char arg[256];
1915 hHistoryAllPack.Reset();
1916 int userid = hHistoryAllPack.ReadCell();
1917 hHistoryAllPack.ReadString(arg, sizeof(arg));
1918 delete hHistoryAllPack;
1919
1920 int client = GetClientOfUserId(userid);
1921
1922 if(db == null || results == null || sError[0] != '\0')
1923 {
1924 LogError("Database query failure: %s", sError);
1925 return;
1926 }
1927
1928 DataPack hAllHistory = new DataPack();
1929 int iAllHistoryAmount;
1930
1931 while (results.FetchRow())
1932 {
1933 char sNameBuffer1[MAX_NAME_LENGTH];
1934 char sIPBuffer1[16];
1935 char sAccountIdBuffer1[32];
1936
1937 results.FetchString(0, sNameBuffer1, sizeof(sNameBuffer1));
1938 results.FetchString(1, sIPBuffer1, sizeof(sIPBuffer1));
1939 results.FetchString(2, sAccountIdBuffer1, sizeof(sAccountIdBuffer1));
1940
1941 hAllHistory.WriteString(sNameBuffer1);
1942 hAllHistory.WriteString(sIPBuffer1);
1943 hAllHistory.WriteString(sAccountIdBuffer1);
1944 iAllHistoryAmount++;
1945 }
1946
1947 if (results.RowCount != 0)
1948 {
1949 if (g_iPrintChat == 1 || client)
1950 CPrintToChat(client, "[{green}!{default}]{blue}========================={default}[{green}!{default}]");
1951 if (g_iPrintConsole == 1)
1952 PrintToConsole(client, "[!]=========================[!]");
1953 if (g_iPrintServer == 1)
1954 PrintToServer("[!]=========================[!]");
1955
1956 hAllHistory.Reset();
1957
1958 for (int i = 0; i < iAllHistoryAmount; i++)
1959 {
1960 if (i != 0)
1961 {
1962 if (g_iPrintChat == 1 || client)
1963 CPrintToChat(client, "{green}----------");
1964 if (g_iPrintConsole == 1)
1965 PrintToConsole(client, "----------");
1966 if (g_iPrintServer == 1)
1967 PrintToServer("----------");
1968 }
1969
1970 char sNameBuffer2[MAX_NAME_LENGTH];
1971 char sIPBuffer2[16];
1972 char sAccountIdBuffer2[32];
1973 hAllHistory.ReadString(sNameBuffer2, sizeof(sNameBuffer2));
1974 hAllHistory.ReadString(sIPBuffer2, sizeof(sIPBuffer2));
1975 hAllHistory.ReadString(sAccountIdBuffer2, sizeof(sAccountIdBuffer2));
1976
1977 int iAccountId = StringToInt(sAccountIdBuffer2);
1978
1979 char sSteamId2[32];
1980 char sSteamId3[32];
1981 char sSteamId64[64];
1982
1983 GetSteamId2ByAccountId(iAccountId, sSteamId2, sizeof(sSteamId2));
1984 GetSteamId3ByAccountId(iAccountId, sSteamId3, sizeof(sSteamId3));
1985 GetSteamId64ByAccountId(iAccountId, sSteamId64, sizeof(sSteamId64));
1986
1987 if (g_iPrintChat == 1 || client)
1988 {
1989 CPrintToChat(client, "{default}Name: {olive}%s", sNameBuffer2);
1990 CPrintToChat(client, "{default}SteamId2: {olive}%s", sSteamId2);
1991 CPrintToChat(client, "{default}SteamId3: {olive}%s", sSteamId3);
1992 CPrintToChat(client, "{default}SteamId64: {olive}%s", sSteamId64);
1993 CPrintToChat(client, "{default}IP: {olive}%s", sIPBuffer2);
1994 }
1995
1996 if (g_iPrintConsole == 1)
1997 {
1998 PrintToConsole(client, "Name: %s", sNameBuffer2);
1999 PrintToConsole(client, "SteamId2: %s", sSteamId2);
2000 PrintToConsole(client, "SteamId3: %s", sSteamId3);
2001 PrintToConsole(client, "SteamId64: %s", sSteamId64);
2002 PrintToConsole(client, "IP: %s", sIPBuffer2);
2003 }
2004
2005 if (g_iPrintServer == 1)
2006 {
2007 PrintToServer("Name: %s", sNameBuffer2);
2008 PrintToServer("SteamId2: %s", sSteamId2);
2009 PrintToServer("SteamId3: %s", sSteamId3);
2010 PrintToServer("SteamId64: %s", sSteamId64);
2011 PrintToServer("IP: %s", sIPBuffer2);
2012 }
2013 }
2014
2015 if (g_iPrintChat == 1 || client)
2016 CPrintToChat(client, "[{green}!{default}]{blue}========================={default}[{green}!{default}]");
2017 if (g_iPrintConsole == 1)
2018 PrintToConsole(client, "[!]=========================[!]");
2019 if (g_iPrintServer == 1)
2020 PrintToServer("[!]=========================[!]");
2021 }
2022 else
2023 {
2024 char query[256];
2025 g_hDatabase.Format(query, sizeof(query), "SELECT Name, IP, AccountID FROM Players WHERE Name LIKE '%s%' ORDER BY `Players`.`Date` DESC", arg);
2026
2027 hHistoryAllPack = new DataPack();
2028 hHistoryAllPack.WriteCell(userid);
2029 hHistoryAllPack.WriteString(arg);
2030
2031 g_hDatabase.Query(OnInfoQueryRetry2, query, hHistoryAllPack);
2032 }
2033
2034 delete hAllHistory;
2035}
2036
2037public void OnHistoryAllQueryRetry2(Database db, DBResultSet results, const char[] sError, DataPack hHistoryAllPack)
2038{
2039 char arg[256];
2040 hHistoryAllPack.Reset();
2041 int userid = hHistoryAllPack.ReadCell();
2042 hHistoryAllPack.ReadString(arg, sizeof(arg));
2043 delete hHistoryAllPack;
2044
2045 int client = GetClientOfUserId(userid);
2046
2047 if(db == null || results == null || sError[0] != '\0')
2048 {
2049 LogError("Database query failure: %s", sError);
2050 return;
2051 }
2052
2053 DataPack hAllHistory = new DataPack();
2054 int iAllHistoryAmount;
2055
2056 while (results.FetchRow())
2057 {
2058 char sNameBuffer1[MAX_NAME_LENGTH];
2059 char sIPBuffer1[16];
2060 char sAccountIdBuffer1[32];
2061
2062 results.FetchString(0, sNameBuffer1, sizeof(sNameBuffer1));
2063 results.FetchString(1, sIPBuffer1, sizeof(sIPBuffer1));
2064 results.FetchString(2, sAccountIdBuffer1, sizeof(sAccountIdBuffer1));
2065
2066 hAllHistory.WriteString(sNameBuffer1);
2067 hAllHistory.WriteString(sIPBuffer1);
2068 hAllHistory.WriteString(sAccountIdBuffer1);
2069 iAllHistoryAmount++;
2070 }
2071
2072 if (results.RowCount != 0)
2073 {
2074 if (g_iPrintChat == 1 || client)
2075 CPrintToChat(client, "[{green}!{default}]{blue}========================={default}[{green}!{default}]");
2076 if (g_iPrintConsole == 1)
2077 PrintToConsole(client, "[!]=========================[!]");
2078 if (g_iPrintServer == 1)
2079 PrintToServer("[!]=========================[!]");
2080
2081 hAllHistory.Reset();
2082
2083 for (int i = 0; i < iAllHistoryAmount; i++)
2084 {
2085 if (i != 0)
2086 {
2087 if (g_iPrintChat == 1 || client)
2088 CPrintToChat(client, "{green}----------");
2089 if (g_iPrintConsole == 1)
2090 PrintToConsole(client, "----------");
2091 if (g_iPrintServer == 1)
2092 PrintToServer("----------");
2093 }
2094
2095 char sNameBuffer2[MAX_NAME_LENGTH];
2096 char sIPBuffer2[16];
2097 char sAccountIdBuffer2[32];
2098 hAllHistory.ReadString(sNameBuffer2, sizeof(sNameBuffer2));
2099 hAllHistory.ReadString(sIPBuffer2, sizeof(sIPBuffer2));
2100 hAllHistory.ReadString(sAccountIdBuffer2, sizeof(sAccountIdBuffer2));
2101
2102 int iAccountId = StringToInt(sAccountIdBuffer2);
2103
2104 char sSteamId2[32];
2105 char sSteamId3[32];
2106 char sSteamId64[64];
2107
2108 GetSteamId2ByAccountId(iAccountId, sSteamId2, sizeof(sSteamId2));
2109 GetSteamId3ByAccountId(iAccountId, sSteamId3, sizeof(sSteamId3));
2110 GetSteamId64ByAccountId(iAccountId, sSteamId64, sizeof(sSteamId64));
2111
2112 if (g_iPrintChat == 1 || client)
2113 {
2114 CPrintToChat(client, "{default}Name: {olive}%s", sNameBuffer2);
2115 CPrintToChat(client, "{default}SteamId2: {olive}%s", sSteamId2);
2116 CPrintToChat(client, "{default}SteamId3: {olive}%s", sSteamId3);
2117 CPrintToChat(client, "{default}SteamId64: {olive}%s", sSteamId64);
2118 CPrintToChat(client, "{default}IP: {olive}%s", sIPBuffer2);
2119 }
2120
2121 if (g_iPrintConsole == 1)
2122 {
2123 PrintToConsole(client, "Name: %s", sNameBuffer2);
2124 PrintToConsole(client, "SteamId2: %s", sSteamId2);
2125 PrintToConsole(client, "SteamId3: %s", sSteamId3);
2126 PrintToConsole(client, "SteamId64: %s", sSteamId64);
2127 PrintToConsole(client, "IP: %s", sIPBuffer2);
2128 }
2129
2130 if (g_iPrintServer == 1)
2131 {
2132 PrintToServer("Name: %s", sNameBuffer2);
2133 PrintToServer("SteamId2: %s", sSteamId2);
2134 PrintToServer("SteamId3: %s", sSteamId3);
2135 PrintToServer("SteamId64: %s", sSteamId64);
2136 PrintToServer("IP: %s", sIPBuffer2);
2137 }
2138 }
2139
2140 if (g_iPrintChat == 1 || client)
2141 CPrintToChat(client, "[{green}!{default}]{blue}========================={default}[{green}!{default}]");
2142 if (g_iPrintConsole == 1)
2143 PrintToConsole(client, "[!]=========================[!]");
2144 if (g_iPrintServer == 1)
2145 PrintToServer("[!]=========================[!]");
2146 }
2147 else
2148 {
2149 char query[256];
2150 g_hDatabase.Format(query, sizeof(query), "SELECT Name, IP, AccountID FROM Players WHERE Name LIKE '%%%s%%' ORDER BY `Players`.`Date` DESC", arg);
2151
2152 hHistoryAllPack = new DataPack();
2153 hHistoryAllPack.WriteCell(userid);
2154 hHistoryAllPack.WriteString(arg);
2155
2156 g_hDatabase.Query(OnInfoQueryRetry3, query, hHistoryAllPack);
2157 }
2158
2159 delete hAllHistory;
2160}
2161
2162public void OnHistoryAllQueryRetry3(Database db, DBResultSet results, const char[] sError, DataPack hHistoryAllPack)
2163{
2164 char arg[256];
2165 hHistoryAllPack.Reset();
2166 int userid = hHistoryAllPack.ReadCell();
2167 hHistoryAllPack.ReadString(arg, sizeof(arg));
2168 delete hHistoryAllPack;
2169
2170 int client = GetClientOfUserId(userid);
2171
2172 if(db == null || results == null || sError[0] != '\0')
2173 {
2174 LogError("Database query failure: %s", sError);
2175 return;
2176 }
2177
2178 if(db == null || results == null || sError[0] != '\0')
2179 {
2180 LogError("Database query failure: %s", sError);
2181 return;
2182 }
2183
2184 DataPack hAllHistory = new DataPack();
2185 int iAllHistoryAmount;
2186
2187 while (results.FetchRow())
2188 {
2189 char sNameBuffer1[MAX_NAME_LENGTH];
2190 char sIPBuffer1[16];
2191 char sAccountIdBuffer1[32];
2192
2193 results.FetchString(0, sNameBuffer1, sizeof(sNameBuffer1));
2194 results.FetchString(1, sIPBuffer1, sizeof(sIPBuffer1));
2195 results.FetchString(2, sAccountIdBuffer1, sizeof(sAccountIdBuffer1));
2196
2197 hAllHistory.WriteString(sNameBuffer1);
2198 hAllHistory.WriteString(sIPBuffer1);
2199 hAllHistory.WriteString(sAccountIdBuffer1);
2200
2201 iAllHistoryAmount++;
2202 }
2203
2204 if (results.RowCount != 0)
2205 {
2206 if (g_iPrintChat == 1 || client)
2207 CPrintToChat(client, "[{green}!{default}]{blue}========================={default}[{green}!{default}]");
2208 if (g_iPrintConsole == 1)
2209 PrintToConsole(client, "[!]=========================[!]");
2210 if (g_iPrintServer == 1)
2211 PrintToServer("[!]=========================[!]");
2212
2213 hAllHistory.Reset();
2214
2215 for (int i = 0; i < iAllHistoryAmount; i++)
2216 {
2217 if (i != 0)
2218 {
2219 if (g_iPrintChat == 1 || client)
2220 CPrintToChat(client, "{green}----------");
2221 if (g_iPrintConsole == 1)
2222 PrintToConsole(client, "----------");
2223 if (g_iPrintServer == 1)
2224 PrintToServer("----------");
2225 }
2226
2227 char sNameBuffer2[MAX_NAME_LENGTH];
2228 char sIPBuffer2[16];
2229 char sAccountIdBuffer2[32];
2230 hAllHistory.ReadString(sNameBuffer2, sizeof(sNameBuffer2));
2231 hAllHistory.ReadString(sIPBuffer2, sizeof(sIPBuffer2));
2232 hAllHistory.ReadString(sAccountIdBuffer2, sizeof(sAccountIdBuffer2));
2233
2234 int iAccountId = StringToInt(sAccountIdBuffer2);
2235
2236 char sSteamId2[32];
2237 char sSteamId3[32];
2238 char sSteamId64[64];
2239
2240 GetSteamId2ByAccountId(iAccountId, sSteamId2, sizeof(sSteamId2));
2241 GetSteamId3ByAccountId(iAccountId, sSteamId3, sizeof(sSteamId3));
2242 GetSteamId64ByAccountId(iAccountId, sSteamId64, sizeof(sSteamId64));
2243
2244 if (g_iPrintChat == 1 || client)
2245 {
2246 CPrintToChat(client, "{default}Name: {olive}%s", sNameBuffer2);
2247 CPrintToChat(client, "{default}SteamId2: {olive}%s", sSteamId2);
2248 CPrintToChat(client, "{default}SteamId3: {olive}%s", sSteamId3);
2249 CPrintToChat(client, "{default}SteamId64: {olive}%s", sSteamId64);
2250 CPrintToChat(client, "{default}IP: {olive}%s", sIPBuffer2);
2251 }
2252
2253 if (g_iPrintConsole == 1)
2254 {
2255 PrintToConsole(client, "Name: %s", sNameBuffer2);
2256 PrintToConsole(client, "SteamId2: %s", sSteamId2);
2257 PrintToConsole(client, "SteamId3: %s", sSteamId3);
2258 PrintToConsole(client, "SteamId64: %s", sSteamId64);
2259 PrintToConsole(client, "IP: %s", sIPBuffer2);
2260 }
2261
2262 if (g_iPrintServer == 1)
2263 {
2264 PrintToServer("Name: %s", sNameBuffer2);
2265 PrintToServer("SteamId2: %s", sSteamId2);
2266 PrintToServer("SteamId3: %s", sSteamId3);
2267 PrintToServer("SteamId64: %s", sSteamId64);
2268 PrintToServer("IP: %s", sIPBuffer2);
2269 }
2270 }
2271
2272 if (g_iPrintChat == 1 || client)
2273 CPrintToChat(client, "[{green}!{default}]{blue}========================={default}[{green}!{default}]");
2274 if (g_iPrintConsole == 1)
2275 PrintToConsole(client, "[!]=========================[!]");
2276 if (g_iPrintServer == 1)
2277 PrintToServer("[!]=========================[!]");
2278 }
2279 else
2280 {
2281 if (g_iPrintChat == 1 || client)
2282 CPrintToChat(client, "[{green}!{default}] {red}No player found");
2283 if (g_iPrintConsole == 1)
2284 PrintToConsole(client, "[!] No player found");
2285 if (g_iPrintServer == 1)
2286 PrintToServer("[!] No player found");
2287 }
2288
2289 delete hAllHistory;
2290}
2291
2292////////////////////////////////////////////////////////////////
2293
2294public void SQL_CreateAndInsertQuery(Database db, DBResultSet results, const char[] sError, any data)
2295{
2296 if(db == null || results == null || sError[0] != '\0')
2297 {
2298 LogError("Database query failure: %s", sError);
2299 return;
2300 }
2301}
2302
2303////////////////////////////////////////////////////////////////
2304// SteamID Classification Functions
2305////////////////////////////////////////////////////////////////
2306
2307int GetArgType(const char[] arg)
2308{
2309 if (StrContains(arg, "STEAM_") != -1)
2310 return Arg_Steam2ID;
2311
2312 if (StrContains(arg, "U:1:") != -1)
2313 return Arg_Steam3ID;
2314
2315 if (IsIP(arg))
2316 return Arg_IP;
2317
2318 if (StringToInt(arg))
2319 return strlen(arg) > 16 ? Arg_Steam64ID : Arg_Steam32ID;
2320
2321 return Arg_Name;
2322}
2323
2324bool IsIP(const char[] arg)
2325{
2326 int iDots;
2327
2328 for (int i = 0; i < strlen(arg); i++)
2329 {
2330 if (arg[i] == '.')
2331 iDots++;
2332 if (!IsCharNumeric(arg[i]) && arg[i] != '.')
2333 return false;
2334 }
2335
2336 if (iDots == 3)
2337 return true;
2338
2339 return false;
2340}
2341
2342////////////////////////////////////////////////////////////////
2343// SteamID Convert Functions
2344////////////////////////////////////////////////////////////////
2345
2346stock int GetAccountIdByAny(int client, const char[] arg, int iArgType)
2347{
2348 int iAccountId;
2349
2350 if (GetArgType(arg) == Arg_Steam2ID)
2351 {
2352 iAccountId = GetAccountIdBySteamId2(arg);
2353
2354 if (arg[7] == '\0')
2355 {
2356 if (g_iPrintChat == 1 || client)
2357 {
2358 CPrintToChat(client, "{blue}[{default}!{blue}] {default}If you are trying to use a {blue}SteamID2\n"
2359 ..."{blue}[{default}!{blue}] {default}(i.e.: {olive}STEAM_0:1:191972089{default})\n"
2360 ..."{blue}[{default}!{blue}] {default}Don't forget the {green}\"quotes\"{default}!");
2361 }
2362
2363 if (g_iPrintConsole == 1)
2364 {
2365 PrintToConsole(client, "[!] If you are trying to use a SteamID2\n"
2366 ..."[!] (i.e.: STEAM_0:1:191972089)\n"
2367 ..."[!] Don't forget the \"quotes\"!");
2368 }
2369
2370 if (g_iPrintServer == 1)
2371 {
2372 PrintToServer("[!] If you are trying to use a SteamID2\n"
2373 ..."[!] (i.e.: STEAM_0:1:191972089)\n"
2374 ..."[!] Don't forget the \"quotes\"!");
2375 }
2376 }
2377
2378 return iAccountId;
2379 }
2380 else if (GetArgType(arg) == Arg_Steam3ID)
2381 {
2382 iAccountId = GetAccountIdBySteamId3(arg);
2383
2384 return iAccountId;
2385 }
2386 else if (GetArgType(arg) == Arg_Steam32ID)
2387 {
2388 iAccountId = StringToInt(arg);
2389
2390 return iAccountId;
2391 }
2392 else if (GetArgType(arg) == Arg_Steam64ID)
2393 {
2394 iAccountId = GetAccountIdBySteamId64(arg);
2395
2396 return iAccountId;
2397 }
2398 else if (GetArgType(arg) == Arg_Name)
2399 {
2400 if (arg[0] == 'U' && arg[1] == '\0')
2401 {
2402 if (g_iPrintChat == 1 || client)
2403 {
2404 CPrintToChat(client, "{blue}[{default}!{blue}] {default}If you are trying to use a {blue}SteamID3\n"
2405 ..."{blue}[{default}!{blue}] {default}(i.e.: {olive}U:1:383944179{default})\n"
2406 ..."{blue}[{default}!{blue}] {default}Don't forget the {green}\"quotes\"{default}!");
2407 }
2408
2409 if (g_iPrintConsole == 1)
2410 {
2411 PrintToConsole(client, "[!] If you are trying to use a SteamID3\n"
2412 ..."[!] (i.e.: U:1:383944179)\n"
2413 ..."[!] Don't forget the \"quotes\"!");
2414 }
2415
2416 if (g_iPrintServer == 1)
2417 {
2418 PrintToServer("[!] If you are trying to use a SteamID3\n"
2419 ..."[!] (i.e.: U:1:383944179)\n"
2420 ..."[!] Don't forget the \"quotes\"!");
2421 }
2422 }
2423 else if (arg[0] == '[' && arg[1] == 'U' && arg[2] == '\0')
2424 {
2425 if (g_iPrintChat == 1 || client)
2426 {
2427 CPrintToChat(client, "{blue}[{default}!{blue}] {default}If you are trying to use a {blue}SteamID3\n"
2428 ..."{blue}[{default}!{blue}] {default}(i.e.: {olive}[U:1:383944179]{default})\n"
2429 ..."{blue}[{default}!{blue}] {default}Don't forget the {green}\"quotes\"{default}!");
2430 }
2431
2432 if (g_iPrintConsole == 1)
2433 {
2434 PrintToConsole(client, "[!] If you are trying to use a SteamID3\n"
2435 ..."[!] (i.e.: [U:1:383944179])\n"
2436 ..."[!] Don't forget the \"quotes\"!");
2437 }
2438
2439 if (g_iPrintServer == 1)
2440 {
2441 PrintToServer("[!] If you are trying to use a SteamID3\n"
2442 ..."[!] (i.e.: [U:1:383944179])\n"
2443 ..."[!] Don't forget the \"quotes\"!");
2444 }
2445 }
2446
2447 return 0;
2448 }
2449
2450 return 0;
2451}
2452
2453stock int GetAccountIdBySteamId2(const char[] sSteamID2)
2454{
2455 char sBuffer[3][12];
2456 ExplodeString(sSteamID2, ":", sBuffer, sizeof(sBuffer), sizeof(sBuffer[]));
2457
2458 return StringToInt(sBuffer[1]) + (StringToInt(sBuffer[2]) << 1);
2459}
2460
2461stock int GetAccountIdBySteamId3(const char[] sSteamID3)
2462{
2463 char sBuffer[19];
2464 strcopy(sBuffer, sizeof(sBuffer), sSteamID3);
2465
2466 int iBuffer = strlen(sBuffer) - 1;
2467
2468 if (sBuffer[iBuffer] == ']')
2469 sBuffer[iBuffer] = '\0';
2470
2471 return StringToInt(sBuffer[FindCharInString(sBuffer, ':', true) + 1]);
2472}
2473
2474stock int GetAccountIdBySteamId64(const char[] sSteam64)
2475{
2476 static const char sBase[] = "76561197960265728";
2477 int iBorrow = 0;
2478 char sAccount[17];
2479 int iTemp;
2480
2481 for (int i = 16; i >= 0; --i)
2482 {
2483 if (iBorrow > 0)
2484 {
2485 iTemp = (sSteam64[i] - '0') - 1;
2486
2487 if (iTemp >= (sBase[i] - '0'))
2488 {
2489 iBorrow = 0;
2490 sAccount[i] = (iTemp - ((sBase[i]) - '0')) + '0';
2491 }
2492 else
2493 {
2494 iBorrow = 1;
2495 sAccount[i] = ((iTemp + 10) - (sBase[i] - '0')) + '0';
2496 }
2497 }
2498 else
2499 {
2500 if ((sSteam64[i] - '0') >= (sBase[i] - '0'))
2501 {
2502 iBorrow = 0;
2503 sAccount[i] = ((sSteam64[i] - '0') - (sBase[i] - '0')) + '0';
2504 }
2505 else
2506 {
2507 iBorrow = 1;
2508 sAccount[i] = (((sSteam64[i] - '0') + 10) - (sBase[i] - '0') + '0');
2509 }
2510 }
2511 }
2512
2513 return StringToInt(sAccount);
2514}
2515
2516stock Action GetSteamId2ByAccountId(int iAccountId, char[] sSteamId2, int isizeof)
2517{
2518 EngineVersion e = GetEngineVersion();
2519 int iEngine = (e == Engine_Left4Dead || e == Engine_Left4Dead2 || Engine_CSGO);
2520 FormatEx(sSteamId2, isizeof, "STEAM_%i:%i:%i", iEngine, iAccountId % 2, iAccountId / 2);
2521}
2522
2523stock Action GetSteamId3ByAccountId(int iAccountId, char[] sSteamId3, int isizeof)
2524{
2525 FormatEx(sSteamId3, isizeof, "[U:1:%i]", iAccountId);
2526}
2527
2528stock void GetSteamId64ByAccountId(const int iAccountId, char[] sSteamId64, int isizeof)
2529{
2530 strcopy(sSteamId64, isizeof, "76561");
2531
2532 char sBuffer[11];
2533 FormatEx(sBuffer, sizeof(sBuffer), "%010u", iAccountId);
2534 FormatEx(sSteamId64[5], isizeof - 5, "%i", 1979 + 10 * (sBuffer[0] - '0') + sBuffer[1] - '0');
2535
2536 int iBuffer = StringToInt(sBuffer[2]) + 60265728;
2537
2538 if (iBuffer > 100000000)
2539 {
2540 iBuffer -= 100000000;
2541 ++sSteamId64[8];
2542
2543 for (int i = 8; i > 4; --i)
2544 {
2545 if ( sSteamId64[i] > '9')
2546 {
2547 sSteamId64[i] = '0';
2548 ++sSteamId64[i-1];
2549 }
2550 else
2551 {
2552 break;
2553 }
2554 }
2555 }
2556
2557 FormatEx(sSteamId64[9], isizeof - 9, "%i", iBuffer);
2558}
2559
2560////////////////////////////////////////////////////////////////