Rock

rLogs

Aug 2nd, 2012
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.45 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #if defined _ServerLogs_included
  4.     #endinput
  5. #endif
  6.  
  7. #define _ServerLogs_included
  8.  
  9. #define LogExist fexist
  10.  
  11. stock CreateLog( const File[ ] )
  12. {
  13.     if( fexist( File ) )
  14.     {
  15.         printf("Use like this (\"file\", \"message\"); to write in a file.");
  16.         return 0;
  17.     }
  18.     new File:File_Rk = fopen( File, io_write );
  19.     fclose( File_Rk );
  20.    
  21.     return 1;
  22. }
  23.  
  24. stock WriteLog( const File[ ], string[ ] )
  25. {
  26.     if( !fexist( File ) )
  27.     {
  28.         printf("Use CreateLog(\"file\"); to create and write in log.");
  29.         return 0;
  30.     }
  31.     new r_strg[ 300 ];
  32.     new a, m, d, h, mi, s;
  33.     getdate( a, m, d );
  34.     gettime( h,mi,s );
  35.     format( r_strg, sizeof( r_strg ), "(%d/%d/%d)[%02d:%02d:%d] %s\r\n", d, m, a, h, mi , s, string );
  36.     new File:File_r = fopen( File, io_append );
  37.     fwrite( File_r, r_strg );
  38.     fclose( File_r );
  39.    
  40.     return 1;
  41. }
  42.  
  43. stock DeleteLog( const File[ ] )
  44. {
  45.     if( !fexist( File ) )
  46.     {
  47.         printf("This log doesn't exist.");
  48.         return 0;
  49.     }
  50.     fremove( File );
  51.    
  52.     return 1;
  53. }
  54.  
  55. stock ReadLog( const File[ ] )
  56. {
  57.     if( !fexist( File ) )
  58.     {
  59.         printf("This log doesen't exist.");
  60.         return 0;
  61.     }
  62.     new rk_strg[ 100 ];
  63.     new File:r_File = fopen( File, io_read );
  64.     while( fread( r_File, rk_strg ) )
  65.     {
  66.         printf( "[ %s ] %s", File, rk_strg );
  67.         return 1;
  68.     }
  69.     fclose( r_File );
  70.    
  71.     return 1;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment