Advertisement
Guest User

Untitled

a guest
Nov 13th, 2018
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public void SQL_StatsMe2Callback(Handle owner, Handle hndl, const char[] error, any hDatapack){
  2.     if(hndl == INVALID_HANDLE)
  3.     {
  4.         LogError("[RankMe] Query Fail: %s", error);
  5.         return;
  6.     }
  7.    
  8.     ResetPack(hDatapack);
  9.    
  10.     int client = ReadPackCell(hDatapack);
  11.    
  12.     if(client == 0 || !IsClientInGame(client))
  13.         return;
  14.        
  15.     int type = ReadPackCell(hDatapack);
  16.     int i;
  17.    
  18.     char auth[64];
  19.     char name[MAX_NAME_LENGTH];
  20.    
  21.     int target;
  22.    
  23.     if(type == 0){
  24.        
  25.         target = ReadPackCell(hDatapack);
  26.        
  27.         GetClientAuthId(target,AuthId_Steam2,auth,sizeof(auth));
  28.        
  29.         GetClientName(target,name,sizeof(name));
  30.        
  31.     } else if (type == 1) {
  32.        
  33.         i = ReadPackCell(hDatapack);
  34.    
  35.     } else if(type == 2) {
  36.    
  37.         ReadPackString(hDatapack,auth,sizeof(auth));
  38.        
  39.     }
  40.     CloseHandle(hDatapack);
  41.     char Auth_receive[64];
  42.     char Name_receive[MAX_NAME_LENGTH];
  43.    
  44.     if(type != 1){
  45.        
  46.         while(SQL_HasResultSet(hndl) && SQL_FetchRow(hndl))
  47.         {
  48.             i++;
  49.             SQL_FetchString(hndl,1,Auth_receive,64);
  50.            
  51.             SQL_FetchString(hndl,2,Name_receive,MAX_NAME_LENGTH);
  52.            
  53.             if((g_RankBy == 1 && StrEqual(name,Name_receive)) || (g_RankBy == 0 && StrEqual(Auth_receive,auth,false)))
  54.                 break;
  55.         }
  56.  
  57.     } else if (SQL_HasResultSet(hndl)){
  58.         SQL_FetchRow(hndl);
  59.         SQL_FetchString(hndl,1,Auth_receive,64);
  60.        
  61.         SQL_FetchString(hndl,2,Name_receive,MAX_NAME_LENGTH);
  62.     } else {
  63.         return;
  64.     }
  65.    
  66.     Menu panel = CreateMenuEx(_,MenuHandler_DoNothing,MENU_ACTIONS_ALL);
  67.    
  68.     panel.SetTitle(Name_receive);
  69.    
  70.     char text[255];
  71.     panel.Pagination = 3;
  72.     int ikills = SQL_FetchInt(hndl,5);
  73.     int ideaths= SQL_FetchInt(hndl,6);
  74.     int deaths;
  75.     if(ideaths == 0)
  76.         deaths = 1;
  77.     else
  78.         deaths=ideaths;
  79.     float kills = IntToFloat(ikills);
  80.     int shots = SQL_FetchInt(hndl,10);
  81.     if(shots == 0)
  82.         shots = 1;
  83.    
  84.     int rounds = SQL_FetchInt(hndl,14) + SQL_FetchInt(hndl,15);
  85.     if((SQL_FetchInt(hndl,14) == 0) && (SQL_FetchInt(hndl,15) == 0))
  86.     {
  87.         rounds = 1;
  88.     }
  89.  
  90.     int idamage = SQL_FetchInt(hndl,74);
  91.     float damage = IntToFloat(idamage);
  92.    
  93.     int hits = SQL_FetchInt(hndl,11);
  94.     char temp[255];
  95.     Format(temp,sizeof(temp),"- %T\n","BasicStats",client);
  96.     StrCat(text,255,temp);
  97.     if(i == 0)
  98.         Format(temp,sizeof(temp),"%T: %i\n","Points",client,SQL_FetchInt(hndl,4));
  99.     else
  100.         Format(temp,sizeof(temp),"Rank: %i/%i   %T: %i\n",i,g_TotalPlayers,"Points",client,SQL_FetchInt(hndl,4));
  101.     StrCat(text,255,temp);
  102.     Format(temp,255,"%T   KDR: %.2f\n","KillsDeathsAssists",client,ikills,ideaths,SQL_FetchInt(hndl,7),kills/deaths);
  103.     StrCat(text,255,temp);
  104.     Format(temp,255,"%T: %d   %T: %d   %T: %d\n","Headshots", client, SQL_FetchInt(hndl,12),"Suicides",client,SQL_FetchInt(hndl,8),"TKs",client,SQL_FetchInt(hndl,9));
  105.     StrCat(text,255,temp);
  106.     Format(temp,255,"%T: %d   %T: %.2f   %T: %.2f\n ","Damage", client, idamage,"KPR", client, kills/rounds, "DPR", client, damage/rounds);
  107.     StrCat(text,255,temp);
  108.     panel.AddItem("",text);
  109.     text="";
  110.  
  111.     Format(temp,sizeof(temp),"- %T\n","RoundStats",client);
  112.     StrCat(text,255,temp);
  113.     Format(temp,255,"%T: %d/%d   %T: %d/%d   %T: %d\n%T: %d   %T: %d   %T: %d\n","TRWins",client,SQL_FetchInt(hndl,68),SQL_FetchInt(hndl,14),"CTWins",client,SQL_FetchInt(hndl,67),SQL_FetchInt(hndl,15),"MVPs",client,SQL_FetchInt(hndl,73), "MatchWins", client, SQL_FetchInt(hndl, 75), "MatchDraws", client, SQL_FetchInt(hndl, 76), "MatchLosses", client, SQL_FetchInt(hndl, 77));
  114.     StrCat(text,255,temp);
  115.     panel.AddItem("",text);
  116.     text="";
  117.    
  118.     Format(temp,sizeof(temp),"- %T\n","HitStats",client);
  119.     StrCat(text,255,temp);
  120.     Format(temp,255,"%T: %d   %T: %d   %T: %.2f%%\n ","Shots",client,shots,"Hits",client,hits,"Accuracy",client,IntToFloat(hits)/shots*100);
  121.     StrCat(text,255,temp);
  122.     panel.AddItem("",text);
  123.     text="";
  124.    
  125.     Format(temp,sizeof(temp),"- %T\n","BombHostagesStats",client);
  126.     StrCat(text,255,temp);
  127.     Format(temp,255,"%T: %d   %T: %d   %T: %d\n","PlantedBombs",client,SQL_FetchInt(hndl,64),"ExplodedBombs",client,SQL_FetchInt(hndl,65),"DefusedBombs",client,SQL_FetchInt(hndl,66));
  128.     StrCat(text,255,temp);
  129.     Format(temp,255,"%T: %d","RescuedHostages",client,SQL_FetchInt(hndl,69));
  130.     StrCat(text,255,temp);
  131.     panel.AddItem("",text);
  132.     text="";
  133.                
  134.     if(g_bVipEnabled){
  135.         Format(temp,sizeof(temp),"- %T\n","VIPStats",client);
  136.         StrCat(text,255,temp);
  137.         Format(temp,255,"%T: %d/%d   %T: %d\n ","VIPEscapes",client,SQL_FetchInt(hndl,71),SQL_FetchInt(hndl,72),"VIPsKilled",client,SQL_FetchInt(hndl,70));
  138.         StrCat(text,255,temp);
  139.         panel.AddItem("",text);
  140.         text="";
  141.     }
  142.    
  143.     Format(temp,sizeof(temp),"- %T\n","OtherStats",client);
  144.     StrCat(text,255,temp);
  145.    
  146.     int time = SQL_FetchInt(hndl,13);
  147.     if(target != 0 && IsClientInGame(target))
  148.         time += GetTime()-g_aSession[client][CONNECTED];
  149.        
  150.     int hours = RoundToFloor(time/3600.0);
  151.     time = time-(hours*3600);
  152.    
  153.     int minutes = RoundToFloor(time/60.0);
  154.     time = time-(minutes*60);
  155.    
  156.     Format(temp,255,"%T","TimeConnected",client,hours,minutes,time);
  157.     StrCat(text,255,temp);
  158.     panel.AddItem("",text);
  159.     text="";
  160.     panel.Display(client,MENU_TIME_FOREVER);
  161. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement