Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Mar 21st, 2010 | Syntax: PAWN | Size: 6.86 KB | Hits: 73 | Expires: Never
Copy text to clipboard
  1. #include <amxmodx>
  2. #include <httpdl>
  3.  
  4. #pragma semicolon 1
  5.  
  6. // Start: Made these to easily update the plugin
  7. #define MAX 10
  8. new g_CommandList[MAX][] = {
  9.         "/wr",
  10.         "/cg",
  11.         "/fr",
  12.         "/sk",
  13.         "/lt",
  14.         "/ee",
  15.         "/ru",
  16.         "/no",
  17.         "/se",
  18.         "/dk"
  19. };
  20. new g_Record[MAX][] = {
  21.         "World record",
  22.         "German record",
  23.         "French record",
  24.         "Slovakian record",
  25.         "Lithuanian record",
  26.         "Estonian record",
  27.         "Russin record",
  28.         "Norwegian record",
  29.         "Swedish record",
  30.         "Danish record"
  31. };
  32. new g_DownloadUrl[MAX][] = {
  33.         "http://xtreme-jumps.eu/demos.txt",
  34.         "http://climbers-germany.de/demos.txt",
  35.         "http://kzfr.verygames.net/demos.txt",
  36.         "http://kzsk.sk/demos/demos.txt",
  37.         "http://kzlt.bentski.lt/demos.txt",
  38.         "http://kreedz.pri.ee/demos.txt",
  39.         "http://climbers.cpms.ru/records.txt",
  40.         "http://kz-scandinavia.com/demos_no.txt",
  41.         "http://kz-scandinavia.com/demos_se.txt",
  42.         "http://kz-scandinavia.com/demos_dk.txt"
  43. };
  44. // End
  45.  
  46. new g_flDemoData[MAX][256];
  47.  
  48. // Hudmessage related variables
  49. new g_iColors[3] = { 255, 0, 255 };
  50. new Float:g_fCoords[2] = { 0.01, 0.2 };
  51. new g_CvarShowTime;
  52.  
  53. ////////////////////////////////////////////////////////////////////////////////////////////////////
  54. //      Init
  55. ////////////////////////////////////////////////////////////////////////////////////////////////////
  56.  
  57. public plugin_init( )
  58. {
  59.         register_plugin( "Kreedz Records", "1.4", "SchlumPF*" );
  60.        
  61.         g_CvarShowTime = register_cvar( "kz_records_showtime", "5.0" );
  62.        
  63.         register_clcmd( "say", "cmdHookSay" );
  64.        
  65.         register_concmd( "kz_records_pos", "cmdChangePos" );
  66.         register_concmd( "kz_records_color", "cmdChangeColor" );
  67.        
  68.         register_srvcmd( "kz_records_update", "cmdUpdate" );
  69.  
  70.         new data[128];
  71.         get_localinfo( "amxx_datadir", data, sizeof data - 1 );
  72.        
  73.         for( new i ; i < MAX ; i++ )
  74.                 format( g_flDemoData[i], 255, "%s/demos_%s.txt", data, g_CommandList[i][1] );
  75. }
  76.  
  77. ////////////////////////////////////////////////////////////////////////////////////////////////////
  78. //      Hook say
  79. ////////////////////////////////////////////////////////////////////////////////////////////////////
  80.  
  81. public cmdHookSay( plr )
  82. {
  83.         static message[512];
  84.         read_args( message, sizeof message - 1 );
  85.         remove_quotes( message );
  86.        
  87.         if( message[0] )
  88.         {
  89.                 for( new i ; i < MAX ; i++ )
  90.                 {
  91.                         if( equali( g_CommandList[i], message, 3 ) )
  92.                         {                              
  93.                                 static list[3], mapname[64];
  94.                                 format( list, sizeof list - 1, "%s", message );
  95.                                
  96.                                 if( message[4] )
  97.                                         copy( mapname, sizeof mapname - 1, message[4] ); // maybe i should add some function which does show maps with similar names?!
  98.                                 else
  99.                                         get_mapname( mapname, sizeof mapname - 1 );
  100.                                
  101.                                 if( file_exists( g_flDemoData[i] ) )
  102.                                 {
  103.                                         static line, line_len;
  104.                                         static data[64];
  105.                                         static map[32], kreedzer[32], time_str[16], len, temp[32], ext[16];
  106.                                         new time_num;
  107.                                        
  108.                                         while( ( line = read_file( g_flDemoData[i], line, data, sizeof data - 1, line_len ) ) != 0 )
  109.                                         {
  110.                                                 parse( data, temp, sizeof temp - 1, time_str, sizeof time_str - 1, kreedzer, sizeof kreedzer - 1 );
  111.                                                
  112.                                                 if( containi( temp, "[" ) != -1 )
  113.                                                 {
  114.                                                         replace( temp, sizeof temp - 1, "[", " " );
  115.                                                         replace( temp, sizeof temp - 1, "]", " " );
  116.                                                         parse( temp, map, sizeof map - 1, ext, sizeof ext - 1 );
  117.                                                         format( ext, sizeof ext - 1, "[%s]", ext );
  118.                                                 }
  119.                                                 else
  120.                                                 {
  121.                                                         map = temp;
  122.                                                         ext = "";
  123.                                                 }
  124.                                                
  125.                                                 if( equali( mapname, map ) )
  126.                                                 {
  127.                                                         if( !time_num )
  128.                                                         {
  129.                                                                 time_num = str_to_num( time_str );
  130.                                                                 len = format( message, sizeof message - 1, "%s: %s (%d:%02d) %s", g_Record[i], kreedzer, ( time_num / 60 ), ( time_num % 60 ), ext );
  131.                                                         }
  132.                                                         else
  133.                                                         {
  134.                                                                 time_num = str_to_num( time_str );
  135.                                                                 len += format( message[len], sizeof message - len - 1, " %s (%d:%02d) %s", kreedzer, ( time_num / 60 ), ( time_num % 60 ), ext );
  136.                                                         }
  137.                                                 }
  138.                                         }
  139.                                        
  140.                                         if ( !time_num )
  141.                                                 format( message, sizeof message - 1, "%s: Author: N/A", g_Record[i]);
  142.                                 }
  143.                                 else
  144.                                 {
  145.                                         format( message, sizeof message - 1, "Cannot view the record, please contact an admin!^n^"%s^" was not found", g_flDemoData[i] );
  146.                                         log_amx( "^"%s^" was not found!", g_flDemoData[i] );
  147.                                 }
  148.                                 /*
  149.                                 set_hudmessage( g_iColors[0], g_iColors[1], g_iColors[2], g_fCoords[0], g_fCoords[1], _, _, get_pcvar_float( g_CvarShowTime ), _, _, -1 );
  150.                                 show_hudmessage( plr, message );
  151.                                 */
  152.                                 client_print(plr, print_chat, message);
  153.                         }
  154.                 }
  155.         }
  156. }
  157.  
  158. ////////////////////////////////////////////////////////////////////////////////////////////////////
  159. //      Updater
  160. ////////////////////////////////////////////////////////////////////////////////////////////////////
  161.  
  162. public cmdUpdate( )
  163. {
  164.         for( new i ; i < MAX ; i++ )
  165.                 download( g_DownloadUrl[i], g_flDemoData[i] );
  166.                
  167.         server_print( "[kz_records.amxx] Updating %i files", MAX );
  168. }
  169.        
  170. ////////////////////////////////////////////////////////////////////////////////////////////////////
  171. //      Change the hudmessage
  172. ////////////////////////////////////////////////////////////////////////////////////////////////////
  173.        
  174. public cmdChangePos( plr )
  175. {      
  176.         if( ( get_user_flags( plr ) & ADMIN_KICK ) )
  177.         {
  178.                 if( read_argc( ) == 3 )
  179.                 {
  180.                         new x_str[4], y_str[4];
  181.                         read_argv( 1, x_str, sizeof y_str - 1 );
  182.                         read_argv( 2, y_str, sizeof x_str - 1 );
  183.                        
  184.                         new Float:x_num, Float:y_num;
  185.                         x_num = str_to_float( x_str );
  186.                         y_num = str_to_float( y_str );
  187.                        
  188.                         if( -1.0 <= x_num <= 1.0 && -1.0 <= y_num <= 1.0 )
  189.                         {
  190.                                 g_fCoords[0] = x_num;
  191.                                 g_fCoords[1] = y_num;
  192.                                
  193.                                 client_print( plr, print_console, "kz_records_pos changed to ^"%f %f^"", x_num, y_num );
  194.                         }
  195.                         else
  196.                                 client_print( plr, print_console, "<x> and <y> have to be between -1.0 and 1.0" );
  197.                 }
  198.                 else
  199.                         client_print( plr, print_console, "Usage: kz_records_pos <x> <y>" );
  200.         }
  201.         else
  202.                 client_print( plr, print_console, "* You have no access to this command" );
  203. }
  204.  
  205. public cmdChangeColor( plr )
  206. {
  207.         if( ( get_user_flags( plr ) & ADMIN_KICK ) )
  208.         {
  209.                 if( read_argc( ) == 4 )
  210.                 {
  211.                         new r_str[4], g_str[4], b_str[4];
  212.                         read_argv( 1, r_str, sizeof r_str - 1 );
  213.                         read_argv( 2, g_str, sizeof g_str - 1 );
  214.                         read_argv( 3, b_str, sizeof b_str - 1 );
  215.                        
  216.                         new r_num, g_num, b_num;
  217.                         r_num = str_to_num( r_str );
  218.                         g_num = str_to_num( g_str );
  219.                         b_num = str_to_num( b_str );
  220.                        
  221.                         if( 0 <= r_num <= 255 && 0 <= g_num <= 255 && 0 <= b_num <= 255 )
  222.                         {
  223.                                 g_iColors[0] = r_num;
  224.                                 g_iColors[1] = g_num;
  225.                                 g_iColors[2] = b_num;
  226.                                
  227.                                 client_print( plr, print_console, "kz_records_color changed to ^"%i %i %i^"", r_num, g_num, b_num );
  228.                         }
  229.                         else
  230.                                 client_print( plr, print_console, "<red>, <green> and <blue> have to be between 0 and 255" );
  231.                 }
  232.                 else
  233.                         client_print( plr, print_console, "Usage: kz_records_color <red> <green> <blue>" );
  234.         }
  235.         else
  236.                 client_print( plr, print_console, "* You have no access to this command" );
  237. }