Guest User

kLog V1.0

a guest
Aug 5th, 2012
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.46 KB | None | 0 0
  1. /*
  2.     NAME:   kLog
  3.     DESC:   Log System
  4.     AUTHOR: Orel Lazri (oKzrh)
  5.             SKYPE: iferox2
  6.             EMAIL: [email protected]
  7. */
  8.  
  9. //--------------- INCLUDES ---------------
  10. #include <a_samp>
  11.  
  12. //--------------- DEFINES ----------------
  13. // Comment those lines below to disable them
  14. #define ADMIN_LOG 1 // Also log admin text and commands
  15. #define ADMIN_LOG_CHAT 1 // When each log is written, admins can also see it
  16.  
  17. //--------------- PUBLICS ----------------
  18. public OnPlayerText(playerid, text[]) {
  19.     #if ADMIN_LOG
  20.         WriteLog(playerid, text);
  21.     #else
  22.         if (!IsPlayerAdmin(playerid))
  23.             WriteLog(playerid, text);
  24.     #endif
  25.     return 1;
  26. }
  27.  
  28. public OnPlayerCommandText(playerid, cmdtext[]) {
  29.     #if ADMIN_LOG
  30.         WriteLog(playerid, cmdtext);
  31.     #else
  32.         if (!IsPlayerAdmin(playerid))
  33.             WriteLog(playerid, cmdtext);
  34.     #endif
  35.     return 0;
  36. }
  37.  
  38. //--------------- STOCKS -----------------
  39. stock GN(playerid) {
  40.     new pname[MAX_PLAYER_NAME];
  41.     GetPlayerName(playerid, pname, sizeof(pname));
  42.     return pname;
  43. }
  44.  
  45. stock WriteLog(playerid, text[]) {
  46.     new str[140], time[3], File:log = fopen("klog.txt", io_append);
  47.     gettime(time[0], time[1], time[2]);
  48.     format(str, sizeof(str), "[%d:%d:%d] %s: %s\r\n", time[0], time[1], time[2], GN(playerid), text);
  49.     fwrite(log, str);
  50.     fclose(log);
  51.     #if defined ADMIN_LOG_CHAT
  52.         for (new i = 0; i < MAX_PLAYERS; i++) {
  53.             if (IsPlayerConnected(i) && IsPlayerAdmin(i) && playerid != i)
  54.                 SendClientMessage(i, 0x757575AA, str);
  55.         }
  56.     #endif
  57.     return 1;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment