Advertisement
Guest User

RoaRec v1.0

a guest
Nov 2nd, 2011
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 8.02 KB | None | 0 0
  1. #if defined ROAREC_V1_0_
  2. ================================================================================
  3.                            RoaRec v1.0 by Roach
  4. ================================================================================
  5.    - Credits to Zh3r0 from some Examples( in The Eclipse ).
  6.    - Credits to Y_Less for y_ini and foreach.
  7.    - Credits to Zh3r0 for FormatMSG and FormatMSGToAll Function( Define ).
  8.    - Credits to Zh3r0 for my Identitation.
  9.    - Credits to stuntman from some ideeas and councils.
  10.    - Thanks to Ryder_RO for helping and for the RoaRec( Record System ) Ideea.
  11. ================================================================================
  12. #endif
  13.  
  14. //==============================================================================//
  15. //                              Includes                                        //
  16. //==============================================================================//
  17. #include <  a_samp > // Credits to the SA:MP - Developement Team
  18. #include <YSI\y_ini> // Credits to Y_Less
  19. #include < foreach > // Credits to Y_Less
  20.  
  21. //==============================================================================//
  22. //                              RoaRec Timer Time                                   //
  23. //==============================================================================//
  24. #define rTime           5000 // you can Modify this( in Miliseconds )
  25.  
  26. //==============================================================================//
  27. //                              RoaRec Target                                   //
  28. //==============================================================================//
  29. #define rRecTarget      "rRecord.sav"
  30.  
  31. //==============================================================================//
  32. //                          Repleaced/Shorcuts                                  //
  33. //==============================================================================//
  34. #define Public:%0(%1)   forward %0( %1 ); public %0( %1 )
  35.  
  36. #define FormatMSG(%0,%1,%2,%3)\
  37. do\
  38. {\
  39.      format( _S_T_R_, 10000, (%2), %3 );\
  40.      SendClientMessage((%0),(%1), _S_T_R_);\
  41. }\
  42. while ( False )
  43.  
  44. //------------------------------------------------------------------------------//
  45.  
  46. new
  47.     H[ 1 + 1 ], /*Hours + Minutes*/
  48.    
  49.     _S_T_R_[ 1000 ], /*Universal String*/
  50.    
  51.     rPlayers, /*Online Players*/
  52.    
  53.     rNRec[ MAX_PLAYER_NAME ], /*Name of the Player*/
  54.    
  55.     rARec, /*Amount of Players( Record )*/
  56.    
  57.     rDRec[ 3 ], /*Date of the Record*/
  58.    
  59.     rHRec[ 2 ] /*Hour of the Record*/
  60. ;
  61.  
  62. new rMounth[ 12 ][ ] =
  63. {
  64.     "January",
  65.    
  66.     "February",
  67.    
  68.     "March",
  69.    
  70.     "April",
  71.    
  72.     "May",
  73.    
  74.     "June",
  75.    
  76.     "July",
  77.    
  78.     "August",
  79.    
  80.     "September",
  81.    
  82.     "October",
  83.    
  84.     "November",
  85.    
  86.     "December"
  87. };
  88.  
  89. stock
  90.    bool:False = false /*Bool for FormatMSG*/
  91. ;
  92.  
  93. public OnFilterScriptInit( )
  94. {
  95.     rPlayers = OnlinePlayers( );
  96.    
  97.     INI_ParseFile(rRecTarget, "pRecord"); // ParseFile
  98.  
  99.     gettime( H[ 0 ], H[ 1 ] );
  100.  
  101.     print(  "\n==========================================" );
  102.     print(  "|| -> RoaRec v1.0 By Roach Loaded       ||"  );
  103.     print(  "==========================================  " );
  104.     printf( "|| %02d:%02d        ||      ", H[ 0 ], H[ 1 ] );
  105.     print(  "==================\n"                         );
  106.     return ( 1 );
  107. }
  108.  
  109. public OnFilterScriptExit( )
  110. {
  111.     gettime( H[ 0 ], H[ 1 ] );
  112.  
  113.     print(  "\n==========================================" );
  114.     print(  "|| -> RoaRec v1.0 By Roach UnLoaded      ||" );
  115.     print(  "==========================================  " );
  116.     printf( "|| %02d:%02d        ||      ", H[ 0 ], H[ 1 ]  );
  117.     print(  "==================\n"                          );
  118.     return ( 1 );
  119. }
  120.  
  121. public OnPlayerConnect( playerid )
  122. {
  123.     INI_ParseFile(rRecTarget, "pRecord"); // ParseFile
  124.  
  125.     SetTimerEx( "rRecord", rTime, false, "d", playerid );
  126.     return ( 1 );
  127. }
  128.  
  129. public OnPlayerDisconnect( playerid, reason )
  130. {
  131.     rPlayers --;
  132.     return( 1 );
  133. }
  134.  
  135. //------------------------------------------------------------------------------//
  136.  
  137. //==============================================================================
  138. // Usage: OnlinePlayers( );
  139. // Function: Use to see how many players are on the Server.
  140. //==============================================================================
  141. OnlinePlayers( )
  142. {
  143.     new rConn;
  144.     foreach(Player, i) rConn++;
  145.     return ( rConn );
  146. }
  147.  
  148. //==============================================================================
  149. // Usage: ---
  150. // Function: To check if is a new record or the Old.
  151. //==============================================================================
  152. Public:rRecord( playerid )
  153. {
  154.     rPlayers ++;
  155.    
  156.     if( rARec ) FormatMSG( playerid, -1, "• Record for Online Players: {97FA17}%d{FFFFFF}, fixed {97FA17}%d %s %d{FFFFFF}, at {97FA17}%d:%d{FFFFFF} by {97FA17}%s{FFFFFF}.", rARec, rDRec[ 0 ], rMounth[ rDRec[ 1 ] - 1 ], rDRec[ 2 ], rHRec[ 0 ], rHRec[ 1 ], rNRec );
  157.    
  158.     if( rARec < rPlayers )
  159.     {
  160.         new Date[ 5 ];
  161.         getdate( Date[ 0 ], Date[ 1 ], Date[ 2 ] );
  162.         gettime( Date[ 3 ], Date[ 4 ]            );
  163.    
  164.         format( rNRec, sizeof rNRec, "%s", pName( playerid ) );
  165.        
  166.         rARec = OnlinePlayers( );
  167.        
  168.         foreach(Player, i) FormatMSG( i, -1, "• New record for Online Players: {97FA17}%d{FFFFFF}, fixed on {97FA17}%d %s %d{FFFFFF}, at {97FA17}%d:%d{FFFFFF} by {97FA17}%s{FFFFFF}.", OnlinePlayers( ), Date[ 2 ], rMounth[ Date[ 1 ] - 1 ], Date[ 0 ], Date[ 3 ], Date[ 4 ], pName( playerid ) );
  169.        
  170.         rSaveRec( );
  171.     }
  172. }
  173.  
  174. //==============================================================================
  175. // Usage: ---
  176. // Function: To save the Data( Y_INI ).
  177. //==============================================================================
  178. Public:pRecord( name[ ], value[ ] )
  179. {
  180.     if( !strcmp ( name, "rName" ) )
  181.     {
  182.         format( rNRec, sizeof rNRec, "%s", value );
  183.     }
  184.     if( !strcmp ( name, "rNumber" ) )
  185.     {
  186.         rARec = strval( value );
  187.     }
  188.     if( !strcmp ( name, "rDay" ) )
  189.     {
  190.         rDRec[ 0 ] = strval( value );
  191.     }
  192.     if( !strcmp ( name, "rMonth" ) )
  193.     {
  194.         rDRec[ 1 ] = strval( value );
  195.     }
  196.     if( !strcmp ( name, "rYear" ) )
  197.     {
  198.         rDRec[ 2 ] = strval( value );
  199.     }
  200.     if( !strcmp ( name, "rHour" ) )
  201.     {
  202.         rHRec[ 0 ] = strval( value );
  203.     }
  204.     if( !strcmp ( name, "rMins" ) )
  205.     {
  206.         rHRec[ 1 ] = strval( value );
  207.     }
  208. }
  209.  
  210. //==============================================================================
  211. // Usage: rSaveRec( );
  212. // Function: To write( with Y_INI ) in the rRecord.sav file.
  213. //==============================================================================
  214. rSaveRec( )
  215. {
  216.     gettime( rHRec[ 0 ], rHRec[ 1 ] );
  217.     getdate( rDRec[ 2 ], rDRec[ 1 ], rDRec[ 0 ] );
  218.  
  219.     new INI:rRec = INI_Open( rRecTarget );
  220.    
  221.     INI_WriteString( rRec, "rName", rNRec );
  222.     INI_WriteInt( rRec, "rNumber", OnlinePlayers( ) );
  223.     INI_WriteInt( rRec, "rDay", rDRec[ 0 ] );
  224.     INI_WriteInt( rRec, "rMonth", rDRec[ 1 ] );
  225.     INI_WriteInt( rRec, "rYear", rDRec[ 2 ] );
  226.     INI_WriteInt( rRec, "rHour", rHRec[ 0 ] );
  227.     INI_WriteInt( rRec, "rMins", rHRec[ 1 ] );
  228.    
  229.     INI_Close( rRec );
  230. }
  231.  
  232. //==============================================================================
  233. // Usage: pName( playerid );
  234. // Function: Used to get the name of a player.
  235. //==============================================================================
  236. pName( p )
  237. {
  238.     new NAME[ MAX_PLAYER_NAME ];
  239.     GetPlayerName( p, NAME, MAX_PLAYER_NAME );
  240.     return ( NAME );
  241. }
  242.  
  243. //==============================================================================
  244. // Usage: rDate( )
  245. // Function: Used to get the Record Date.
  246. //==============================================================================
  247. stock rDate( Sec = false )
  248. {
  249.    new zStr[ 30 ];
  250.    if ( Sec )
  251.    {
  252.       new Date[ 6 ];
  253.       getdate( Date[ 0 ], Date[ 1 ], Date[ 2 ] );
  254.       gettime( Date[ 3 ], Date[ 4 ], Date[ 5 ] );
  255.       format( zStr, 30, "{97FA17}%d %s %d{FFFFFF}, at {97FA17}%d:%d:%d{FFFFFF}", Date[ 2 ], Date[ 1 ], Date[ 0 ], Date[ 3 ], Date[ 4 ], Date[ 5 ] );
  256.    }
  257.    else
  258.    {
  259.       new Date[ 5 ];
  260.       getdate( Date[ 0 ], Date[ 1 ], Date[ 2 ] );
  261.       gettime( Date[ 3 ], Date[ 4 ]          );
  262.       format( zStr, 30, "{97FA17}%d %s %d{FFFFFF}, at {97FA17}%d:%d{FFFFFF}", Date[ 2 ], rMounth[ Date[ 1 ] - 1 ], Date[ 0 ], Date[ 3 ], Date[ 4 ] );
  263.    }
  264.    return ( zStr );
  265. }
  266.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement