· 9 years ago · Feb 04, 2017, 09:38 PM
1/* *********************************************************************
2
3Thanks for people that help me:
4- dalto (http://forums.alliedmods.net/member.php?u=29575)
5
6
7Updates:
8 * Display FIX
9 * Query FIXES
10 * New: OLD STATS deleting
11 * Update TABLE on UTF8 and Setting NAMES to UTF8 on DatabaseConnect
12 * Changes in Database Connect
13 * New: Added "/headhunters"
14 * New: played_time, we will creat most active players TOP
15 * New: last_active ON this we will base is this player stats not to old.. (we dont want have BIG MySQL DataBase)
16 in future, maybe i will creat archive table, that there we will be have those player's, and they will be come back from archive when they will connect.
17 * Anti Flood Protection (new userFlood[64];)
18 * New announce message on: onClientPutInServer(client)
19 * WWW sie Cvar ("sm_lrcss_www",)
20 * PHP site nick protection:
21 [ ReplaceString(name, sizeof(name), "'", "");
22 ReplaceString(name, sizeof(name), "<", "");
23 ReplaceString(name, sizeof(name), "\"", "");
24]
25* Changed SQL_Query on SQL_TQuery Functions, Helper: - dalto
26* Added Debug Mode for MySQL Queries: new DEBUG = 0;
27* Added: char steamIdSave[64][255]; for Player Disconnect useage in: SQL_TQuery
28* Added: if(hndl == INVALID_HANDLE) function check in all: SQL_TQuery
29
30MySQL Query:
31
32CREATE TABLE `tf2ware_rank`(
33`rank_id` int(64) NOT NULL auto_increment,
34`steamId` varchar(32) NOT NULL default '',
35`nick` varchar(128) NOT NULL default '',
36`mg_won` int(12) NOT NULL default '0,
37`mg_lose` int(12) NOT NULL default '0,
38`bossstagewon` int(12) NOT NULL default '0,
39`totalwins` int(12) NOT NULL default '0,
40`last_active` int(12) NOT NULL default '0,
41`played_time` int(12) NOT NULL default '0,
42PRIMARY KEY (`rank_id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8;
43
44database.cfg
45
46 "tf2ware_rank"
47 {
48 "driver" "default"
49 "host" "127.0.0.1"
50 "database" "database_name"
51 "user" "database_user"
52 "pass" "PASSWORD"
53 //"timeout" "0"
54 "port" "3306"
55 }
56
57*************************************************************************** */
58
59// KOLOROWE KREDKI
60#define YELLOW 0x01
61#define GREEN 0x04
62
63// DEBUG MODE (1 = ON, 0 = OFF)
64
65int g_reconnectCounter = 0;
66Handle g_hSQL;
67// SOME DEFINES
68#define MAX_LINE_WIDTH 60
69
70// STATS TIME (SET DAYS AFTER STATS ARE DELETE OF NONACTIVE PLAYERS)
71#define PLAYER_STATSOLD 30
72char mg_id[255];
73char output3[255];
74// STATS DEFINATION FOR PLAYERS
75int MinigameWon[MAXPLAYERS+1];
76int MinigameLose[MAXPLAYERS+1];
77int BossStageWon[MAXPLAYERS+1];
78int TotalRoundWon[MAXPLAYERS+1];
79int userInit[MAXPLAYERS+1];
80int userFlood[MAXPLAYERS+1];
81int userPtime[MAXPLAYERS+1];
82int Mg_Query[MAXPLAYERS+1];
83char steamIdSave[MAXPLAYERS+1][255];
84
85// HANDLE OF DATABASE
86
87int ConnectSQL()
88{
89 if (g_hSQL != INVALID_HANDLE)
90 CloseHandle(g_hSQL);
91
92 g_hSQL = INVALID_HANDLE;
93
94 if (SQL_CheckConfig("tf2ware_rank"))
95 {
96 SQL_TConnect(ConnectSQLCallback, "tf2ware_rank");
97 }
98 else
99 {
100 SetFailState("PLUGIN STOPPED - Reason: no config entry found for 'tf2ware_rank' in databases.cfg - PLUGIN STOPPED");
101 }
102}
103
104public int ConnectSQLCallback(Handle owner, Handle hndl, const char[] error, any data)
105{
106 if (g_reconnectCounter >= 55)
107 {
108 SetFailState("PLUGIN STOPPED - Reason: reconnect counter reached max - PLUGIN STOPPED");
109 return;
110 }
111
112 if (hndl == INVALID_HANDLE)
113 {
114 LogError("[tf2ware_rank.smx] Connection to SQL database has failed, Try #%d, Reason: %s", g_reconnectCounter, error);
115 g_reconnectCounter++;
116 ConnectSQL();
117
118 return;
119 }
120
121 char driver[16];
122 SQL_GetDriverIdent(owner, driver, sizeof(driver));
123
124 g_hSQL = CloneHandle(hndl);
125
126 if (StrEqual(driver, "mysql", false))
127 {
128
129 SQL_TQuery(g_hSQL, CreateSQLTableCallback, "CREATE TABLE IF NOT EXISTS `tf2ware_rank` (`rank_id` INTEGER NOT NULL AUTO_INCREMENT, `steamid` varchar(32) NOT NULL, `nick` varchar(128) NOT NULL, `mg_won` INTEGER NOT NULL, `mg_lose` INTEGER NOT NULL, `bossstagewon` INTEGER NOT NULL, `totalwins` INTEGER NOT NULL, `last_active` INTEGER NOT NULL, `played_time` INTEGER NOT NULL, PRIMARY KEY (rank_id));");
130 char output[128];
131 char Query[255];
132 char Query2[255];
133 for (int i=0; i<sizeof(g_name); i++)
134 {
135 if (StrEqual(g_name[i], ""))
136 {
137 continue;
138 }
139 if(GetMinigameConfNum(g_name[i], "id") <= 9){
140 Format(output, sizeof(output), "%1d_%s", GetMinigameConfNum(g_name[i], "id"), g_name[i]);
141 }
142 if(GetMinigameConfNum(g_name[i], "id") >= 10){
143 Format(output, sizeof(output), "%2d_%s", GetMinigameConfNum(g_name[i], "id"), g_name[i]);
144 }
145 Format(Query, sizeof(Query), "ALTER TABLE `tf2ware_rank` ADD `%s` INTEGER NOT NULL;", output);
146 Format(Query2, sizeof(Query), "INSERT INTO registration (%s)", output);
147
148 SQL_TQuery(g_hSQL, CreateSQLTableCallback, Query);
149 SQL_TQuery(g_hSQL, CreateSQLTableCallback, Query2);
150 }
151 }
152 g_reconnectCounter = 1;
153}
154
155public int CreateSQLTableCallback(Handle owner, Handle hndl, const char[] error, any data)
156{
157 if (owner == INVALID_HANDLE)
158 {
159 g_reconnectCounter++;
160 ConnectSQL();
161
162 return;
163 }
164
165 if (hndl == INVALID_HANDLE)
166 {
167 return;
168 }
169}
170
171public int InitializeClient( int client )
172{
173 if (!IsFakeClient(client))
174 {
175 MinigameWon[client]=0;
176 MinigameLose[client]=0;
177 BossStageWon[client]=0;
178 TotalRoundWon[client]=0;
179 userFlood[client]=0;
180 userPtime[client]=GetTime();
181 char steamId[64];
182 GetClientAuthId(client, AuthId_Steam2, steamId, sizeof(steamId));
183 steamIdSave[client] = steamId;
184 //PrintToChatAll("client %s", steamId);
185 Mg_Query[client] = 0;
186 CreateTimer(1.0, initPlayerBase, client);
187 }
188}
189
190public Action initPlayerBase(Handle timer, any client){
191 if (g_hSQL != INVALID_HANDLE)
192 {
193 char buffer[200];
194 Format(buffer, sizeof(buffer), "SELECT * FROM tf2ware_rank WHERE steamId = '%s'", steamIdSave[client]);
195 //PrintToChatAll("DEBUG: Action:initPlayerBase (%s)", buffer);
196 SQL_TQuery(g_hSQL, SQLUserLoad, buffer, client);
197 }
198}
199public int saveUser(int client){
200 if ( !IsFakeClient(client) && userInit[client] == 1)
201 {
202 if (g_hSQL != INVALID_HANDLE)
203 {
204 char buffer[200];
205 Format(buffer, sizeof(buffer), "SELECT * FROM tf2ware_rank WHERE steamId = '%s'", steamIdSave[client]);
206 //PrintToChatAll("DEBUG: saveUser (%s)", buffer);
207
208 SQL_TQuery(g_hSQL, SQLUserSave, buffer, client);
209 }
210 }
211}
212
213public Action Command_Say(int client, int args){
214
215 char text[192]; char command[64];
216
217 int startidx = 0;
218
219 GetCmdArgString(text, sizeof(text));
220
221 if (text[strlen(text)-1] == '"')
222 {
223 text[strlen(text)-1] = '\0';
224 startidx = 1;
225 }
226 if (strcmp(command, "say2", false) == 0)
227
228 startidx += 4;
229
230 if (strcmp(text[startidx], "/rank", false) == 0) {
231 if(userFlood[client] != 1){
232 saveUser(client);
233 GetMyRank(client);
234 userFlood[client]=1;
235 CreateTimer(10.0, removeFlood, client);
236 } else {
237 PrintToChat(client,"%cDo not flood the server!", GREEN);
238 }
239 } else if (strcmp(text[startidx], "/top10", false) == 0)
240 {
241 if(userFlood[client] != 1){
242 saveUser(client);
243 showTOP(client);
244 userFlood[client]=1;
245 CreateTimer(10.0, removeFlood, client);
246 } else {
247 PrintToChat(client,"%cDo not flood the server!", GREEN);
248 }
249 } else if (strcmp(text[startidx], "/mg_list", false) == 0)
250 {
251 if(userFlood[client] != 1){
252 saveUser(client);
253 showTOPHeadHunter(client);
254 userFlood[client]=1;
255 CreateTimer(10.0, removeFlood, client);
256 } else {
257 PrintToChat(client,"%cDo not flood the server!", GREEN);
258 }
259 }
260 else if (strcmp(text[startidx], "/wlr", false) == 0)
261 {
262 if(userFlood[client] != 1){
263 saveUser(client);
264 GetMyWLR(client);
265 userFlood[client]=1;
266 CreateTimer(10.0, removeFlood, client);
267 } else {
268 PrintToChat(client,"%cDo not flood the server!", GREEN);
269 }
270 }
271 return Plugin_Continue;
272}
273
274public Action removeFlood(Handle timer, any client){
275 userFlood[client]=0;
276}
277public int GetMyWLR(int client){
278 if (g_hSQL != INVALID_HANDLE)
279 {
280 if(userInit[client] == 1){
281
282 char buffer[200];
283 Format(buffer, sizeof(buffer), "SELECT `mg_won`, `mg_lose`, `bossstagewon` FROM `tf2ware_rank` WHERE `steamId` = '%s' LIMIT 1", steamIdSave[client]);
284 //PrintToChatAll("DEBUG: GetMyWLR (%s)", buffer);
285 SQL_TQuery(g_hSQL, SQLGetMyWLR, buffer, client);
286
287 } else {
288
289 PrintToChat(client,"%cWait for system load you from database", GREEN);
290
291 }
292 } else {
293 PrintToChat(client, "%cWLR System is now not avilable", GREEN);
294 }
295}
296public int GetMyRank(int client){
297 if (g_hSQL != INVALID_HANDLE)
298 {
299 if(userInit[client] == 1){
300 char buffer[200];
301 Format(buffer, sizeof(buffer), "SELECT `mg_won`, `mg_lose`, `bossstagewon`, `totalwins` FROM `tf2ware_rank` WHERE `steamId` = '%s' LIMIT 50", steamIdSave[client]);
302 //PrintToChatAll("DEBUG: GetMyRank (%s)", buffer);
303 SQL_TQuery(g_hSQL, SQLGetMyRank, buffer, client);
304
305 } else {
306
307 PrintToChat(client,"%cWait for system load you from database", GREEN);
308
309 }
310 } else {
311 PrintToChat(client, "%cRank System is now not avilable", GREEN);
312 }
313}
314public int GetWinnerPoints(int client){
315 if (g_hSQL != INVALID_HANDLE)
316 {
317 if(userInit[client] == 1){
318
319 char buffer[200];
320 Format(buffer, sizeof(buffer), "SELECT `totalwins` FROM `tf2ware_rank` WHERE `steamId` = '%s' LIMIT 1", steamIdSave[client]);
321 //PrintToChatAll("DEBUG: GetMyRank (%s)", buffer);
322 SQL_TQuery(g_hSQL, SQLGetWinnerPoints, buffer, client);
323
324 } else {
325
326 PrintToChat(client,"%cWait for system load you from database", GREEN);
327
328 }
329 } else {
330 PrintToChat(client, "%cRank System is now not avilable", GREEN);
331 }
332}
333
334public int showTOP(int client){
335
336 if (g_hSQL != INVALID_HANDLE)
337 {
338 char buffer[200];
339 //Format(buffer, sizeof(buffer), "SELECT *, (`mg_lose`/`mg_won`) / `played_time` AS rankn FROM `tf2ware_rank` WHERE `mg_won` > 0 AND `mg_lose` > 0 ORDER BY rankn ASC LIMIT 10");
340 Format(buffer, sizeof(buffer), "SELECT * FROM tf2ware_rank ORDER BY totalwins DESC LIMIT 10");
341 //PrintToChatAll("DEBUG: showTOP (%s)", buffer);
342 SQL_TQuery(g_hSQL, SQLTopShow, buffer, client);
343 } else {
344 PrintToChat(client, "%cRank System is now not avilable", GREEN);
345 }
346}
347
348public int showTOPHeadHunter(int client){
349
350 if (g_hSQL != INVALID_HANDLE)
351 {
352 char buffer[200];
353 Format(buffer, sizeof(buffer), "SELECT * FROM tf2ware_rank WHERE steamId = '%s'", steamIdSave[client]);
354 SQL_TQuery(g_hSQL, SQLMg_WinList, buffer, client);
355 } else {
356 PrintToChat(client, "%cRank System is now not avilable", GREEN);
357 }
358}
359
360public int TopMenu(Menu menu, MenuAction action, int param1, int param2)
361{
362}
363
364// ================================================================================
365
366public int SQLErrorCheckCallback(Handle owner, Handle hndl, const char[] error, any data)
367{
368 if(!StrEqual("", error))
369 {
370 //PrintToChatAll("Last Connect SQL Error: %s", error);
371 }
372}
373
374
375public int SQLUserLoad(Handle owner, Handle hndl, const char[] error, any client){
376 if (!IsClientInGame(client)) return;
377 if(SQL_FetchRow(hndl))
378 {
379 char name[MAX_LINE_WIDTH];
380 GetClientName( client, name, sizeof(name) );
381
382 ReplaceString(name, sizeof(name), "'", "");
383 ReplaceString(name, sizeof(name), "<", "");
384 ReplaceString(name, sizeof(name), "\"", "");
385
386 char buffer[512];
387 Format(buffer, sizeof(buffer), "UPDATE tf2ware_rank SET nick = '%s', last_active = '%i' WHERE steamId = '%s'", name, GetTime(), steamIdSave[client]);
388 //PrintToChatAll("DEBUG: SQLUserLoad (%s)", buffer);
389 SQL_TQuery(g_hSQL, SQLErrorCheckCallback, buffer);
390
391 userInit[client] = 1;
392 } else {
393
394 char name[MAX_LINE_WIDTH];
395 char buffer[200];
396
397 GetClientName( client, name, sizeof(name) );
398
399 ReplaceString(name, sizeof(name), "'", "");
400 ReplaceString(name, sizeof(name), "<", "");
401 ReplaceString(name, sizeof(name), "\"", "");
402
403 Format(buffer, sizeof(buffer), "INSERT INTO tf2ware_rank (steamId, nick, last_active) VALUES('%s','%s', '%i')", steamIdSave[client], name, GetTime());
404 //PrintToChatAll("DEBUG: SQLUserLoad (%s)", buffer);
405 SQL_TQuery(g_hSQL, SQLErrorCheckCallback, buffer);
406
407 userInit[client] = 1;
408 }
409}
410
411public int SQLUserSave(Handle owner, Handle hndl, const char[] error, any client){
412 if(hndl == INVALID_HANDLE)
413 {
414 LogError(error);
415 //PrintToChatAll("Last Connect SQL Error: %s", error);
416 return;
417 }
418
419 int QueryReadRow_MGWON;
420 int QueryReadRow_MGLOSE;
421 int QueryReadRow_BOSSWON;
422 int QueryReadRow_TOTALROUNDS;
423 int QueryReadRow_PTIME;
424 int QueryReadRow_MGQUERY;
425 int mg_id2 = 8+iMinigame;
426 if(SQL_FetchRow(hndl))
427 {
428 QueryReadRow_MGWON=SQL_FetchInt(hndl,3) + MinigameWon[client];
429 QueryReadRow_MGLOSE=SQL_FetchInt(hndl,4) + MinigameLose[client];
430 QueryReadRow_BOSSWON=SQL_FetchInt(hndl,5) + BossStageWon[client];
431 QueryReadRow_TOTALROUNDS=SQL_FetchInt(hndl,6) + TotalRoundWon[client];
432 QueryReadRow_PTIME=SQL_FetchInt(hndl,8) + GetTime() - userPtime[client];
433 QueryReadRow_MGQUERY=SQL_FetchInt(hndl,mg_id2) + MinigameWon[client];
434 MinigameWon[client] = 0;
435 MinigameLose[client] = 0;
436 BossStageWon[client] = 0;
437 TotalRoundWon[client] = 0;
438 Mg_Query[client] = 0;
439 userPtime[client] = GetTime();
440 char buffer[512];
441 Format(buffer, sizeof(buffer), "UPDATE tf2ware_rank SET mg_won = '%i', mg_lose = '%i', bossstagewon = '%i', totalwins = '%i', played_time = '%i', %s = '%i' WHERE steamId = '%s'", QueryReadRow_MGWON, QueryReadRow_MGLOSE, QueryReadRow_BOSSWON, QueryReadRow_TOTALROUNDS, QueryReadRow_PTIME, output2, QueryReadRow_MGQUERY, steamIdSave[client]);
442
443
444 //PrintToChatAll("DEBUG: SQLUserSave (%s)", buffer);
445 SQL_TQuery(g_hSQL, SQLErrorCheckCallback, buffer);
446 }
447
448}
449
450public int SQLGetMyWLR(Handle owner, Handle hndl, const char[] error, any client){
451 if(hndl == INVALID_HANDLE)
452 {
453 LogError(error);
454 //PrintToChatAll("Last Connect SQL Error: %s", error);
455 return;
456 }
457
458 int RAmgwon;
459 int RAmglose;
460 int RABossWon;
461
462 if(SQL_FetchRow(hndl))
463 {
464 RAmgwon=SQL_FetchInt(hndl, 0);
465 RAmglose=SQL_FetchInt(hndl, 1);
466 RABossWon=SQL_FetchInt(hndl, 2);
467 char buffer[512];
468 float fmg_won = float(RAmgwon + RABossWon);
469 float fmg_lose = float(RAmglose);
470 float kpd = 0.0;
471 if (fmg_won <= 0 && fmg_lose <= 0)
472 {
473 return;
474 }
475 else if (fmg_won > 0 && fmg_lose <= 0)
476 {
477 kpd = fmg_won - fmg_lose;
478 }
479 else if (fmg_won > 0 && fmg_lose > 0)
480 {
481 kpd = fmg_won / fmg_lose;
482 }
483 Format(buffer, sizeof(buffer), "WinLoseRatio: %.2f , minigames won: %i, minigames losed: %i, Boss Stages Wons: %i", kpd, RAmgwon, RAmglose , RABossWon);
484 PrintToChat(client,"%cWin/Lose Rate (%s)", GREEN, buffer);
485 } else {
486 PrintToChat(client, "%cYour kpd is not avlilable!", GREEN);
487 }
488}
489public int SQLGetWinnerPoints(Handle owner, Handle hndl, const char[] error, any client){
490 if(hndl == INVALID_HANDLE)
491 {
492 LogError(error);
493 //PrintToChatAll("Last Connect SQL Error: %s", error);
494 return;
495 }
496 int RATotalwins;
497
498 if(SQL_FetchRow(hndl))
499 {
500 RATotalwins=SQL_FetchInt(hndl, 0) + TotalRoundWon[client];
501 TotalRoundWon[client]=0;
502 char buffer[512];
503 //PrintToChatAll("DEBUG: SQLGetMyRank (%s)", buffer);
504 if (RATotalwins <= 1)
505 {
506 CPrintToChatAllEx(client, "%T\x01 %T", "TF2WARE_RANK_PREFIX_COLOR", client, "NOTIFY_VICTORY_FIRST", client, client);
507 Format(buffer, sizeof(buffer), "%T\x01 %T ", "TF2WARE_RANK_PREFIX_COLOR", LANG_SERVER, "NOTIFY_VICTORY_FIRST", LANG_SERVER, client);
508 }
509 else
510 {
511 CPrintToChatAllEx(client, "%T\x01 %T ", "TF2WARE_RANK_PREFIX_COLOR", client, "NOTIFY_VICTORY", client, client, RATotalwins);
512 Format(buffer, sizeof(buffer), "%T\x01 %T ", "TF2WARE_RANK_PREFIX_COLOR", LANG_SERVER, "NOTIFY_VICTORY", LANG_SERVER, client, RATotalwins);
513 }
514 char savebuffer[255];
515 Format(savebuffer, sizeof(savebuffer), "UPDATE tf2ware_rank SET totalwins = '%i' WHERE steamId = '%s'", RATotalwins, steamIdSave[client]);
516 SQL_TQuery(g_hSQL, SQL_ErrorCheckCallBack, savebuffer, client);
517 Format(buffer, sizeof(buffer), "SELECT * FROM tf2ware_rank ORDER BY totalwins DESC LIMIT 50");
518 SQL_TQuery(g_hSQL, SQLShowWinner, savebuffer, client, DBPrio_High);
519 } else {
520 PrintToChat(client, "%cYour winner event not avlilable!", GREEN);
521 }
522}
523public int SQLGetMyRank(Handle owner, Handle hndl, const char[] error, any client){
524 if(hndl == INVALID_HANDLE)
525 {
526 LogError(error);
527 //PrintToChatAll("Last Connect SQL Error: %s", error);
528 return;
529 }
530
531 int RAmgwon;
532 int RAmglose;
533 int RABossWon;
534 int RATotalwins;
535
536 if(SQL_FetchRow(hndl))
537 {
538 RAmgwon=SQL_FetchInt(hndl, 0);
539 RAmglose=SQL_FetchInt(hndl, 1);
540 RABossWon=SQL_FetchInt(hndl, 2);
541 RATotalwins=SQL_FetchInt(hndl, 3);
542 char buffer[512];
543 Format(buffer, sizeof(buffer), "SELECT * FROM tf2ware_rank ORDER BY `totalwins` DESC LIMIT 50;");
544 //PrintToChatAll("DEBUG: SQLGetMyRank (%s)", buffer);
545 //SQL_TQuery(g_hSQL, SQLShowRank, buffer, client);
546 PrintToChat(client,"%cMinigame Won: %i | Minigame Failed: %i | Boss Stage Won: %i | Total TF2Ware Rounds Wins: %i", GREEN, RAmgwon, RAmglose, RABossWon, RATotalwins);
547 } else {
548 PrintToChat(client, "%cYour kpd is not avlilable!", GREEN);
549 }
550}
551public int SQLShowRank(Handle owner, Handle hndl, const char[] error, any client){
552 if (SQL_HasResultSet(hndl))
553 {
554 while (SQL_FetchRow(hndl))
555 {
556 int rows;
557 //SQL_FetchString(hndl, 2, name, sizeof(name));
558 //totalwins=SQL_FetchInt(hndl,6);
559 rows = SQL_GetRowCount(hndl);
560 PrintToChat(client,"%cYour rank is: %i.", GREEN, rows);
561 }
562 }
563}
564public int SQLShowWinner(Handle owner, Handle hndl, const char[] error, any client){
565 if (SQL_HasResultSet(hndl))
566 {
567 int rows = SQL_GetRowCount(hndl);
568 PrintToChat(client,"%cYour rank is: %i.", GREEN, rows);
569 }
570}
571public int SQLShowWLR(Handle owner, Handle hndl, const char[] error, any client){
572 if (SQL_HasResultSet(hndl))
573 {
574 int rows = SQL_GetRowCount(hndl);
575 PrintToChat(client,"%cYour rank is: %i.", GREEN, rows);
576 }
577}
578
579public int SQLTopShow(Handle owner, Handle hndl, const char[] error, any client){
580
581 if(hndl == INVALID_HANDLE)
582 {
583 LogError(error);
584 //PrintToChatAll("Last Connect SQL Error: %s", error);
585 return;
586 }
587 Panel panel = CreatePanel(GetMenuStyleHandle(MenuStyle_Radio));
588 char text[128];
589 Format(text,127,"TF2ware Rounds Top 10 Players");
590 SetPanelTitle(panel,text);
591
592 int row;
593 char name[64];
594 int totalwins;
595 if (SQL_HasResultSet(hndl))
596 {
597 while (SQL_FetchRow(hndl))
598 {
599 row++;
600 SQL_FetchString(hndl, 2, name, sizeof(name));
601 totalwins=SQL_FetchInt(hndl,6);
602 Format(text,127,"%d) %s Won %i times!", row, name, totalwins);
603 DrawPanelText(panel, text);
604 }
605 } else {
606 Format(text,127,"TF2ware Rounds TOP 10 is empty!");
607 DrawPanelText(panel, text);
608 }
609
610 DrawPanelItem(panel, " ", ITEMDRAW_SPACER|ITEMDRAW_RAWLINE);
611
612 Format(text,59,"Exit");
613 DrawPanelItem(panel, text);
614
615 SendPanelToClient(panel, client, TopMenu, 20);
616 //panel.Send(client, TopMenu, 20);
617
618 //delete panel
619
620 CloseHandle(panel);
621
622}
623public int SQLMg_WinList(Handle owner, Handle hndl, const char[] error, any client){
624
625 if(hndl == INVALID_HANDLE)
626 {
627 LogError(error);
628 //PrintToChatAll("Last Connect SQL Error: %s", error);
629 return;
630 }
631 Menu menu = new Menu(MenuHandler1);
632 //menu.SetTitle("%T", "Minigames win details", LANG_SERVER);
633 menu.SetTitle("Minigames win details");
634 char text[128];
635
636 int row;
637 //char name[64];
638 char mg_name[64];
639 int mg_Query;
640 //int ptimed;
641 //char textime[64];
642 int mg_id2;
643
644 if (SQL_HasResultSet(hndl))
645 {
646 while (SQL_FetchRow(hndl))
647 {
648 for (int i=0; i<sizeof(g_name); i++)
649 {
650 if (StrEqual(g_name[i], ""))
651 {
652 continue;
653 }
654 row++;
655 if(GetMinigameConfNum(g_name[i], "id") <= 9){
656 Format(output3, sizeof(output3), "%1d_%s", GetMinigameConfNum(g_name[i], "id"), g_name[i]);
657 }
658 if(GetMinigameConfNum(g_name[i], "id") >= 10){
659 Format(output3, sizeof(output3), "%2d_%s", GetMinigameConfNum(g_name[i], "id"), g_name[i]);
660 }
661 if(GetMinigameConfNum(g_name[i], "id") <= 9){
662 Format(mg_id, sizeof(mg_id), "%1d", GetMinigameConfNum(g_name[i], "id"));
663 }
664 if(GetMinigameConfNum(g_name[i], "id") >= 10){
665 Format(mg_id, sizeof(mg_id), "%2d", GetMinigameConfNum(g_name[i], "id"));
666 }
667 Format(mg_name, sizeof(mg_name), "%s", g_name[i]);
668 mg_id2 = StringToInt(mg_id);
669 //PrintToChatAll("NUMERO DI MERDA %i", mg_id2);
670 mg_Query=SQL_FetchInt(hndl, mg_id2 +8);
671 Format(text,127," %s : %i", mg_name, mg_Query);
672 menu.AddItem(text, text);
673 }
674 }
675 } else {
676 Format(text,127,"TOP BossStageWon is empty!");
677 menu.AddItem(text, text);
678 }
679 menu.ExitButton = false;
680 menu.Display(client, 20);
681
682}
683public int MenuHandler1(Menu menu, MenuAction action, int param1, int param2){}
684
685public int SQL_ErrorCheckCallBack(Handle owner, Handle hndl, const char[] error, any data)
686{
687 // This is just an errorcallback for function who normally don't return any data
688 if(hndl == INVALID_HANDLE)
689 {
690 SetFailState("Query failed! %s", error);
691 LogError("Didint connect to a detabase2!");
692 }
693}