Advertisement
Paulo_AttacK

DelAuto Acc v2.0

Dec 14th, 2012
431
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.33 KB | None | 0 0
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. //
  4. //        #### ########   ######     ######## ########    ###    ##     ##
  5. //         ##  ##     ## ##    ##       ##    ##         ## ##   ###   ###
  6. //         ##  ##     ## ##             ##    ##        ##   ##  #### ####
  7. //         ##  ########   ######        ##    ######   ##     ## ## ### ##
  8. //         ##  ##              ##       ##    ##       ######### ##     ##
  9. //         ##  ##        ##    ##       ##    ##       ##     ## ##     ##
  10. //        #### ##         ######        ##    ######## ##     ## ##     ##
  11. //
  12. //
  13. //                              DelAuto Acc v2.0
  14. //
  15. /*                   ______          ______           _      
  16. //                   | ___ \         | ___ \         | |      
  17. //                   | |_/ /_   _    | |_/ /_ _ _   _| | ___  
  18. //                   | ___ \ | | |   |  __/ _` | | | | |/ _ \
  19. //                   | |_/ / |_| |_  | | | (_| | |_| | | (_) |
  20. //                   \____/ \__, (_) \_|  \__,_|\__,_|_|\___/
  21. //                           __/ |                            
  22. //                          |___/                            
  23. */                            
  24. //
  25. //            !!!   Deleta automaticamente contas de usuários inativos, usando INI  !!!
  26. //
  27. //          [iPs]TeaM soluções de programação em geral (agora com cursos)
  28. //
  29. //                  http://ips-team.forumeiros.com/ (contate-nos)
  30. //
  31. /////////////////////////////////////////////////////////////////////////////////
  32.  
  33. #define pTIME 30 //Coloque em dias aqui o tempo para que a Acc seja deletada.
  34. #define pFILE "Contas/%s.ini" //Coloque aqui o caminho das contas dos Players.
  35. #define pBACKUP "pBackup" //Configure aqui sua Pasta de Backups.
  36. #define pCriarArq(%0) fclose(fopen(%0, io_append))
  37. #define pUSERS 255 //Número de linhas máximo das Acc's.
  38. #if !defined isnull
  39.     #define isnull(%1) !(%1[0]) || %1[0] == '\1' && !(%1[1])
  40. #endif
  41.  
  42. public OnGameModeInit() {
  43.     if(fexist("pNameUsers.Paulo")) {
  44.         new File: pArq, pTime = gettime(), pStr[64], pName[24], pFind;
  45.         pArq = fopen("pNameUsers.Paulo", io_read);
  46.         while(fread(pArq, pStr)) {
  47.             if(pTime > strval(pStr[(pFind = strfind(pStr, "=") + 1)]) > 0) {
  48.                 strmid(pName, pStr, 0, (pFind - 1));
  49.                 format(pStr, 64, pFILE, pName);
  50.                 pRemoveKey("pNameUsers.Paulo", pName);
  51.                 printf("User: %s teve sua Conta deletada pois ficou invativo por mais de %i dias.", pName, pTIME);
  52.                 pMoveFile(pStr);
  53.             }
  54.         }
  55.         fclose(pArq);
  56.     } else pCriarArq("pNameUsers.Paulo");
  57.     return CallLocalFunction("DelOnGameModeInit", #);
  58. }
  59.  
  60. public OnPlayerConnect(playerid) {
  61.     if(fexist("pNameUsers.Paulo")) pWriteFile("pNameUsers.Paulo", pGetPlayerName(playerid), (gettime() + (60 * 60 * 24 * pTIME)));
  62.     return CallLocalFunction("DelOnPlayerConnect", "i", playerid);
  63. }
  64.  
  65. #if defined _ALS_OnGameModeInit
  66.     #undef OnGameModeInit
  67. #else
  68.     #define _ALS_OnGameModeInit
  69. #endif
  70.  
  71. #if defined _ALS_OnPlayerConnect
  72.     #undef OnPlayerConnect
  73. #else
  74.     #define _ALS_OnPlayerConnect
  75. #endif
  76.  
  77. #define OnGameModeInit DelOnGameModeInit
  78. #define OnPlayerConnect DelOnPlayerConnect
  79.  
  80. forward DelOnGameModeInit();
  81. forward DelOnPlayerConnect(playerid);
  82.  
  83. pGetPlayerName(playerid) {
  84.     new pName[24];
  85.     GetPlayerName(playerid, pName, 24);
  86.     return pName;
  87. }
  88.  
  89. pWriteFile(file[], key[], valor) {
  90.     new File: pArq, pStr[40];
  91.     pRemoveKey(file, key);
  92.     pArq = fopen(file, io_append);
  93.     format(pStr, 40, "%s=%i\r\n", key, valor);
  94.     fwrite(pArq, pStr);
  95.     fclose(pArq);
  96.     return 1;
  97. }
  98.  
  99. stock pFileSave[pUSERS][128], bFileSave[pUSERS][128];
  100. pMoveFile(file[]) {
  101.     new File: pFile, pStr[35], pPos;
  102.     if(!fexist(file)) return 0;
  103.     pFileSave = bFileSave;
  104.     pFile = fopen(file, io_read);
  105.     while(fread(pFile, pStr)) pFileSave[pPos++] = pStr;
  106.     fclose(pFile);
  107.     fremove(file);
  108.     strdel(file, 0, strfind(file, "/"));
  109.     format(file, 64, "%s/%s", pBACKUP, file);
  110.     pFile = fopen(file, io_write);
  111.     for(new pI; pPos > -1; --pPos) fwrite(pFile, pFileSave[pI++]);
  112.     fclose(pFile);
  113.     return 1;
  114. }
  115.  
  116. pRemoveKey(file[], ignorekey[]) {
  117.     new File: pFile, pStr[35], bool: pVar, pPos;
  118.     if(!fexist(file)) return 0;
  119.     pFileSave = bFileSave;
  120.     pFile = fopen(file, io_read);
  121.     while(fread(pFile, pStr)) {
  122.         if(strfind(pStr, ignorekey, true) == -1) {
  123.             pFileSave[pPos++] = pStr;
  124.         } else pVar = true;
  125.     }
  126.     fclose(pFile);
  127.     if(!pVar) return 0;
  128.     fremove(file);
  129.     pFile = fopen(file, io_write);
  130.     for(new pI; pPos > -1; --pPos) fwrite(pFile, pFileSave[pI++]);
  131.     fclose(pFile);
  132.     return 1;
  133. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement