· 9 years ago · Dec 04, 2016, 06:12 PM
1// AuthId_Steam2, /**< Steam2 rendered format, ex "STEAM_1:1:4153990" */
2// AuthId_Steam3, /**< Steam3 rendered format, ex "[U:1:8307981]" */
3// AuthId_SteamID64, /**< A SteamID64 (uint64) as a String, ex "76561197968573709" */
4
5#include <sourcemod>
6#include <morecolors>
7#include <geoip>
8#define PLUGIN_VERSION "1.0.539"
9new Handle:db = INVALID_HANDLE;
10new totalCount;
11new String:NamePlayer[40];
12new ratingPlayer;
13new pointcountPlayer;
14new killPlayer;
15new deathPlayer;
16new RankSpeed;
17new SpeedPlayer;
18new DeflectPlayer;
19new SumDeflectPlayer;
20new playtimePlayer;
21new rank[MAXPLAYERS+1];
22new rating[MAXPLAYERS+1];
23new kills[MAXPLAYERS+1];
24new deaths[MAXPLAYERS+1];
25new speed[MAXPLAYERS+1];
26new deflect[MAXPLAYERS+1];
27new sumdeflect[MAXPLAYERS+1];
28new playtime[MAXPLAYERS+1];
29new sessionrating[MAXPLAYERS+1];
30new sessionkills[MAXPLAYERS+1];
31new sessiondeaths[MAXPLAYERS+1];
32new sessionplaytime[MAXPLAYERS+1]
33new String:ranklog[PLATFORM_MAX_PATH];
34public Plugin:myinfo =
35{
36 name = "Ranking",
37 author = "AJAX",
38 description = "Top players and top speed.",
39 version = PLUGIN_VERSION,
40 url = "ajax.com"
41};
42public OnPluginStart() {
43 decl String:error[256];
44 db = SQL_Connect("rank", true, error, sizeof(error));
45 if(db==INVALID_HANDLE) {
46 LogError("Could not connect to database: %s", error);
47 return;
48 }
49 SQL_TQuery(db, SQLErrorCheckCallback, "CREATE TABLE IF NOT EXISTS stats (steamid TEXT, name TEXT, rating INTEGER, kills INTEGER, deaths INTEGER, speed INTEGER, deflect INTEGER, sumdeflect INTEGER, playtime INTEGER)");
50 RegConsoleCmd("say", Command_say);
51 RegConsoleCmd("say_team", Command_say);
52 RegConsoleCmd("sm_top", Top_target, "Top_target.", 0);
53 RegConsoleCmd("sm_rank", Top_target, "Top_target.", 0);
54 RegConsoleCmd("sm_ts", Top_Speed, "Top_Speed.", 0);
55 HookEvent("player_death", Event_player_death);
56 CreateTimer(60.0, Name_Check, _, TIMER_REPEAT);
57 CreateTimer(60.0, Time_Update, _, TIMER_REPEAT);
58 new String:ftime[86];
59 FormatTime(ftime, sizeof(ftime), "logs/rank/logs%m-%d-%y.txt");
60 BuildPath(Path_SM, ranklog, sizeof(ranklog), ftime);
61}
62public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max)
63{
64 RegPluginLibrary("rank");
65 CreateNative("SetSpeed", Native_SetSpeed);
66 CreateNative("SetDeflect", Native_SetDeflect);
67 CreateNative("SetSumDeflect", Native_SetSumDeflect);
68 CreateNative("GetSpeed", Native_GetSpeed);
69 CreateNative("GetDeflect", Native_GetDeflect);
70 return APLRes_Success;
71}
72public Native_SetSpeed(Handle:plugin, params)
73{
74 decl String:SteamID[36], String:query[100];
75 new client = GetNativeCell(1);
76 speed[client] = GetNativeCell(2);
77 GetClientAuthId(client, AuthId_Steam2, SteamID, sizeof(SteamID));
78 Format(query, sizeof(query), "UPDATE stats SET speed='%i' WHERE steamid='%s'", speed[client], SteamID);
79 SQL_TQuery(db, SQLErrorCheckCallback, query);
80}
81public Native_SetDeflect(Handle:plugin, params)
82{
83 decl String:SteamID[36], String:query[100];
84 new client = GetNativeCell(1);
85 deflect[client] = GetNativeCell(2);
86 GetClientAuthId(client, AuthId_Steam2, SteamID, sizeof(SteamID));
87 Format(query, sizeof(query), "UPDATE stats SET deflect='%i' WHERE steamid='%s'", deflect[client], SteamID);
88 SQL_TQuery(db, SQLErrorCheckCallback, query);
89}
90public Native_SetSumDeflect(Handle:plugin, params)
91{
92 decl String:SteamID[36], String:query[100];
93 new client = GetNativeCell(1);
94 sumdeflect[client]++;
95 GetClientAuthId(client, AuthId_Steam2, SteamID, sizeof(SteamID));
96 Format(query, sizeof(query), "UPDATE stats SET sumdeflect='%i' WHERE steamid='%s'", sumdeflect[client], SteamID);
97 SQL_TQuery(db, SQLErrorCheckCallback, query);
98}
99public Native_GetSpeed(Handle:plugin, params)
100{
101 new client = GetNativeCell(1);
102 if(IsClientInGame(client) && !IsFakeClient(client)){
103 return speed[client];
104 }
105 return 0;
106}
107public Native_GetDeflect(Handle:plugin, params) // params = id client
108{
109 new client = GetNativeCell(1);
110 if(IsClientInGame(client) && !IsFakeClient(client)){
111 return deflect[client];
112 }
113 return 0;
114}
115public Action:Top_target(client, args)
116{
117 decl String:strTarget[36];
118 if(args < 1)
119 {
120 return Plugin_Handled;
121 }
122 GetCmdArg(1, strTarget, sizeof(strTarget));
123 decl String:query[160];
124 Format(query, sizeof(query), "SELECT name,rating,kills,deaths,speed,deflect,sumdeflect,playtime FROM stats WHERE name='%s'", strTarget);
125 SQL_TQuery(db, SQLQueryRankCheck, query, GetClientUserId(client));
126 return Plugin_Handled;
127}
128public Action:Top_Speed(client, args)
129{
130 decl String:strTarget[36];
131 if(args < 1)
132 {
133 return Plugin_Handled;
134 }
135 GetCmdArg(1, strTarget, sizeof(strTarget));
136 decl String:query[160];
137 Format(query, sizeof(query), "SELECT name,speed,deflect,sumdeflect FROM stats WHERE name='%s'", strTarget);
138 SQL_TQuery(db, SQLQueryTSCheck, query, GetClientUserId(client));
139 return Plugin_Handled;
140}
141public Action:Name_Check(Handle:hTimer)
142{
143 for (new iClient = 1; iClient <= MaxClients; iClient++)
144 {
145 if (IsClientInGame(iClient) && !IsFakeClient(iClient))
146 {
147 decl String:steamId[36], String:name[72], String:query[140];
148 GetClientAuthId(iClient, AuthId_Steam2, steamId, sizeof(steamId));
149 GetClientName(iClient, name, sizeof(name));
150 ReplaceString(name, sizeof(name), "'", "");
151 ReplaceString(name, sizeof(name), "<?", "");
152 ReplaceString(name, sizeof(name), "?>", "");
153 ReplaceString(name, sizeof(name), "`", "");
154 ReplaceString(name, sizeof(name), ",", "");
155 ReplaceString(name, sizeof(name), "<?PHP", "");
156 ReplaceString(name, sizeof(name), "<?php", "");
157 ReplaceString(name, sizeof(name), "<", "[");
158 ReplaceString(name, sizeof(name), ">", "]");
159 Format(query, sizeof(query), "UPDATE stats SET name = '%s' WHERE steamid = '%s'", name, steamId);
160 SQL_TQuery(db,SQLErrorCheckCallback, query);
161 }
162 }
163}
164public Action:Time_Update(Handle:hTimer)
165{
166 for (new iClient = 1; iClient <= MaxClients; iClient++)
167 {
168 if (IsClientInGame(iClient) && !IsFakeClient(iClient))
169 {
170 decl String:steamId[36], String:query[140];
171 GetClientAuthId(iClient, AuthId_Steam2, steamId, sizeof(steamId));
172 playtime[iClient]++;
173 sessionplaytime[iClient]++;
174 Format(query, sizeof(query), "UPDATE stats SET playtime = '%i' WHERE steamid = '%s'", playtime[iClient], steamId);
175 SQL_TQuery(db,SQLErrorCheckCallback, query);
176 }
177 }
178}
179public OnClientPostAdminCheck(client)
180{
181 if(!IsFakeClient(client) && client > 0)
182 {
183 CreateTimer(2.0, Timer_PrintConnect, GetClientUserId(client));
184 }
185 if(!IsFakeClient(client) && IsClientInGame(client) && client > 0) {
186 decl String:clientid[36], String:query[160];
187 new userid = GetClientUserId(client);
188 GetClientAuthId(client, AuthId_Steam2, clientid, sizeof(clientid));
189 if (strlen(clientid) > 8)
190 {
191 Format(query, sizeof(query), "SELECT rating,kills,deaths,speed,deflect,sumdeflect,playtime FROM stats WHERE steamid='%s'", clientid);
192 SQL_TQuery(db, SQLQueryConnect, query, userid);
193 } else
194 {
195 KickClient(client, "The target was not found.");
196 }
197 SQL_TQuery(db, Query_GetRecordCount, "SELECT COUNT(*) FROM stats");
198 sessionrating[client] = 0;
199 sessionkills[client] = 0;
200 sessiondeaths[client] = 0;
201 sessionplaytime[client] = 0;
202}
203}
204public Action:Timer_PrintConnect(Handle:timer, any:userid)
205{
206 new client = GetClientOfUserId(userid);
207 if (client > 0)
208 {
209 decl String:query[100];
210 Format(query, sizeof(query), "SELECT * FROM stats WHERE rating>'%i'", rating[client]);
211 SQL_TQuery(db, SQLQueryPrint, query, GetClientUserId(client));
212 }
213}
214public SQLQueryPrint(Handle:owner, Handle:hndl, const String:error[], any:data)
215{
216 new client;
217 if((client = GetClientOfUserId(data))==0) {
218 return;
219 }
220 if(hndl==INVALID_HANDLE){
221 LogError("Query failed: %s", error);
222 }
223 else{
224 rank[client] = SQL_GetRowCount(hndl) + 1;
225 }
226 PrintToChatAll("\x073EFF3E%N\x01 has joined the game and is ranked \x073EFF3E#%i\x01 out of \x073EFF3E%i\x01 players with \x073EFF3E%i\x01 Points!", client, rank[client], totalCount, rating[client]);
227}
228public Query_GetRecordCount(Handle:owner, Handle:hndl, const String:error[], any:data)
229{
230 if(hndl==INVALID_HANDLE)
231 {
232 LogError("Query failed: %s", error);
233 return;
234 }
235 if (SQL_FetchRow(hndl) == true)
236 totalCount = SQL_FetchInt(hndl, 0) + 1;
237}
238public SQLQueryConnect(Handle:owner, Handle:hndl, const String:error[], any:data) {
239 new client;
240 if((client = GetClientOfUserId(data))==0) {
241 return;
242 }
243 if(hndl==INVALID_HANDLE) {
244 LogError("Query failed: %s", error);
245 } else {
246 decl String:query[160], String:clientname[40], String:clientid[40];
247 GetClientName(client, clientname, sizeof(clientname));
248 ReplaceString(clientname, sizeof(clientname), "'", "");
249 GetClientAuthId(client, AuthId_Steam2, clientid, sizeof(clientid));
250 if(!SQL_MoreRows(hndl)) {
251 Format(query, sizeof(query), "INSERT INTO stats VALUES('%s', '%s', 1000, 0, 0, 0, 0, 0, 0)", clientid, clientname); // Ñтимид, ник, очки, килы, Ñмерти, ÑкороÑть, отражениÑ
252 SQL_TQuery(db, SQLErrorCheckCallback, query);
253 rating[client] = 1000;
254 kills[client] = 0;
255 deaths[client] = 0;
256 speed[client] = 0;
257 deflect[client] = 0;
258 sumdeflect[client] = 0;
259 playtime[client] = 0;
260 } else {
261 Format(query, sizeof(query), "UPDATE stats SET name='%s' WHERE steamid='%s'", client, clientname, clientid);
262 SQL_TQuery(db, SQLErrorCheckCallback, query);
263 }
264 while(SQL_FetchRow(hndl)) {
265 rating[client] = SQL_FetchInt(hndl, 0);
266 kills[client] = SQL_FetchInt(hndl, 1);
267 deaths[client] = SQL_FetchInt(hndl, 2);
268 speed[client] = SQL_FetchInt(hndl, 3);
269 deflect[client] = SQL_FetchInt(hndl, 4);
270 sumdeflect[client] = SQL_FetchInt(hndl, 5);
271 playtime[client] = SQL_FetchInt(hndl, 6);
272 }
273 }
274}
275public SQLQueryTS(Handle:owner, Handle:hndl, const String:error[], any:data) {
276 new client;
277 if((client = GetClientOfUserId(data))==0) {
278 return;
279 }
280 if(hndl==INVALID_HANDLE) {
281 LogError("Query failed: %s", error);
282 }
283 else {
284 new i = 1;
285 decl String:PlayerName[40], String:PlayerID[40], String:menuline[40];
286 new Handle:menu = CreateMenu(TSMenuHandler1);
287 while (SQL_FetchRow(hndl))
288 {
289 SQL_FetchString(hndl,0, PlayerName , 40);
290 SQL_FetchString(hndl,1, PlayerID , 40);
291 Format(menuline, sizeof(menuline), "%i. %s", i, PlayerName);
292 AddMenuItem(menu, PlayerID, menuline);
293 i++;
294 }
295 SetMenuExitButton(menu, true);
296 DisplayMenu(menu, client, 60);
297 }
298}
299public TSMenuHandler1(Handle:menu, MenuAction:action, param1, param2)
300{
301 if (action == MenuAction_Select)
302 {
303 decl String:info[40], String:buffer[160];
304 GetMenuItem(menu, param2, info, sizeof(info));
305 Format(buffer, sizeof(buffer), "SELECT name,speed,deflect,sumdeflect FROM stats WHERE steamid='%s'", info);
306 SQL_TQuery(db, SQLQueryTSCheck, buffer, GetClientUserId(param1));
307 }
308 else if (action == MenuAction_End)
309 {
310 CloseHandle(menu);
311 }
312}
313public SQLQueryTSCheck(Handle:owner, Handle:hndl, const String:error[], any:data) {
314 new client;
315 if((client = GetClientOfUserId(data))==0) {
316 return;
317 }
318 if(hndl==INVALID_HANDLE) {
319 LogError("Query failed: %s", error);
320 } else {
321 if(!SQL_MoreRows(hndl)){
322 PrintToChat(client, "The target was not found.");
323 return;
324 }
325 while(SQL_FetchRow(hndl)) {
326 SQL_FetchString(hndl, 0, NamePlayer, 40);
327 SpeedPlayer = SQL_FetchInt(hndl, 1);
328 DeflectPlayer = SQL_FetchInt(hndl, 2);
329 SumDeflectPlayer = SQL_FetchInt(hndl, 3);
330 }
331 }
332 decl String:query[80];
333 Format(query, sizeof(query), "SELECT * FROM stats WHERE speed>'%i'", SpeedPlayer);
334 SQL_TQuery(db, SQLQueryTSWiew, query, GetClientUserId(client));
335}
336public SQLQueryTSWiew(Handle:owner, Handle:hndl, const String:error[], any:data) {
337 new client;
338 if((client = GetClientOfUserId(data))==0) {
339 return;
340 }
341 if(hndl==INVALID_HANDLE) {
342 LogError("Query failed: %s", error);
343 }
344 RankSpeed = SQL_GetRowCount(hndl) + 1;
345 decl String:buffer[80];
346 new Handle:panel = CreatePanel();
347 SetPanelTitle(panel, "Speed stats:");
348 Format(buffer, sizeof(buffer), "â–º Speed: %i", SpeedPlayer);
349 DrawPanelText(panel, buffer);
350 Format(buffer, sizeof(buffer), "â–º Deflect: %i", DeflectPlayer);
351 DrawPanelText(panel, buffer);
352 Format(buffer, sizeof(buffer), "â–º Sum Deflect: %i", SumDeflectPlayer);
353 DrawPanelText(panel, buffer);
354 DrawPanelItem(panel, "Close");
355 SendPanelToClient(panel, client, PanelHandlerNothing, 15);
356 PrintToChatAll("\x073EFF3E%s\x01 is Top speed \x073EFF3E#%i\x01 out of \x073EFF3E%i\x01 Players with \x073EFF3E%i\x01 Speed!", NamePlayer, RankSpeed, totalCount, SpeedPlayer);
357 CloseHandle(panel);
358}
359public SQLQueryTop10(Handle:owner, Handle:hndl, const String:error[], any:data) {
360 new client;
361 if((client = GetClientOfUserId(data))==0) {
362 return;
363 }
364 if(hndl==INVALID_HANDLE) {
365 LogError("Query failed: %s", error);
366 }
367 else {
368 new i = 1;
369 decl String:PlayerName[40], String:PlayerID[40], String:menuline[40];
370 new Handle:menu = CreateMenu(TopMenuHandler1);
371 while (SQL_FetchRow(hndl))
372 {
373 SQL_FetchString(hndl,0, PlayerName , 40);
374 SQL_FetchString(hndl,1, PlayerID , 40);
375 Format(menuline, sizeof(menuline), "%i. %s", i, PlayerName);
376 AddMenuItem(menu, PlayerID, menuline);
377 i++;
378 }
379 SetMenuExitButton(menu, true);
380 DisplayMenu(menu, client, 60);
381 }
382}
383public TopMenuHandler1(Handle:menu, MenuAction:action, param1, param2)
384{
385 if (action == MenuAction_Select)
386 {
387 decl String:info[40], String:buffer[160];
388 GetMenuItem(menu, param2, info, sizeof(info));
389 Format(buffer, sizeof(buffer), "SELECT name,rating,kills,deaths,speed,deflect,sumdeflect,playtime FROM stats WHERE steamid='%s'", info);
390 SQL_TQuery(db, SQLQueryRankCheck, buffer, GetClientUserId(param1));
391 }
392 else if (action == MenuAction_End)
393 {
394 CloseHandle(menu);
395 }
396}
397public SQLQueryRankCheck(Handle:owner, Handle:hndl, const String:error[], any:data) {
398 new client;
399 if((client = GetClientOfUserId(data))==0) {
400 return;
401 }
402 if(hndl==INVALID_HANDLE) {
403 LogError("Query failed: %s", error);
404 } else {
405 if(!SQL_MoreRows(hndl)){
406 PrintToChat(client, "The target was not found.");
407 return;
408 }
409 while(SQL_FetchRow(hndl)) {
410 SQL_FetchString(hndl, 0, NamePlayer, 40);
411 pointcountPlayer = SQL_FetchInt(hndl, 1);
412 killPlayer = SQL_FetchInt(hndl, 2);
413 deathPlayer = SQL_FetchInt(hndl, 3);
414 SpeedPlayer = SQL_FetchInt(hndl, 4);
415 DeflectPlayer = SQL_FetchInt(hndl, 5);
416 SumDeflectPlayer = SQL_FetchInt(hndl, 6);
417 playtimePlayer = SQL_FetchInt(hndl, 7);
418 }
419 }
420 decl String:query[80];
421 Format(query, sizeof(query), "SELECT * FROM stats WHERE rating>'%i'", pointcountPlayer);
422 SQL_TQuery(db, SQLQueryRankWiew, query, GetClientUserId(client));
423}
424public SQLQueryRankWiew(Handle:owner, Handle:hndl, const String:error[], any:data) {
425 new client;
426 if((client = GetClientOfUserId(data))==0) {
427 return;
428 }
429 if(hndl==INVALID_HANDLE) {
430 LogError("Query failed: %s", error);
431 }
432 ratingPlayer = SQL_GetRowCount(hndl) + 1;
433 new Float:kpd = deathPlayer==0?0.0:float(killPlayer)/float(deathPlayer);
434 decl String:buffer[80];
435 new Handle:panel = CreatePanel();
436 SetPanelTitle(panel, "Ranking stats:");
437 Format(buffer, sizeof(buffer), "â–º Point: %i", pointcountPlayer);
438 DrawPanelText(panel, buffer);
439 Format(buffer, sizeof(buffer), "â–º Speed: %i", SpeedPlayer);
440 DrawPanelText(panel, buffer);
441 Format(buffer, sizeof(buffer), "â–º Deflect: %i", DeflectPlayer);
442 DrawPanelText(panel, buffer);
443 Format(buffer, sizeof(buffer), "â–º Sum Deflect: %i", SumDeflectPlayer);
444 DrawPanelText(panel, buffer);
445 Format(buffer, sizeof(buffer), "â–º Rank: %i (of %i)", ratingPlayer, totalCount);
446 DrawPanelText(panel, buffer);
447 Format(buffer, sizeof(buffer), "â–º Kills: %i", killPlayer);
448 DrawPanelText(panel, buffer);
449 Format(buffer, sizeof(buffer), "â–º Deaths: %i", deathPlayer);
450 DrawPanelText(panel, buffer);
451 Format(buffer, sizeof(buffer), "â–º PLAYTIME: %i min", playtimePlayer);
452 DrawPanelText(panel, buffer);
453 Format(buffer, sizeof(buffer), "â–º KPD: %.2f", kpd);
454 DrawPanelText(panel, buffer);
455 DrawPanelItem(panel, "Close");
456 SendPanelToClient(panel, client, PanelHandlerNothing, 15);
457 PrintToChatAll("\x073EFF3E%s\x01 is Ranked \x073EFF3E#%i\x01 out of \x073EFF3E%i\x01 Players with \x073EFF3E%i\x01 Points!", NamePlayer, ratingPlayer, totalCount, pointcountPlayer);
458 CloseHandle(panel);
459}
460public SQLErrorCheckCallback(Handle:owner, Handle:hndl, const String:error[], any:data) {
461 if(!StrEqual("", error)) {
462 LogError("Query failed: %s", error);
463 }
464}
465public Action:Event_player_death(Handle:event, const String:name[], bool:dontBroadcast) {
466 new client = GetClientOfUserId(GetEventInt(event, "userid"));
467 new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
468 if(client!=0 && attacker!=0) {
469 if(!IsFakeClient(client)&&!IsFakeClient(attacker)&&client!=attacker) {
470 decl String:clientid[60], String:attackerid[60], String:query[256];
471 GetClientAuthId(client, AuthId_Steam2, clientid, sizeof(clientid));
472 GetClientAuthId(attacker, AuthId_Steam2, attackerid, sizeof(attackerid));
473 new add_point_attacker = (rating[client]+1)/(rating[attacker]+1) + GetRandomInt(1, 3);
474 if(add_point_attacker > 10)
475 add_point_attacker = GetRandomInt(10, 12);
476 new dec_point_client = (rating[client]+1)/(rating[attacker]+1) + GetRandomInt(1, 2);
477 if(dec_point_client > 8)
478 dec_point_client = GetRandomInt(8, 10);
479 rating[client] = rating[client] - 3 - dec_point_client;
480 rating[attacker] = rating[attacker] + 5 + add_point_attacker;
481 sessionrating[client] = sessionrating[client] - 3 - dec_point_client;
482 sessionrating[attacker] = sessionrating[attacker] + 5 + add_point_attacker;
483 kills[attacker]++;
484 deaths[client]++;
485 sessionkills[attacker]++;
486 sessiondeaths[client]++;
487 Format(query, sizeof(query), "UPDATE stats SET rating='%i',deaths='%i' WHERE steamid='%s'", rating[client], deaths[client], clientid);
488 SQL_TQuery(db, SQLErrorCheckCallback, query);
489 Format(query, sizeof(query), "UPDATE stats SET rating='%i',kills='%i' WHERE steamid='%s'", rating[attacker], kills[attacker], attackerid);
490 SQL_TQuery(db, SQLErrorCheckCallback, query);
491 }
492 }
493}
494public Action:Command_say(client, args) {
495 if (!client) return Plugin_Continue;
496 if (client <= 0) return Plugin_Continue;
497 decl String:text[192];
498 if(GetCmdArgString(text, sizeof(text))<1) {
499 return Plugin_Continue;
500 }
501 new startidx;
502 if(text[strlen(text)-1]=='"') {
503 text[strlen(text)-1] = '\0';
504 startidx = 1;
505 }
506 decl String:clientid[60];
507 GetClientAuthId(client, AuthId_Steam2, clientid, sizeof(clientid));
508 if(strcmp(text[startidx], "rank", false)==0 || strcmp(text[startidx], "!rank", false)==0 || strcmp(text[startidx], "session", false)==0 || strcmp(text[startidx], "/session", false)==0) {
509 if(StrContains(text[startidx], "rank", false)!=-1) {
510 decl String:query[160];
511 Format(query, sizeof(query), "SELECT name,rating,kills,deaths,speed,deflect,sumdeflect,playtime FROM stats WHERE steamid='%s'", clientid);
512 SQL_TQuery(db, SQLQueryRankCheck, query, GetClientUserId(client));
513 return Plugin_Handled;
514 } else {
515 decl String:buffer[80];
516 new Handle:panel = CreatePanel();
517 SetPanelTitle(panel, "Session stats:");
518 Format(buffer, sizeof(buffer), "â–º Rating: %i", sessionrating[client]);
519 DrawPanelText(panel, buffer);
520 Format(buffer, sizeof(buffer), "â–º Kills: %i", sessionkills[client]);
521 DrawPanelText(panel, buffer);
522 Format(buffer, sizeof(buffer), "â–º Deaths: %i", sessiondeaths[client]);
523 DrawPanelText(panel, buffer);
524 Format(buffer, sizeof(buffer), "â–º PLAYTIME: %i min", sessionplaytime[client]);
525 DrawPanelText(panel, buffer);
526 DrawPanelItem(panel, "Close");
527 SendPanelToClient(panel, client, PanelHandlerNothing, 15);
528 CloseHandle(panel);
529 }
530 return Plugin_Handled;
531 } else if(strcmp(text[startidx], "top10", false)==0 || strcmp(text[startidx], "!top10", false)==0 || strcmp(text[startidx], "top", false)==0 || strcmp(text[startidx], "!top", false)==0) {
532 SQL_TQuery(db, SQLQueryTop10, "SELECT name,steamid FROM stats ORDER BY rating DESC LIMIT 0,100", GetClientUserId(client));
533 return Plugin_Handled;
534 } else if (strcmp(text[startidx], "ts", false)==0 || strcmp(text[startidx], "!ts", false)==0 || strcmp(text[startidx], "/ts", false)==0)
535 {
536 SQL_TQuery(db, SQLQueryTS, "SELECT name,steamid FROM stats ORDER BY speed DESC LIMIT 0,100", GetClientUserId(client));
537 return Plugin_Handled;
538 } else if (strcmp(text[startidx], "tc", false)==0 || strcmp(text[startidx], "!tc", false)==0 || strcmp(text[startidx], "/tc", false)==0)
539 {
540 decl String:query[160];
541 Format(query, sizeof(query), "SELECT name,speed,deflect,sumdeflect FROM stats WHERE steamid='%s'", clientid);
542 SQL_TQuery(db, SQLQueryTSCheck, query, GetClientUserId(client));
543 return Plugin_Handled;
544 }
545 return Plugin_Continue;
546}
547public PanelHandlerNothing(Handle:menu, MenuAction:action, param1, param2) {
548 // Do nothing
549}