· 6 years ago · Jan 11, 2020, 04:50 PM
1#pragma semicolon 1
2
3#include <sourcemod>
4#include <sdktools>
5#include <mostactive_month>
6
7#pragma newdecls required
8
9#define IDAYS 30
10
11int g_iPlayTimeSpec[MAXPLAYERS+1] = 0;
12int g_iPlayTimeT[MAXPLAYERS+1] = 0;
13int g_iPlayTimeCT[MAXPLAYERS+1] = 0;
14
15bool g_bChecked[MAXPLAYERS + 1];
16
17char g_sSQLBuffer[3096];
18
19bool g_bIsMySQl;
20
21Handle g_hDB = INVALID_HANDLE;
22Handle gF_OnInsertNewPlayer;
23
24int g_iHours;
25int g_iMinutes;
26int g_iSeconds;
27
28public Plugin myinfo =
29{
30 name = "[CSGO] Most Active Month",
31 author = "Franc1sco & Shanapu | Edited: somebody.",
32 description = "Most Active Month",
33 version = "1.0",
34 url = "http://sourcemod.net"
35};
36
37public APLRes AskPluginLoad2(Handle myself, bool late, char [] error, int err_max)
38{
39 CreateNative("MostActive_GetPlayTimeCTMonth", Native_GetPlayTimeCTMonth);
40 CreateNative("MostActive_GetPlayTimeTMonth", Native_GetPlayTimeTMonth);
41 CreateNative("MostActive_GetPlayTimeSpecMonth", Native_GetPlayTimeSpecMonth);
42 CreateNative("MostActive_GetPlayTimeTotalMonth", Native_GetPlayTimeTotalMonth);
43
44 gF_OnInsertNewPlayer = CreateGlobalForward("MostActive_OnInsertNewPlayerMonth", ET_Event, Param_Cell);
45
46 RegPluginLibrary("mostactive_month");
47
48 return APLRes_Success;
49}
50
51public void OnPluginStart()
52{
53 RegConsoleCmd("sm_activem", DOMenu);
54 RegAdminCmd("sm_wastedm", Command_Wasted, ADMFLAG_RESERVATION, "Wasted command");
55
56 int day, month, year;
57
58 char sday[2];
59 FormatTime(sday, sizeof(sday), "%d");
60 day = StringToInt(sday);
61
62 if (day == 1)
63 {
64 PruneDatabase();
65 }
66
67
68 SQL_TConnect(OnSQLConnect, "mostactive_month");
69}
70
71public int OnSQLConnect(Handle owner, Handle hndl, char [] error, any data)
72{
73 if(hndl == INVALID_HANDLE)
74 {
75 LogError("Database failure: %s", error);
76
77 SetFailState("Databases dont work");
78 }
79 else
80 {
81 g_hDB = hndl;
82
83 SQL_GetDriverIdent(SQL_ReadDriver(g_hDB), g_sSQLBuffer, sizeof(g_sSQLBuffer));
84 g_bIsMySQl = StrEqual(g_sSQLBuffer,"mysql", false) ? true : false;
85
86 if(g_bIsMySQl)
87 {
88 Format(g_sSQLBuffer, sizeof(g_sSQLBuffer), "CREATE TABLE IF NOT EXISTS `mostactive_month` (`playername` varchar(128) NOT NULL, `steamid` varchar(32) PRIMARY KEY NOT NULL,`last_accountuse` int(64) NOT NULL, `timeCT` INT( 16 ), `timeTT` INT( 16 ),`timeSPE` INT( 16 ), `total` INT( 16 ))");
89
90 SQL_TQuery(g_hDB, OnSQLConnectCallback, g_sSQLBuffer);
91 }
92 else
93 {
94 Format(g_sSQLBuffer, sizeof(g_sSQLBuffer), "CREATE TABLE IF NOT EXISTS mostactive_month (playername varchar(128) NOT NULL, steamid varchar(32) PRIMARY KEY NOT NULL,last_accountuse int(64) NOT NULL, timeCT INTEGER, timeTT INTEGER, timeSPE INTEGER, total INTEGER)");
95
96 SQL_TQuery(g_hDB, OnSQLConnectCallback, g_sSQLBuffer);
97 }
98 }
99}
100
101public int OnSQLConnectCallback(Handle owner, Handle hndl, char [] error, any data)
102{
103 if(hndl == INVALID_HANDLE)
104 {
105 LogError("Query failure: %s", error);
106 return;
107 }
108
109 for(int client = 1; client <= MaxClients; client++)
110 {
111 if(IsClientInGame(client))
112 {
113 OnClientPostAdminCheck(client);
114 }
115 }
116}
117
118public void InsertSQLNewPlayer(int client)
119{
120 char query[255], steamid[32];
121 GetClientAuthId(client, AuthId_Steam2,steamid, sizeof(steamid));
122 int userid = GetClientUserId(client);
123
124 char Name[MAX_NAME_LENGTH+1];
125 char SafeName[(sizeof(Name)*2)+1];
126 if(!GetClientName(client, Name, sizeof(Name)))
127 Format(SafeName, sizeof(SafeName), "<noname>");
128 else
129 {
130 TrimString(Name);
131 SQL_EscapeString(g_hDB, Name, SafeName, sizeof(SafeName));
132 }
133
134 Format(query, sizeof(query), "INSERT INTO mostactive_month(playername, steamid, last_accountuse, timeCT, timeTT, timeSPE, total) VALUES('%s', '%s', '%d', '0', '0', '0', '0');", SafeName, steamid, GetTime());
135 SQL_TQuery(g_hDB, SaveSQLPlayerCallback, query, userid);
136 g_iPlayTimeCT[client] = 0;
137 g_iPlayTimeT[client] = 0;
138 g_iPlayTimeSpec[client] = 0;
139
140 Call_StartForward(gF_OnInsertNewPlayer);
141 Call_PushCell(client);
142 Call_Finish();
143
144 g_bChecked[client] = true;
145}
146
147public int Native_GetPlayTimeCTMonth(Handle plugin, int argc)
148{
149 int client = GetNativeCell(1);
150
151 return g_iPlayTimeCT[client];
152}
153
154public int Native_GetPlayTimeTMonth(Handle plugin, int argc)
155{
156 int client = GetNativeCell(1);
157
158 return g_iPlayTimeT[client];
159}
160
161public int Native_GetPlayTimeSpecMonth(Handle plugin, int argc)
162{
163 int client = GetNativeCell(1);
164
165 return g_iPlayTimeSpec[client];
166}
167
168public int Native_GetPlayTimeTotalMonth(Handle plugin, int argc)
169{
170 int client = GetNativeCell(1);
171
172 return g_iPlayTimeSpec[client]+g_iPlayTimeCT[client]+g_iPlayTimeT[client];
173}
174
175public int SaveSQLPlayerCallback(Handle owner, Handle hndl, char [] error, any data)
176{
177 if(hndl == INVALID_HANDLE)
178 {
179 LogError("Query failure: %s", error);
180 }
181}
182
183public void CheckSQLSteamID(int client)
184{
185 char query[255], steamid[32];
186 GetClientAuthId(client, AuthId_Steam2,steamid, sizeof(steamid) );
187
188 Format(query, sizeof(query), "SELECT timeCT, timeTT, timeSPE FROM mostactive_month WHERE steamid = '%s'", steamid);
189 SQL_TQuery(g_hDB, CheckSQLSteamIDCallback, query, GetClientUserId(client));
190}
191
192public int CheckSQLSteamIDCallback(Handle owner, Handle hndl, char [] error, any data)
193{
194 int client;
195
196 if((client = GetClientOfUserId(data)) == 0)
197 {
198 return;
199 }
200
201 if(hndl == INVALID_HANDLE)
202 {
203 LogError("Query failure: %s", error);
204 return;
205 }
206 if(!SQL_GetRowCount(hndl) || !SQL_FetchRow(hndl))
207 {
208 InsertSQLNewPlayer(client);
209 return;
210 }
211
212 g_iPlayTimeCT[client] = SQL_FetchInt(hndl, 0);
213 g_iPlayTimeT[client] = SQL_FetchInt(hndl, 1);
214 g_iPlayTimeSpec[client] = SQL_FetchInt(hndl, 2);
215 g_bChecked[client] = true;
216}
217
218public void SaveSQLCookies(int client)
219{
220 char steamid[32];
221 GetClientAuthId(client, AuthId_Steam2,steamid, sizeof(steamid) );
222 char Name[MAX_NAME_LENGTH+1];
223 char SafeName[(sizeof(Name)*2)+1];
224 if(!GetClientName(client, Name, sizeof(Name)))
225 Format(SafeName, sizeof(SafeName), "<noname>");
226 else
227 {
228 TrimString(Name);
229 SQL_EscapeString(g_hDB, Name, SafeName, sizeof(SafeName));
230 }
231
232 char buffer[3096];
233 Format(buffer, sizeof(buffer), "UPDATE mostactive_month SET last_accountuse = %d, playername = '%s',timeCT = '%i',timeTT = '%i', timeSPE = '%i',total = '%i' WHERE steamid = '%s';",GetTime(), SafeName, g_iPlayTimeCT[client],g_iPlayTimeT[client],g_iPlayTimeSpec[client],g_iPlayTimeCT[client]+g_iPlayTimeT[client]+g_iPlayTimeSpec[client], steamid);
234 SQL_TQuery(g_hDB, SaveSQLPlayerCallback, buffer);
235 g_bChecked[client] = false;
236}
237
238public void OnPluginEnd()
239{
240 for(int client = 1; client <= MaxClients; client++)
241 {
242 if(IsClientInGame(client))
243 {
244 OnClientDisconnect(client);
245 }
246 }
247}
248
249public void OnClientDisconnect(int client)
250{
251 if(!IsFakeClient(client) && g_bChecked[client]) SaveSQLCookies(client);
252}
253
254public void OnClientPostAdminCheck(int client)
255{
256 if(!IsFakeClient(client)) CheckSQLSteamID(client);
257}
258
259public void PruneDatabase()
260{
261 if(g_hDB == INVALID_HANDLE)
262 {
263 return;
264 }
265
266 int maxlastaccuse;
267 maxlastaccuse = 1;
268
269 char buffer[1024];
270
271 if(g_bIsMySQl)
272 Format(buffer, sizeof(buffer), "DELETE FROM `mostactive_month` WHERE `last_accountuse`>'%d' AND `last_accountuse`>'0';", maxlastaccuse);
273 else
274 Format(buffer, sizeof(buffer), "DELETE FROM mostactive_month WHERE last_accountuse>'%d' AND last_accountuse>'0';", maxlastaccuse);
275
276 SQL_TQuery(g_hDB, PruneDatabaseCallback, buffer);
277}
278
279public int PruneDatabaseCallback(Handle owner, Handle hndl, char [] error, any data)
280{
281 if(hndl == INVALID_HANDLE)
282 {
283
284 }
285}
286
287public void OnMapStart()
288{
289 CreateTimer(1.0, PlayTimeTimer, _, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
290}
291
292public Action PlayTimeTimer(Handle timer)
293{
294 for(int i = 1; i <= MaxClients; i++)
295 {
296 if(IsClientInGame(i))
297 {
298 int team = GetClientTeam(i);
299
300 if(team == 2)
301 {
302 ++g_iPlayTimeT[i];
303 }
304 else if(team == 3)
305 {
306 ++g_iPlayTimeCT[i];
307 }
308 else
309 {
310 ++g_iPlayTimeSpec[i];
311 }
312 }
313 }
314}
315
316public void ShowTotal(int client)
317{
318 if(g_hDB != INVALID_HANDLE)
319 {
320 char buffer[200];
321 Format(buffer, sizeof(buffer), "SELECT playername, total, steamid FROM mostactive_month ORDER BY total DESC LIMIT 999");
322 SQL_TQuery(g_hDB, ShowTotalCallback, buffer, client);
323 }
324 else
325 {
326 PrintToChat(client, " \x03Rank System is now not avilable");
327 }
328}
329
330public int ShowTotalCallback(Handle owner, Handle hndl, char [] error, any client)
331{
332 if(hndl == INVALID_HANDLE)
333 {
334 LogError(error);
335 PrintToServer("Last Connect SQL Error: %s", error);
336 return;
337 }
338
339 Menu menu2 = CreateMenu(DIDMenuHandler2);
340 menu2.SetTitle("Ranglista");
341
342 int order = 0;
343 char number[64];
344 char name[64];
345 char textbuffer[128];
346 char steamid[128];
347
348 if(SQL_HasResultSet(hndl))
349 {
350 while (SQL_FetchRow(hndl))
351 {
352 order++;
353 Format(number,64, "option%i", order);
354 SQL_FetchString(hndl, 0, name, sizeof(name));
355 SQL_FetchString(hndl, 2, steamid, sizeof(steamid));
356 g_iHours = 0;
357 g_iMinutes = 0;
358 g_iSeconds = 0;
359 ShowTimer2(SQL_FetchInt(hndl, 1));
360 Format(textbuffer,128, "n%i %s - %d óra %d perc %d mp.", order,name,g_iHours, g_iMinutes, g_iSeconds);
361 menu2.AddItem(steamid, textbuffer);
362 }
363 }
364 if(order < 1)
365 {
366 menu2.AddItem("empty", "TOP is empty!");
367 }
368
369 menu2.ExitButton = true;
370 menu2.ExitBackButton = true;
371 menu2.Display(client,MENU_TIME_FOREVER);
372}
373
374public void ShowSpec(int client)
375{
376 if(g_hDB != INVALID_HANDLE)
377 {
378 char buffer[200];
379 Format(buffer, sizeof(buffer), "SELECT playername, timeSPE, steamid FROM mostactive_month ORDER BY timeSPE DESC LIMIT 999");
380 SQL_TQuery(g_hDB, ShowSpecCallback, buffer, client);
381 }
382 else
383 {
384 PrintToChat(client, " \x03Rank System is now not avilable");
385 }
386}
387
388public void ShowSpecCallback(Handle owner, Handle hndl, char [] error, any client)
389{
390 if(hndl == INVALID_HANDLE)
391 {
392 LogError(error);
393 PrintToServer("Last Connect SQL Error: %s", error);
394 return;
395 }
396
397 Menu menu2 = CreateMenu(DIDMenuHandler2);
398 menu2.SetTitle("Top Megfigyelő");
399
400 int order = 0;
401 char number[64];
402 char name[64];
403 char textbuffer[128];
404 char steamid[128];
405
406 if(SQL_HasResultSet(hndl))
407 {
408 while (SQL_FetchRow(hndl))
409 {
410 order++;
411 Format(number,64, "option%i", order);
412 SQL_FetchString(hndl, 0, name, sizeof(name));
413 SQL_FetchString(hndl, 2, steamid, sizeof(steamid));
414 g_iHours = 0;
415 g_iMinutes = 0;
416 g_iSeconds = 0;
417 ShowTimer2(SQL_FetchInt(hndl, 1));
418 Format(textbuffer,128, "n%i %s - %d óra %d perc %d mp.", order,name,g_iHours, g_iMinutes, g_iSeconds);
419 menu2.AddItem(steamid, textbuffer);
420 }
421 }
422 if(order < 1)
423 {
424 menu2.AddItem("empty", "TOP is empty!");
425 }
426
427 menu2.ExitButton = true;
428 menu2.ExitBackButton = true;
429 menu2.Display(client,MENU_TIME_FOREVER);
430}
431
432public void ShowTerror(int client)
433{
434 if(g_hDB != INVALID_HANDLE)
435 {
436 char buffer[200];
437 Format(buffer, sizeof(buffer), "SELECT playername, timeTT, steamid FROM mostactive_month ORDER BY timeTT DESC LIMIT 999");
438 SQL_TQuery(g_hDB, ShowTerrorCallback, buffer, client);
439 }
440 else
441 {
442 PrintToChat(client, " \x03Rank System is now not avilable");
443 }
444}
445
446public int ShowTerrorCallback(Handle owner, Handle hndl, char [] error, any client)
447{
448 if(hndl == INVALID_HANDLE)
449 {
450 LogError(error);
451 PrintToServer("Last Connect SQL Error: %s", error);
452 return;
453 }
454
455 Menu menu2 = CreateMenu(DIDMenuHandler2);
456 menu2.SetTitle("Top Terrorista");
457
458 int order = 0;
459 char number[64];
460 char name[64];
461 char textbuffer[128];
462 char steamid[128];
463
464 if(SQL_HasResultSet(hndl))
465 {
466 while (SQL_FetchRow(hndl))
467 {
468 order++;
469 Format(number,64, "option%i", order);
470 SQL_FetchString(hndl, 0, name, sizeof(name));
471 SQL_FetchString(hndl, 2, steamid, sizeof(steamid));
472 g_iHours = 0;
473 g_iMinutes = 0;
474 g_iSeconds = 0;
475 ShowTimer2(SQL_FetchInt(hndl, 1));
476 Format(textbuffer,128, "n%i %s - %d óra %d perc %d mp.", order,name,g_iHours, g_iMinutes, g_iSeconds);
477 menu2.AddItem(steamid, textbuffer);
478 }
479 }
480 if(order < 1)
481 {
482 menu2.AddItem("empty", "TOP is empty!");
483 }
484
485 menu2.ExitButton = true;
486 menu2.ExitBackButton = true;
487 menu2.Display(client,MENU_TIME_FOREVER);
488}
489
490public void ShowCT(int client)
491{
492 if(g_hDB != INVALID_HANDLE)
493 {
494 char buffer[200];
495 Format(buffer, sizeof(buffer), "SELECT playername, timeCT, steamid FROM mostactive_month ORDER BY timeCT DESC LIMIT 999");
496 SQL_TQuery(g_hDB, ShowCTCallback, buffer, client);
497 }
498 else
499 {
500 PrintToChat(client, " \x03Rank System is now not avilable");
501 }
502}
503
504public int ShowCTCallback(Handle owner, Handle hndl, char [] error, any client)
505{
506 if(hndl == INVALID_HANDLE)
507 {
508 LogError(error);
509 PrintToServer("Last Connect SQL Error: %s", error);
510 return;
511 }
512
513 Menu menu2 = CreateMenu(DIDMenuHandler2);
514 menu2.SetTitle("Top Terrorelhárító");
515
516
517 int order = 0;
518 char number[64];
519 char name[64];
520 char textbuffer[128];
521 char steamid[128];
522
523 if(SQL_HasResultSet(hndl))
524 {
525 while (SQL_FetchRow(hndl))
526 {
527 order++;
528 Format(number,64, "option%i", order);
529 SQL_FetchString(hndl, 0, name, sizeof(name));
530 SQL_FetchString(hndl, 2, steamid, sizeof(steamid));
531 g_iHours = 0;
532 g_iMinutes = 0;
533 g_iSeconds = 0;
534 ShowTimer2(SQL_FetchInt(hndl, 1));
535 Format(textbuffer,128, "n%i %s - %d óra %d perc %d mp.", order,name,g_iHours, g_iMinutes, g_iSeconds);
536 menu2.AddItem(steamid, textbuffer);
537 }
538 }
539 if(order < 1)
540 {
541 menu2.AddItem("empty", "TOP is empty!");
542 }
543
544 menu2.ExitButton = true;
545 menu2.ExitBackButton = true;
546 menu2.Display(client,MENU_TIME_FOREVER);
547}
548
549int ShowTimer(int Time, char[] buffer,int sizef)
550{
551 g_iHours = 0;
552 g_iMinutes = 0;
553 g_iSeconds = Time;
554
555 while(g_iSeconds > 3600)
556 {
557 g_iHours++;
558 g_iSeconds -= 3600;
559 }
560 while(g_iSeconds > 60)
561 {
562 g_iMinutes++;
563 g_iSeconds -= 60;
564 }
565 if(g_iHours >= 1)
566 {
567 Format(buffer, sizef, "%d óra %d perc %d mp.", g_iHours, g_iMinutes, g_iSeconds );
568 }
569 else if(g_iMinutes >= 1)
570 {
571 Format(buffer, sizef, "%d perc %d mp.", g_iMinutes, g_iSeconds );
572 }
573 else
574 {
575 Format(buffer, sizef, "%d mp.", g_iSeconds );
576 }
577}
578
579void ShowTimer2(int Time)
580{
581 g_iHours = 0;
582 g_iMinutes = 0;
583 g_iSeconds = Time;
584
585 while(g_iSeconds > 3600)
586 {
587 g_iHours++;
588 g_iSeconds -= 3600;
589 }
590 while(g_iSeconds > 60)
591 {
592 g_iMinutes++;
593 g_iSeconds -= 60;
594 }
595}
596
597bool GetCommunityID(char [] AuthID, char [] FriendID, int size)
598{
599 if(strlen(AuthID) < 11 || AuthID[0]!='S' || AuthID[6]=='I')
600 {
601 FriendID[0] = 0;
602 return false;
603 }
604 int iUpper = 765611979;
605 int iFriendID = StringToInt(AuthID[10])*2 + 60265728 + AuthID[8]-48;
606 int iDiv = iFriendID/100000000;
607 int iIdx = 9-(iDiv?iDiv/10+1:0);
608 iUpper += iDiv;
609 IntToString(iFriendID, FriendID[iIdx], size-iIdx);
610 iIdx = FriendID[9];
611 IntToString(iUpper, FriendID, size);
612 FriendID[9] = iIdx;
613 return true;
614}
615
616public int DIDMenuHandler2(Menu menu2, MenuAction action, int client, int itemNum)
617{
618 if( action == MenuAction_Select )
619 {
620 char info[128], community[128];
621
622 GetMenuItem(menu2, itemNum, info, sizeof(info));
623 GetCommunityID(info, community, sizeof(community));
624
625 Format(community, sizeof(community), " \x02[\x0BActive\x02] \x06http://steamcommunity.com/profiles/%s", community);
626 PrintToChat(client, community);
627 PrintToConsole(client, community);
628 }
629 else if(action == MenuAction_Cancel)
630 {
631 if(itemNum==MenuCancel_ExitBack)
632 {
633 DOMenu(client,0);
634 }
635 }
636 else if(action == MenuAction_End)
637 {
638 CloseHandle(menu2);
639 }
640}
641
642public Action DOMenu(int client, int args)
643{
644 if(args > 0)
645 {
646 char steamid[64];
647 GetCmdArgString(steamid, sizeof(steamid));
648
649 char buffer[200];
650 Format(buffer, sizeof(buffer), "SELECT timeCT, timeTT, timeSPE, total, playername FROM mostactive_month WHERE steamid = '%s'", steamid);
651 SQL_TQuery(g_hDB, SQLShowPlayTime, buffer, GetClientUserId(client));
652 }
653 else
654 {
655 Menu menu = CreateMenu(DIDMenuHandler);
656 menu.SetTitle("Szerver Játékidő - Havi");
657 menu.AddItem("option1", "Saját Idő");
658 menu.AddItem("option2", "Ranglista");
659 menu.AddItem("option4", "Top Terrorista");
660 menu.AddItem("option5", "Top Terrorelhárító");
661 menu.AddItem("option3", "Top Megfigyelő");
662 menu.ExitButton = true;
663 menu.Display(client,MENU_TIME_FOREVER);
664 }
665 return Plugin_Handled;
666}
667
668public int SQLShowPlayTime(Handle owner, Handle hndl, char [] error, any data)
669{
670 int client;
671
672 if((client = GetClientOfUserId(data)) == 0)
673 {
674 return;
675 }
676
677 if(hndl == INVALID_HANDLE)
678 {
679 LogError("Query failure: %s", error);
680 return;
681 }
682 if(!SQL_GetRowCount(hndl) || !SQL_FetchRow(hndl))
683 {
684 PrintToChat(client, " \x03SteamID not found in the database");
685 return;
686 }
687 char name[124];
688 SQL_FetchString(hndl, 4, name, 124);
689
690 Menu menu = CreateMenu(DIDMenuHandlerHandler);
691 menu.SetTitle("Havi szerver játékidő: %s\n ", name);
692
693 char buffer[124];
694
695 ShowTimer(SQL_FetchInt(hndl, 2), buffer, sizeof(buffer));
696 Format(buffer, 124, "Megfigyelő: %s", buffer);
697 menu.AddItem("", buffer, ITEMDRAW_DISABLED);
698
699 ShowTimer(SQL_FetchInt(hndl, 1), buffer, sizeof(buffer));
700 Format(buffer, 124, "Terrorista: %s", buffer);
701 menu.AddItem("", buffer, ITEMDRAW_DISABLED);
702
703 ShowTimer(SQL_FetchInt(hndl, 0), buffer, sizeof(buffer));
704 Format(buffer, 124, "Terrorelhárító: %s", buffer);
705 menu.AddItem("", buffer, ITEMDRAW_DISABLED);
706
707 ShowTimer(SQL_FetchInt(hndl, 3), buffer, sizeof(buffer));
708 Format(buffer, 124, "Havi összes játékidő: %s", buffer);
709 menu.AddItem("", buffer, ITEMDRAW_DISABLED);
710
711 menu.ExitButton = true;
712 menu.ExitBackButton = true;
713 menu.Display(client,MENU_TIME_FOREVER);
714}
715
716public int DIDMenuHandler(Menu menu, MenuAction action, int client, int itemNum)
717{
718 if( action == MenuAction_Select )
719 {
720 char info[32];
721
722 GetMenuItem(menu, itemNum, info, sizeof(info));
723
724 if( strcmp(info,"option1") == 0 )
725 {
726 Menu menu2 = CreateMenu(DIDMenuHandlerHandler);
727 menu2.SetTitle("Havi szerver játékidő: %N\n ", client);
728
729 char buffer[124];
730
731 ShowTimer(g_iPlayTimeSpec[client], buffer, sizeof(buffer));
732 Format(buffer, 124, "Megfigyelő: %s", buffer);
733 menu2.AddItem("", buffer, ITEMDRAW_DISABLED);
734
735 ShowTimer(g_iPlayTimeT[client], buffer, sizeof(buffer));
736 Format(buffer, 124, "Terrorista: %s", buffer);
737 menu2.AddItem("", buffer, ITEMDRAW_DISABLED);
738
739 ShowTimer(g_iPlayTimeCT[client], buffer, sizeof(buffer));
740 Format(buffer, 124, "Terrorelhárító: %s", buffer);
741 menu2.AddItem("", buffer, ITEMDRAW_DISABLED);
742
743 int totalt = (g_iPlayTimeT[client] + g_iPlayTimeCT[client] + g_iPlayTimeSpec[client]);
744 ShowTimer(totalt, buffer, sizeof(buffer));
745 Format(buffer, 124, "Havi összes játékidő: %s", buffer);
746 menu2.AddItem("", buffer, ITEMDRAW_DISABLED);
747 menu2.ExitButton = true;
748 menu2.ExitBackButton = true;
749 menu2.Display(client,MENU_TIME_FOREVER);
750 }
751 else if( strcmp(info,"option2") == 0 )
752 {
753 ShowTotal(client);
754 }
755 else if( strcmp(info,"option3") == 0 )
756 {
757 ShowSpec(client);
758 }
759 else if( strcmp(info,"option4") == 0 )
760 {
761 ShowTerror(client);
762 }
763 else if( strcmp(info,"option5") == 0 )
764 {
765 ShowCT(client);
766 }
767 }
768 if(action == MenuAction_Cancel)
769 {
770 if(itemNum==MenuCancel_ExitBack)
771 {
772 DOMenu(client,0);
773 }
774 }
775 else if(action == MenuAction_End)
776 {
777 CloseHandle(menu);
778 }
779}
780
781public int DIDMenuHandlerHandler(Menu menu, MenuAction action, int client, int itemNum)
782{
783 if(action == MenuAction_Cancel)
784 {
785 if(itemNum==MenuCancel_ExitBack)
786 {
787 DOMenu(client,0);
788 }
789 }
790 else if(action == MenuAction_End)
791 {
792 CloseHandle(menu);
793 }
794}
795
796public Action Command_Wasted(int client, int args)
797{
798 SQL_TQuery(g_hDB, SQLShowWasteTime, "SELECT sum(total) FROM mostactive_month");
799
800 return Plugin_Handled;
801}
802
803public int SQLShowWasteTime(Handle owner, Handle hndl, char [] error, any client)
804{
805 if(hndl == INVALID_HANDLE)
806 {
807 LogError("Query failure: %s", error);
808 return;
809 }
810
811 while (SQL_FetchRow(hndl))
812 {
813 char buffer[124];
814 ShowTimer(SQL_FetchInt(hndl, 0), buffer, sizeof(buffer));
815 PrintToChatAll(" \x02[\x0BActive\x02] \x06Összesen \x02%s \x06időt töltöttek eddig a játékosok a szerveren a hónapban.", buffer);
816 }
817
818 delete hndl;
819}