IlanZiin

Logs de Conexão

Feb 4th, 2018
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.32 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #define Arquivo_Log "logs.txt"
  4.  
  5. main(){}
  6.  
  7. public OnPlayerConnect(playerid)
  8. {
  9.     new File:Logs = fopen(Arquivo_Log, io_append);
  10.     if(Logs)
  11.     {
  12.         new string[128], IP[30], time[6];
  13.         gettime(time[0], time[1], time[2]);
  14.         getdate(time[5], time[4], time[3]);
  15.         GetPlayerIp(playerid, IP, sizeof(IP));
  16.         format(string,sizeof(string), "[%02d:%02d:%02d | %02d/%02d/%02d | IP: %s] %s conectou no servidor \r\n", time[0], time[1], time[2], time[3],time[4],time[5],IP,PlayerName(playerid));
  17.         fwrite(Logs, string);
  18.         fclose(Logs);
  19.     }
  20.     else
  21.     {
  22.         printf("Arquivo %s não encontrado", Arquivo_Log);
  23.     }
  24.     return 1;
  25. }
  26.  
  27. public OnPlayerDisconnect(playerid, reason)
  28. {
  29.     new File:Logs = fopen(Arquivo_Log, io_append);
  30.     if(Logs)
  31.     {
  32.         new string[128], IP[30], time[6];
  33.         gettime(time[0], time[1], time[2]);
  34.         getdate(time[5], time[4], time[3]);
  35.         GetPlayerIp(playerid, IP, sizeof(IP));
  36.         format(string,sizeof(string), "[%02d:%02d:%02d | %02d/%02d/%02d | IP: %s] %s deslogou do servidor \r\n", time[0], time[1], time[2], time[3],time[4],time[5],IP,PlayerName(playerid));
  37.         fwrite(Logs, string);
  38.         fclose(Logs);
  39.     }
  40.     else
  41.     {
  42.         printf("Arquivo %s não encontrado", Arquivo_Log);
  43.     }
  44.     return 1;
  45. }
  46.  
  47. PlayerName(playerid)
  48. {
  49.     new nome[24];
  50.     GetPlayerName(playerid, nome, sizeof(nome));
  51.     return nome;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment