Logs.inc 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /****************************************************************************************************
  2. * *
  3. * )( Log File )( *
  4. * *
  5. * Copyright © 2017 Witkacy. All rights reserved. *
  6. * *
  7. * Download: https://github.com/AbyssMorgan/SA-MP/tree/master/include/SAM *
  8. * Publication: None *
  9. * Website: http://8.ct8.pl *
  10. * *
  11. * Plugins: None *
  12. * Modules: None *
  13. * *
  14. * File Version: 1.0.1 *
  15. * SA:MP Version: 0.3.7 *
  16. * *
  17. * Functions: *
  18. * WriteLog(string[],file[]); *
  19. * *
  20. ****************************************************************************************************/
  21. #if defined _Log_File
  22. #endinput
  23. #endif
  24. #define _Log_File
  25. #if !defined EMPTY_LOG_BUFFER
  26. #define EMPTY_LOG_BUFFER ""
  27. #endif
  28. forward WriteLog(string[],file[]);
  29. public WriteLog(string[],file[]){
  30. static wl_date[3],wl_time[3],wl_str[512];
  31. getdate(wl_date[0],wl_date[1],wl_date[2]);
  32. gettime(wl_time[0],wl_time[1],wl_time[2]);
  33. format(wl_str,sizeof wl_str,"[%02d.%02d.%02d %02d:%02d:%02d] %s\r\n",wl_date[0],wl_date[1],wl_date[2],wl_time[0],wl_time[1],wl_time[2],string);
  34. if(!fexist(file)){
  35. new File:cfile = fopen(file,io_readwrite);
  36. fwrite(cfile,EMPTY_LOG_BUFFER);
  37. fclose(cfile);
  38. }
  39. new File:flog = fopen(file,io_append);
  40. fwrite(flog,wl_str);
  41. fclose(flog);
  42. return 1;
  43. }
  44. //EOF