Advertisement
captmicro

KAC_FILTER v3

Aug 1st, 2010
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.87 KB | None | 0 0
  1. //- CREATE file kac_filter.txt in main directory. One SteamID per line. [IMPORTANT!]
  2.  
  3. //- REPLACE KAC_Kick in translations.sp with below function [DONT KICK FILTERED PLAYERS] -//
  4. stock KAC_Kick(client, const String:trans[], any:...)
  5. {
  6.     //- FILTER START --//
  7.     new String:f_sID[64];
  8.     GetClientAuthString(client, f_sID, sizeof(f_sID));
  9.     new Handle:f_sIDfile = OpenFile("kac_filter.txt", "r");
  10.     new String:f_sIDline[64];
  11.     new bool:f_sIDfilterd = false;
  12.     if (f_sIDfile == INVALID_HANDLE) {
  13.         PrintToServer("KAC_FILTER: Error opening kac_filter.txt!");
  14.     } else {
  15.         while (!IsEndOfFile(f_sIDfile) && ReadFileLine(f_sIDfile, f_sIDline, sizeof(f_sIDline)))
  16.         {
  17.             new len = strlen(f_sIDline);
  18.             for (new i = 0; i < len; i++) { if (IsCharSpace(f_sIDline[i])) { f_sIDline[i] = '\0'; break; } }
  19.             if (strcmp(f_sIDline, f_sID) == 0) { f_sIDfilterd = true; }
  20.         }
  21.     }
  22.     if (f_sIDfilterd) {
  23.         PrintToServer("KAC_FILTER: Bypass KAC_Kick for %s", f_sID);
  24.     } else { //- FILTER DEFAULT -//
  25.    
  26.     decl String:f_sBuffer[256], String:f_sFormat[256];
  27.     GetTrieString(g_hCLang[client], trans, f_sFormat, sizeof(f_sFormat));
  28.     VFormat(f_sBuffer, sizeof(f_sBuffer), f_sFormat, 3);
  29.     KickClient(client, "%s", f_sBuffer);
  30.     OnClientDisconnect(client); // Do this since the client is no longer useful to us. - Kigen
  31.    
  32.     } CloseHandle(f_sIDfile); //- FILTER END -//
  33. }
  34.  
  35. //- REPLACE KAC_Ban in translations.sp with below function [DONT BAN FILTERED PLAYERS] -//
  36. stock KAC_Ban(client, time, const String:trans[], const String:format[], any:...)
  37. {
  38.     //- FILTER START --//
  39.     new String:f_sID[64];
  40.     GetClientAuthString(client, f_sID, sizeof(f_sID));
  41.     new Handle:f_sIDfile = OpenFile("kac_filter.txt", "r");
  42.     new String:f_sIDline[64];
  43.     new bool:f_sIDfilterd = false;
  44.     if (f_sIDfile == INVALID_HANDLE) {
  45.         PrintToServer("KAC_FILTER: Error opening kac_filter.txt!");
  46.     } else {
  47.         while (!IsEndOfFile(f_sIDfile) && ReadFileLine(f_sIDfile, f_sIDline, sizeof(f_sIDline)))
  48.         {
  49.             new len = strlen(f_sIDline);
  50.             for (new i = 0; i < len; i++) { if (IsCharSpace(f_sIDline[i])) { f_sIDline[i] = '\0'; break; } }
  51.             if (strcmp(f_sIDline, f_sID) == 0) { f_sIDfilterd = true; }
  52.         }
  53.     }
  54.     if (f_sIDfilterd) {
  55.         PrintToServer("KAC_FILTER: Bypass KAC_Kick for %s", f_sID);
  56.     } else { //- FILTER DEFAULT -//
  57.        
  58.     new String:f_sBuffer[256], String:f_sEReason[256];
  59.     GetTrieString(g_hCLang[client], trans, f_sEReason, sizeof(f_sEReason));
  60.     VFormat(f_sBuffer, sizeof(f_sBuffer), format, 5);
  61.     if ( g_bSourceBans )
  62.         SBBanPlayer(0, client, time, f_sBuffer);
  63.     else
  64.         BanClient(client, time, BANFLAG_AUTO, f_sBuffer, f_sEReason, "KAC");
  65.     OnClientDisconnect(client); // Bashats!
  66.    
  67.     } CloseHandle(f_sIDfile); //- FILTER END -//
  68. }
  69.  
  70. //- REPLACE Network_OnSockRecvVer in network.sp with below function [DISABLE UPDATING] -//
  71. public Network_OnSockRecvVer(Handle:socket, String:data[], const size, any:we)
  72. {
  73.     g_bVCheckDone = true;
  74.     g_hVTimer = CreateTimer(14400.0, Network_VTimer);
  75.     //- LogMessage("Received that KAC is up-to-date."); -//
  76.     if ( SocketIsConnected(socket) )
  77.         SocketDisconnect(socket);
  78. }
  79.  
  80.  
  81. //- REPLACE Network_OnSocketReceive in network.sp with below function [BYPASS GBAN LIST FOR FILTERED PLAYERS] -//
  82. public Network_OnSocketReceive(Handle:socket, String:data[], const size, any:client)
  83. {
  84.     if ( socket == INVALID_HANDLE || !g_bAuthorized[client] )
  85.         return;
  86.  
  87.     PrintToServer("KAC: Netowork_OnSocketReceive data; %s", data);
  88.     decl String:f_sName[64], String:f_sAuthID[64], String:f_sBuffer[256];
  89.     GetClientName(client, f_sName, 64);
  90.     GetClientAuthString(client, f_sAuthID, 64);
  91.     g_bChecked[client] = true;
  92.     if ( StrEqual(data, "_BAN") )
  93.     {
  94.         //- FILTER START --//
  95.         new String:f_sID[64];
  96.         GetClientAuthString(client, f_sID, sizeof(f_sID));
  97.         new Handle:f_sIDfile = OpenFile("kac_filter.txt", "r");
  98.         new String:f_sIDline[64];
  99.         new bool:f_sIDfilterd = false;
  100.         if (f_sIDfile == INVALID_HANDLE) {
  101.             PrintToServer("KAC_FILTER: Error opening kac_filter.txt!");
  102.         } else {
  103.             while (!IsEndOfFile(f_sIDfile) && ReadFileLine(f_sIDfile, f_sIDline, sizeof(f_sIDline)))
  104.             {
  105.                 new len = strlen(f_sIDline);
  106.                 for (new i = 0; i < len; i++) { if (IsCharSpace(f_sIDline[i])) { f_sIDline[i] = '\0'; break; } }
  107.                 if (strcmp(f_sIDline, f_sID) == 0) { f_sIDfilterd = true; }
  108.             }
  109.         }
  110.         if (f_sIDfilterd) {
  111.             PrintToServer("KAC_FILTER: Bypass KAC_Kick for %s", f_sID);
  112.         } else { //- FILTER DEFAULT -//
  113.        
  114.         KAC_Translate(client, KAC_GBANNED, f_sBuffer, sizeof(f_sBuffer));
  115.         SetTrieString(g_hDenyArray, f_sAuthID, f_sBuffer);
  116.         KAC_Log("%s (%s) is on the KAC global banlist.", f_sName, f_sAuthID);
  117.         KAC_Kick(client, KAC_GBANNED);
  118.        
  119.         } CloseHandle(f_sIDfile); //- FILTER END -//
  120.     }
  121.     else
  122.     {
  123.         g_bChecked[client] = false;
  124.         KAC_Log("%s (%s) got unknown reply from KAC master server. Data: %s", f_sName, f_sAuthID, data);
  125.         Status_Report(g_iNetStatus, KAC_ERROR);
  126.     }
  127.     if ( SocketIsConnected(socket) )
  128.         SocketDisconnect(socket);
  129. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement