Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include < a_samp >
- #include < YSI\y_va >
- #if defined _ServerLogs_included
- #endinput
- #endif
- #define _ServerLogs_included
- #define LogExist fexist
- // if you feel that a string with '300' length is too much, #define in your script "LOG_MAX_STRING"
- #if !defined LOG_MAX_STRING
- #define LOG_MAX_STRING ( 300 )
- #endif
- stock WriteInLog( const Log_File[ ], Log_Par[ ], va_args< > )
- {
- if( !LogExist( Log_File ) )
- {
- new
- File:szLogF = fopen( Log_File, io_write );
- fclose( szLogF );
- }
- static
- szLogString[ LOG_MAX_STRING ], iYear, iHour, iMonth,
- szFormatArgs[ LOG_MAX_STRING ], iDay, iSecond, iMinute
- ;
- va_format( szFormatArgs, sizeof( szFormatArgs ), Log_Par, va_start< 2 > );
- getdate( iYear, iMonth, iDay );
- gettime( iHour, iMinute, iSecond );
- format( szLogString, 300, "(%d/%d/%d)[%02d:%02d:%d] %s\r\n", iDay, iMonth, iYear, iHour, iMinute , iSecond, szFormatArgs );
- new
- File:szLog = fopen( Log_File, io_append );
- fwrite( szLog, szLogString );
- fclose( szLog );
- return 1;
- }
- stock DeleteLog( const Log_File[ ] )
- {
- if( !LogExist( Log_File ) )
- {
- printf("This log doesn't exist.");
- return 0;
- }
- fremove( Log_File );
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment