Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #if defined _ServerLogs_included
- #endinput
- #endif
- #define _ServerLogs_included
- #define LogExist fexist
- stock CreateLog( const File[ ] )
- {
- if( fexist( File ) )
- {
- printf("Use like this (\"file\", \"message\"); to write in a file.");
- return 0;
- }
- new File:File_Rk = fopen( File, io_write );
- fclose( File_Rk );
- return 1;
- }
- stock WriteLog( const File[ ], string[ ] )
- {
- if( !fexist( File ) )
- {
- printf("Use CreateLog(\"file\"); to create and write in log.");
- return 0;
- }
- new r_strg[ 300 ];
- new a, m, d, h, mi, s;
- getdate( a, m, d );
- gettime( h,mi,s );
- format( r_strg, sizeof( r_strg ), "(%d/%d/%d)[%02d:%02d:%d] %s\r\n", d, m, a, h, mi , s, string );
- new File:File_r = fopen( File, io_append );
- fwrite( File_r, r_strg );
- fclose( File_r );
- return 1;
- }
- stock DeleteLog( const File[ ] )
- {
- if( !fexist( File ) )
- {
- printf("This log doesn't exist.");
- return 0;
- }
- fremove( File );
- return 1;
- }
- stock ReadLog( const File[ ] )
- {
- if( !fexist( File ) )
- {
- printf("This log doesen't exist.");
- return 0;
- }
- new rk_strg[ 100 ];
- new File:r_File = fopen( File, io_read );
- while( fread( r_File, rk_strg ) )
- {
- printf( "[ %s ] %s", File, rk_strg );
- return 1;
- }
- fclose( r_File );
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment