Advertisement
Rachello

Source

May 8th, 2021
171
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. RegConsoleCmd( "sm_rr", Command_ResentRecords );   
  2. RegConsoleCmd( "sm_resentrecords", Command_ResentRecords );
  3.  
  4. RegConsoleCmd( "sm_rrb", Command_ResentRecords_Bonus );
  5. RegConsoleCmd( "sm_rrc", Command_ResentRecords_Course );
  6.  
  7. public Action Command_ResentRecords( int client, int args )
  8. {
  9.     if ( !client ) return Plugin_Handled;
  10.    
  11.     Menu mMenu = new Menu(Recent_records_handler);
  12.  
  13.     mMenu.SetTitle("<Recent Records :: Selection>\n ");
  14.     mMenu.AddItem("", "Recent Map Records");
  15.     mMenu.AddItem("", "Recent Map Top 10s");
  16.     mMenu.AddItem("", "Recent Course Records");
  17.     mMenu.AddItem("", "Recent Course Top 10s");
  18.     mMenu.AddItem("", "Recent Bonus Records");
  19.     mMenu.AddItem("", "Recent Bonus Top 10s\n \n ");
  20.  
  21.     mMenu.Display(client, MENU_TIME_FOREVER);
  22.    
  23.     return Plugin_Handled;
  24. }
  25.  
  26. public int Recent_records_handler( Menu mMenu, MenuAction action, int client, int item )
  27. {
  28.     if ( action == MenuAction_End ) { delete mMenu; return 0; }
  29.     if ( action != MenuAction_Select ) return 0;
  30.  
  31.     char query[200];
  32.  
  33.     if (item == 0)
  34.     {
  35.         FormatEx(query, sizeof(query), "SELECT recordid, map, mode, date, (select name from plydata where uid = maprecs.uid) FROM maprecs where rank = 1 and run = 0 order by date desc limit 100");
  36.         g_hDatabase.Query(RecentRecords_Map_Wr_Callback, query, GetClientUserId( client ));
  37.     }
  38.     if (item == 1)
  39.     {
  40.         FormatEx(query, sizeof(query), "SELECT recordid, map, mode, date, rank, (select name from plydata where uid = maprecs.uid) FROM maprecs where rank > 1 and rank <= 10 and run = 0 order by date desc limit 100");
  41.         g_hDatabase.Query(RecentRecords_Map_Tt_Callback, query, GetClientUserId( client ));
  42.     }
  43.     if (item == 2)
  44.     {
  45.         FormatEx(query, sizeof(query), "SELECT recordid, map, mode, date, run, (select name from plydata where uid = maprecs.uid) FROM maprecs where rank = 1 and run >= %i and run <= %i order by date desc limit 100", RUN_COURSE1, RUN_COURSE10);
  46.         g_hDatabase.Query(RecentRecords_Course_Wr_Callback, query, GetClientUserId( client ));
  47.     }
  48.     if (item == 3)
  49.     {
  50.         FormatEx(query, sizeof(query), "SELECT recordid, map, mode, date, rank, run, (select name from plydata where uid = maprecs.uid) FROM maprecs where rank > 1 and rank <= 10 and run >= %i and run <= %i order by date desc limit 100", RUN_COURSE1, RUN_COURSE10);
  51.         g_hDatabase.Query(RecentRecords_Course_Tt_Callback, query, GetClientUserId( client ));
  52.     }
  53.     if (item == 4)
  54.     {
  55.         FormatEx(query, sizeof(query), "SELECT recordid, map, mode, date, run, (select name from plydata where uid = maprecs.uid) FROM maprecs where rank = 1 and run >= %i and run <= %i order by date desc limit 100", RUN_BONUS1, RUN_BONUS10);
  56.         g_hDatabase.Query(RecentRecords_Bonus_Wr_Callback, query, GetClientUserId( client ));
  57.     }
  58.     if (item == 5)
  59.     {
  60.         FormatEx(query, sizeof(query), "SELECT recordid, map, mode, date, rank, run, (select name from plydata where uid = maprecs.uid) FROM maprecs where rank > 1 and rank <= 10 and run >= %i and run <= %i order by date desc limit 100", RUN_BONUS1, RUN_BONUS10);
  61.         g_hDatabase.Query(RecentRecords_Bonus_Tt_Callback, query, GetClientUserId( client ));
  62.     }
  63.     return 0;
  64. }
  65.  
  66. public void RecentRecords_Map_Wr_Callback( Database hOwner, DBResultSet hQuery, const char[] szError, int client )
  67. {
  68.     if ( !(client = GetClientOfUserId( client )) ) return;
  69.    
  70.     if ( hQuery == null )
  71.     {
  72.         DB_LogError( "Couldn't retrieve player data!" );
  73.        
  74.         return;
  75.     }
  76.  
  77.     if ( hQuery.RowCount )
  78.     {
  79.         Menu mMenu = new Menu(RecentRecords_Runs_Handler);
  80.         mMenu.SetTitle("<Recent Jump Map Records>\n ");
  81.  
  82.         char recordid[6];
  83.         int mode;
  84.         char map[60], date[40], name[25], buffer[100];
  85.         while (hQuery.FetchRow())
  86.         {
  87.             IntToString( hQuery.FetchInt(0), recordid, sizeof(recordid));
  88.             hQuery.FetchString( 1, map, sizeof( map ) );
  89.             mode = hQuery.FetchInt(2);
  90.             hQuery.FetchString( 3, date, sizeof( date ) );
  91.             hQuery.FetchString( 4, name, sizeof( name ) );
  92.  
  93.             ReplaceString(map, sizeof(map), "jump_", "");
  94.             ReplaceString(map, sizeof(map), "sj_", "");
  95.             ReplaceString(map, sizeof(map), "rj_", "");
  96.  
  97.             FormatTimeDuration(date, sizeof(date), GetTime() + (55755 + 1850) - DateTimeToTimestamp(date));
  98.  
  99.             FormatEx(buffer, sizeof(buffer), "(%s) <%s> - %s - %s", g_szModeName[NAME_SHORT][mode][0], map, name, date);
  100.             mMenu.AddItem(recordid, buffer);
  101.         }
  102.         mMenu.ExitBackButton = true;
  103.         mMenu.Display(client, MENU_TIME_FOREVER);
  104.     }
  105.     delete hQuery;
  106. }
  107.  
  108. public void RecentRecords_Map_Tt_Callback( Database hOwner, DBResultSet hQuery, const char[] szError, int client )
  109. {
  110.     if ( !(client = GetClientOfUserId( client )) ) return;
  111.    
  112.     if ( hQuery == null )
  113.     {
  114.         DB_LogError( "Couldn't retrieve player data!" );
  115.        
  116.         return;
  117.     }
  118.  
  119.     if ( hQuery.RowCount )
  120.     {
  121.         Menu mMenu = new Menu(RecentRecords_Runs_Handler);
  122.         mMenu.SetTitle("<Recent Jump Map Top 10s>\n ");
  123.  
  124.         char recordid[6];
  125.         int mode, rank;
  126.         char map[60], date[40], name[25], buffer[100];
  127.         while (hQuery.FetchRow())
  128.         {
  129.             IntToString( hQuery.FetchInt(0), recordid, sizeof(recordid));
  130.             hQuery.FetchString( 1, map, sizeof( map ) );
  131.             mode = hQuery.FetchInt(2);
  132.             hQuery.FetchString( 3, date, sizeof( date ) );
  133.             rank = hQuery.FetchInt(4);
  134.             hQuery.FetchString( 5, name, sizeof( name ) );
  135.  
  136.             ReplaceString(map, sizeof(map), "jump_", "");
  137.             ReplaceString(map, sizeof(map), "sj_", "");
  138.             ReplaceString(map, sizeof(map), "rj_", "");
  139.  
  140.             FormatTimeDuration(date, sizeof(date), GetTime() + (55755 + 1850) - DateTimeToTimestamp(date));
  141.  
  142.             FormatEx(buffer, sizeof(buffer), "(%s) <%s> (#%i) - %s - %s", g_szModeName[NAME_SHORT][mode][0], map, rank, name, date);
  143.             mMenu.AddItem(recordid, buffer);
  144.         }
  145.         mMenu.ExitBackButton = true;
  146.         mMenu.Display(client, MENU_TIME_FOREVER);
  147.     }
  148.     delete hQuery;
  149. }
  150.  
  151. public void RecentRecords_Course_Wr_Callback( Database hOwner, DBResultSet hQuery, const char[] szError, int client )
  152. {
  153.     if ( !(client = GetClientOfUserId( client )) ) return;
  154.    
  155.     if ( hQuery == null )
  156.     {
  157.         DB_LogError( "Couldn't retrieve player data!" );
  158.        
  159.         return;
  160.     }
  161.  
  162.     if ( hQuery.RowCount )
  163.     {
  164.         Menu mMenu = new Menu(RecentRecords_Runs_Handler);
  165.         mMenu.SetTitle("<Recent Jump Course Records>\n ");
  166.  
  167.         char recordid[6];
  168.         int mode, run;
  169.         char map[60], date[40], name[25], buffer[100];
  170.         while (hQuery.FetchRow())
  171.         {
  172.             IntToString( hQuery.FetchInt(0), recordid, sizeof(recordid));
  173.             hQuery.FetchString( 1, map, sizeof( map ) );
  174.             mode = hQuery.FetchInt(2);
  175.             hQuery.FetchString( 3, date, sizeof( date ) );
  176.             run = hQuery.FetchInt(4);
  177.             hQuery.FetchString( 5, name, sizeof( name ) );
  178.  
  179.             ReplaceString(map, sizeof(map), "jump_", "");
  180.             ReplaceString(map, sizeof(map), "sj_", "");
  181.             ReplaceString(map, sizeof(map), "rj_", "");
  182.  
  183.             FormatTimeDuration(date, sizeof(date), GetTime() + (55755 + 1850) - DateTimeToTimestamp(date));
  184.  
  185.             FormatEx(buffer, sizeof(buffer), "(%s) <%s [%s]> - %s - %s", g_szModeName[NAME_SHORT][mode][0], map, g_szRunName[NAME_SHORT][run], name, date);
  186.             mMenu.AddItem(recordid, buffer);
  187.         }
  188.         mMenu.ExitBackButton = true;
  189.         mMenu.Display(client, MENU_TIME_FOREVER);
  190.     }
  191.     delete hQuery;
  192. }
  193.  
  194. public void RecentRecords_Course_Tt_Callback( Database hOwner, DBResultSet hQuery, const char[] szError, int client )
  195. {
  196.     if ( !(client = GetClientOfUserId( client )) ) return;
  197.    
  198.     if ( hQuery == null )
  199.     {
  200.         DB_LogError( "Couldn't retrieve player data!" );
  201.        
  202.         return;
  203.     }
  204.  
  205.     if ( hQuery.RowCount )
  206.     {
  207.         Menu mMenu = new Menu(RecentRecords_Runs_Handler);
  208.         mMenu.SetTitle("<Recent Jump Course Top 10s>\n ");
  209.  
  210.         char recordid[6];
  211.         int mode, rank, run;
  212.         char map[60], date[40], name[25], buffer[100];
  213.         while (hQuery.FetchRow())
  214.         {
  215.             IntToString( hQuery.FetchInt(0), recordid, sizeof(recordid));
  216.             hQuery.FetchString( 1, map, sizeof( map ) );
  217.             mode = hQuery.FetchInt(2);
  218.             hQuery.FetchString( 3, date, sizeof( date ) );
  219.             rank = hQuery.FetchInt(4);
  220.             run = hQuery.FetchInt(5);
  221.             hQuery.FetchString( 6, name, sizeof( name ) );
  222.  
  223.             ReplaceString(map, sizeof(map), "jump_", "");
  224.             ReplaceString(map, sizeof(map), "sj_", "");
  225.             ReplaceString(map, sizeof(map), "rj_", "");
  226.  
  227.             FormatTimeDuration(date, sizeof(date), GetTime() + (55755 + 1850) - DateTimeToTimestamp(date));
  228.  
  229.             FormatEx(buffer, sizeof(buffer), "(%s) <%s [%s]> (#%i) - %s - %s", g_szModeName[NAME_SHORT][mode][0], map, g_szRunName[NAME_SHORT][run], rank, name, date);
  230.             mMenu.AddItem(recordid, buffer);
  231.         }
  232.         mMenu.ExitBackButton = true;
  233.         mMenu.Display(client, MENU_TIME_FOREVER);
  234.     }
  235.     delete hQuery;
  236. }
  237.  
  238. public void RecentRecords_Bonus_Wr_Callback( Database hOwner, DBResultSet hQuery, const char[] szError, int client )
  239. {
  240.     if ( !(client = GetClientOfUserId( client )) ) return;
  241.    
  242.     if ( hQuery == null )
  243.     {
  244.         DB_LogError( "Couldn't retrieve player data!" );
  245.        
  246.         return;
  247.     }
  248.  
  249.     if ( hQuery.RowCount )
  250.     {
  251.         Menu mMenu = new Menu(RecentRecords_Runs_Handler);
  252.         mMenu.SetTitle("<Recent Jump Bonus Records>\n ");
  253.  
  254.         char recordid[6];
  255.         int mode, rank, run;
  256.         char map[60], date[40], name[25], buffer[100];
  257.         while (hQuery.FetchRow())
  258.         {
  259.             IntToString( hQuery.FetchInt(0), recordid, sizeof(recordid));
  260.             hQuery.FetchString( 1, map, sizeof( map ) );
  261.             mode = hQuery.FetchInt(2);
  262.             hQuery.FetchString( 3, date, sizeof( date ) );
  263.             run = hQuery.FetchInt(4);
  264.             hQuery.FetchString( 5, name, sizeof( name ) );
  265.  
  266.             ReplaceString(map, sizeof(map), "jump_", "");
  267.             ReplaceString(map, sizeof(map), "sj_", "");
  268.             ReplaceString(map, sizeof(map), "rj_", "");
  269.  
  270.             FormatTimeDuration(date, sizeof(date), GetTime() + (55755 + 1850) - DateTimeToTimestamp(date));
  271.  
  272.             FormatEx(buffer, sizeof(buffer), "(%s) <%s [%s]> - %s - %s", g_szModeName[NAME_SHORT][mode][0], map, g_szRunName[NAME_SHORT][run], name, date);
  273.             mMenu.AddItem(recordid, buffer);
  274.         }
  275.         mMenu.ExitBackButton = true;
  276.         mMenu.Display(client, MENU_TIME_FOREVER);
  277.     }
  278.     delete hQuery;
  279. }
  280.  
  281. public void RecentRecords_Bonus_Tt_Callback( Database hOwner, DBResultSet hQuery, const char[] szError, int client )
  282. {
  283.     if ( !(client = GetClientOfUserId( client )) ) return;
  284.    
  285.     if ( hQuery == null )
  286.     {
  287.         DB_LogError( "Couldn't retrieve player data!" );
  288.        
  289.         return;
  290.     }
  291.  
  292.     if ( hQuery.RowCount )
  293.     {
  294.         Menu mMenu = new Menu(RecentRecords_Runs_Handler);
  295.         mMenu.SetTitle("<Recent Jump Bonus Top 10s>\n ");
  296.  
  297.         char recordid[6];
  298.         int mode, rank, run;
  299.         char map[60], date[40], name[25], buffer[100];
  300.         while (hQuery.FetchRow())
  301.         {
  302.             IntToString( hQuery.FetchInt(0), recordid, sizeof(recordid));
  303.             hQuery.FetchString( 1, map, sizeof( map ) );
  304.             mode = hQuery.FetchInt(2);
  305.             hQuery.FetchString( 3, date, sizeof( date ) );
  306.             rank = hQuery.FetchInt(4);
  307.             run = hQuery.FetchInt(5);
  308.             hQuery.FetchString( 6, name, sizeof( name ) );
  309.  
  310.             ReplaceString(map, sizeof(map), "jump_", "");
  311.             ReplaceString(map, sizeof(map), "sj_", "");
  312.             ReplaceString(map, sizeof(map), "rj_", "");
  313.  
  314.             FormatTimeDuration(date, sizeof(date), GetTime() + (55755 + 1850) - DateTimeToTimestamp(date));
  315.  
  316.             FormatEx(buffer, sizeof(buffer), "(%s) <%s [%s]> (#%i) - %s - %s", g_szModeName[NAME_SHORT][mode][0], map, g_szRunName[NAME_SHORT][run], rank, name, date);
  317.             mMenu.AddItem(recordid, buffer);
  318.         }
  319.         mMenu.ExitBackButton = true;
  320.         mMenu.Display(client, MENU_TIME_FOREVER);
  321.     }
  322.     delete hQuery;
  323. }
  324.  
  325. public int RecentRecords_Runs_Handler( Menu mMenu, MenuAction action, int client, int item )
  326. {
  327.     if ( action == MenuAction_End ) { delete mMenu; return 0; }
  328.  
  329.     if ( action == MenuAction_Cancel )
  330.     {
  331.         if (item == MenuCancel_ExitBack)
  332.         {
  333.             ClientCommand(client, "sm_rr");
  334.         }
  335.         return 0;
  336.     }
  337.  
  338.     if ( action != MenuAction_Select ) return 0;
  339.  
  340.     char szRecordid[6];
  341.     int recordid;
  342.  
  343.     GetMenuItem( mMenu, item, szRecordid, sizeof( szRecordid ) );
  344.  
  345.     StringToIntEx(szRecordid, recordid);
  346.  
  347.     DB_RecordInfo(client, 0, recordid);
  348.    
  349.     return 0;
  350. }
Advertisement
RAW Paste Data Copied
Advertisement