Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- /*
- native newLog(filename[]);
- native writeLog(filename[], text[]);
- native deleteLog(filename[]);
- native printLog(filename[]);
- native readLog(playerid, color, filename[]);
- */
- stock newLog ( filename [ ] ) {
- if ( fexist ( filename ) )
- return printf ( "[ERRO]: O arquivo %s já existe." , filename );
- return fclose ( fopen ( filename , io_write ) );
- }
- stock writeLog ( filename [ ] , text [ ] ) {
- new
- str [ 128 ],
- day,
- month,
- year,
- hour,
- minute,
- second,
- File: fileLog;
- if ( !fexist ( filename ) ) {
- newLog ( filename );
- }
- gettime ( hour , minute , second );
- getdate ( year , month , day );
- fileLog = fopen ( filename , io_append );
- format ( str , sizeof ( str ) , "[%02i/%02i/%04i - %02i:%02i:%02i]: %s\r\n" , day , month , year , hour , minute , second , text );
- fwrite ( fileLog , str );
- fclose ( fileLog );
- return 1;
- }
- stock deleteLog ( filename [ ] ) {
- if ( !fexist ( filename ) )
- return printf ( "[ERRO]: O arquivo %s não existe." , filename );
- return fremove ( filename );
- }
- stock printLog ( filename [ ] ) {
- new
- readString [ 128 ],
- File: logFile;
- if ( !fexist ( filename ) )
- return printf ( "[ERRO]: O arquivo %s não existe." , filename );
- logFile = fopen ( filename , io_read );
- while ( fread ( logFile , readString ) ) {
- printf ("\n[%s]: %s\n" , filename , readString );
- }
- return 1;
- }
- stock readLog ( playerid , color , filename [ ] ) {
- new
- str [ 128 ],
- readString [ 128 ],
- File: logFile;
- if ( !fexist ( filename ) )
- return format ( str , 70 , "[ERRO]: O arquivo %s não existe." , filename ) , SendClientMessage ( playerid , color , str );
- logFile = fopen ( filename , io_read );
- while ( fread ( logFile , readString ) ) {
- format ( str , sizeof str , "[%s]: %s" , filename , readString );
- SendClientMessage ( playerid , color , str );
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement