Advertisement
Guest User

Untitled

a guest
Jun 12th, 2011
410
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 10.05 KB | None | 0 0
  1. /*  Formatright © 2009, ConnorMcLeod
  2.  
  3.     AutoBhop Detector is free software;
  4.     you can redistribute it and/or modify it under the terms of the
  5.     GNU General Public License as published by the Free Software Foundation.
  6.  
  7.     This program is distributed in the hope that it will be useful,
  8.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  9.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  10.     GNU General Public License for more details.
  11.  
  12.     You should have received a copy of the GNU General Public License
  13.     along with AutoBhop Detector; if not, write to the
  14.     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  15.     Boston, MA 02111-1307, USA.
  16. */
  17.  
  18. #include <amxmodx>
  19. #include <amxmisc>
  20. #include <fakemeta>
  21. #include <hamsandwich>
  22.  
  23. // pour mon serveur ça
  24. //#define BRE_SERVER
  25.  
  26. #define VERSION "1.1.0"
  27.  
  28. #define MAX_PLAYERS 32
  29.  
  30. new g_iSayText
  31.  
  32. new g_szLogBanFile[128], g_szLogFile[128]
  33.  
  34. #if defined BRE_SERVER
  35. #define MIN_PERFBHOPS_FORCE_UFB 300
  36. native ufb_force_user(index)
  37. native is_steamid_cheater(steamid[])
  38. native set_steamid_cheater(steamid[])
  39. #define TIME_OFFSET 0
  40. new const VoogruMagicNumber[] = "76561197960265728"
  41.  
  42. #endif
  43.  
  44. new Trie:g_tNextCvar
  45.  
  46. new g_pCvarBanTime, g_pCvarSite
  47.  
  48. enum {
  49.     NoAmxBan,
  50.     AmxBans,
  51.     AmxBansNew
  52. }
  53.  
  54. #define MAX_CMD_LENGTH 32
  55. new Trie:g_tKzhAliases, Trie:g_tKzhAliases2, Trie:g_tKzhAliases3
  56.  
  57. new g_iAmxBans, amxbans_use_newbancmd
  58.  
  59. public plugin_init()
  60. {
  61.     register_plugin("Kz Police", VERSION, "ConnorMcLeod")
  62.     new pCvar = register_cvar("KzPolice", VERSION, FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_SPONLY)
  63.     set_pcvar_string(pCvar, VERSION)
  64.  
  65.     g_pCvarBanTime = register_cvar("kz_hack_bantime", "0")
  66.     #if defined BRE_SERVER
  67.         g_pCvarSite = register_cvar("kz_police_website", "http://fontaine2bre.free.fr")
  68.     #else
  69.         g_pCvarSite = register_cvar("kz_police_website", "our website")
  70.     #endif
  71.  
  72. //  RegisterHam(Ham_Player_PreThink, "player", "Ham__CBasePlayer_PreThink__Post", 1)
  73.  
  74. //  register_concmd("kz_display_jumps", "ConsoleCommand_DisplayJumps", ADMIN_BAN)
  75. //  register_clcmd("kz_check_players", "ClientCommand_CheckPlayers", ADMIN_BAN)
  76.  
  77.     g_iSayText = get_user_msgid("SayText")
  78.  
  79.     get_localinfo("amxx_logs", g_szLogFile, charsmax(g_szLogFile))
  80.     add(g_szLogFile, charsmax(g_szLogFile), "/BhopHackChecker")
  81.     if( !dir_exists(g_szLogFile) )
  82.     {
  83.         mkdir(g_szLogFile)
  84.     }
  85.  
  86.     new szDate[16]
  87.     #if defined BRE_SERVER
  88.         format_time(szDate, charsmax(szDate), "%b%Y", get_systime(TIME_OFFSET))
  89.     #else
  90.         get_time("%b%Y", szDate, charsmax(szDate))
  91.     #endif
  92.  
  93.     formatex(g_szLogBanFile, charsmax(g_szLogBanFile), "%s/Banned_%s.log", g_szLogFile, szDate)
  94.     format(g_szLogFile, charsmax(g_szLogFile), "%s/Detection_%s.log", g_szLogFile, szDate)
  95.  
  96.     if( !file_exists(g_szLogBanFile) )
  97.     {
  98.         #if defined BRE_SERVER
  99.             format_time(szDate, charsmax(szDate), "%B %Y", get_systime(TIME_OFFSET))
  100.         #else
  101.             get_time("%B %Y", szDate, charsmax(szDate))
  102.         #endif
  103.         new fp = fopen(g_szLogBanFile, "at")
  104.         fprintf(fp, "%s^n^n", szDate)
  105.         fclose(fp)
  106.     }
  107.  
  108.     new const szPrefixesList[][] = {
  109.         "kzh_bhop",
  110.         "zhy_bhop",
  111.         "kyk_bhop",
  112.         "kxk_bhop",
  113.         "xhz_bhop",
  114.         "yhz_bhop",
  115.         "v0n_bhop",
  116.         "xyz_bhop",
  117.         "kid_bhop",
  118.         "fpt_bhop",
  119.         "fuh_bhop",
  120.         "omg_bhop",
  121.         "voo_bhop",
  122.         "xHack_bhop",
  123.         "xKz_bhop",
  124.         "xkz_bhop",
  125.         "001_bhop",
  126.         "002_bhop",
  127.         "Trk_bhop",
  128.         "m3c_bhop",
  129.         "m4c_bhop",
  130.         "zhyk_bhop",
  131.         "xcfgbhop"
  132.     }
  133.     g_tNextCvar = TrieCreate()
  134.     for(new i; i<sizeof(szPrefixesList)-1; i++)
  135.     {
  136.         TrieSetString(g_tNextCvar, szPrefixesList[i], szPrefixesList[i+1])
  137.     }
  138.  
  139.     new szKzhAliases[][] = {"sw.str", "sw23.str", "slowmo", "ramp"}
  140.     new szKzhAliases2[][] = {"left", "right"}
  141.     new szKzhAliases3[][] = {"autoduck", "autojump", "autojump_units", "bhop", "bhop_standup", "cam", "fixedpitch", "fixedyaw", "noflash", "nosmoke", "speed", "speed_method", "later", "yawspeed", "loopx"}
  142.  
  143.     g_tKzhAliases = TrieCreate()
  144.     for(new i; i<sizeof(szKzhAliases); i++)
  145.     {
  146.         TrieSetCell(g_tKzhAliases, szKzhAliases[i], 1)
  147.     }
  148.     g_tKzhAliases2 = TrieCreate()
  149.     for(new i; i<sizeof(szKzhAliases2); i++)
  150.     {
  151.         TrieSetCell(g_tKzhAliases2, szKzhAliases2[i], 1)
  152.     }
  153.     g_tKzhAliases3 = TrieCreate()
  154.     for(new i; i<sizeof(szKzhAliases3); i++)
  155.     {
  156.         TrieSetCell(g_tKzhAliases3, szKzhAliases3[i], 1)
  157.     }
  158. }
  159.  
  160. public plugin_cfg()
  161. {
  162.     if( is_plugin_loaded ( "AMXBans" ) != -1 )
  163.     {
  164.         g_iAmxBans = AmxBans
  165.     }
  166.     else if( is_plugin_loaded ( "AMXBans Core" ) != -1 )
  167.     {
  168.         g_iAmxBans = AmxBansNew
  169.         amxbans_use_newbancmd = get_cvar_pointer("amxbans_use_newbancmd")
  170.     }
  171. }
  172.  
  173. public client_putinserver( id )
  174. {
  175.     remove_task(id)
  176.     if( !is_user_bot(id) && !is_user_hltv(id) )
  177.     {
  178.         set_task(0.1, "Task_CheckCheatCvar", id)
  179.     }
  180. }
  181.  
  182. public Task_CheckCheatCvar(id)
  183. {
  184.     if( is_user_connected(id) )
  185.     {
  186.         query_client_cvar(id, "kzh_bhop", "ClientCvarResult")
  187.     }
  188. }
  189.  
  190. public ClientCvarResult(id, const szCvar[], const szValue[])
  191. {
  192.     if( is_user_connected(id) )
  193.     {
  194.         if( szValue[0] != 'B' )
  195.         {
  196.             new szName[32], szAuthid[32], szReason[14]
  197.             if( equal(szCvar, "kzh", 3) )
  198.             {
  199.                 szReason = "KZHack"
  200.             }
  201.             else
  202.             {
  203.                 szReason = "KZHack Custom"
  204.             }
  205.  
  206.             get_user_name(id, szName, charsmax(szName))
  207.             get_user_authid(id, szAuthid, charsmax(szAuthid))
  208.  
  209.             #if defined BRE_SERVER
  210.                 new szCommunityId[sizeof VoogruMagicNumber]
  211.                 steamIDToCommunityID(szAuthid, szCommunityId)
  212.                 LogBan("[url=http://steamcommunity.com/profiles/%s][color=#FF0000]%s[/color][/url] [color=#FFA500]%s[/color] (%s)", szCommunityId, szName, szAuthid, szReason)
  213.                 //AddSteamId( szAuthid )
  214.                 set_steamid_cheater( szAuthid )
  215.             #else
  216.             LogBan("%s %s (%s)", szName, szAuthid, szReason)
  217.             #endif
  218.  
  219.             if( g_iAmxBans )
  220.             {
  221.                 if( g_iAmxBans == AmxBans || !get_pcvar_num(amxbans_use_newbancmd) )
  222.                 {
  223.                     server_cmd("amx_ban %d ^"%s^" ^"%s^"", get_pcvar_num(g_pCvarBanTime), szAuthid, szReason)
  224.                 }
  225.                 else
  226.                 {
  227.                     server_cmd("amx_ban ^"%s^" %d ^"%s^"", szAuthid, get_pcvar_num(g_pCvarBanTime), szReason)
  228.                 }
  229.             }
  230.             else
  231.             {
  232.                 new szSite[128]
  233.                 get_pcvar_string(g_pCvarSite, szSite, charsmax(szSite))
  234.                 server_cmd("amx_ban ^"%s^" %d ^"%s, you can complain at %s^"", szAuthid, get_pcvar_num(g_pCvarBanTime), szReason, szSite)
  235.             }
  236.             ColorChat(0, "^3%s ^4has been banned for ^3%s ^4!!", szName, szReason)
  237.         }
  238.         new szNextCvar[9]
  239.         if( TrieGetString(g_tNextCvar, szCvar, szNextCvar, charsmax(szNextCvar)) )
  240.         {
  241.             query_client_cvar(id, szNextCvar, "ClientCvarResult")
  242.         }
  243.     }
  244. }
  245.  
  246. ColorChat(id, fmt[], any:...)
  247. {
  248.     new szMsg[192]
  249.     szMsg[0] = 0x04
  250.     vformat(szMsg[1], charsmax(szMsg)-1, fmt, 3)
  251.  
  252.     message_begin(id ? MSG_ONE : MSG_ALL, g_iSayText, .player=id)
  253.     {
  254.         write_byte(id ? id : 1)
  255.         write_string(szMsg)
  256.     }
  257.     message_end()
  258. }
  259.  
  260. LogBan(const fmt[], any:...)
  261. {
  262.     new szLog[224], szDate[32], szMapName[32]
  263.     vformat(szLog, charsmax(szLog), fmt, 2)
  264.  
  265.     #if defined BRE_SERVER
  266.         format_time(szDate, charsmax(szDate), "%c", get_systime(TIME_OFFSET))
  267.     #else
  268.         get_time("%c", szDate, charsmax(szDate))
  269.     #endif
  270.     get_mapname(szMapName, charsmax(szMapName))
  271.  
  272.     new fp = fopen(g_szLogBanFile, "at")
  273.     fprintf(fp, "%s : %s^n%s^n^n", szDate, szMapName, szLog)
  274.     fclose(fp)
  275. }
  276.  
  277. #if defined BRE_SERVER
  278. steamIDToCommunityID(steamID[],communityID[sizeof VoogruMagicNumber])
  279. {          
  280.     const leftMaxLen = 8
  281.     const rightMaxLen = 20
  282.    
  283.     new left[leftMaxLen];
  284.     new right[rightMaxLen];
  285.    
  286.     strtok(steamID, left, leftMaxLen-1, right, rightMaxLen-1, ':')
  287.     strtok(right, left, leftMaxLen-1, right, rightMaxLen-1, ':')
  288.    
  289.     new iServer = str_to_num(left);
  290.     new iAuthID = str_to_num(right);
  291.    
  292.     const lastIndex = charsmax(VoogruMagicNumber) - 1
  293.     copy(communityID,charsmax(VoogruMagicNumber),VoogruMagicNumber)
  294.    
  295.     new toAdd = iAuthID * 2 + iServer;
  296.    
  297.     new toAddString[sizeof VoogruMagicNumber]
  298.     num_to_str(toAdd,toAddString,charsmax(VoogruMagicNumber));
  299.    
  300.     new addLastIndex = strlen(toAddString) - 1;
  301.    
  302.     for(new i=0;i<=addLastIndex;i++)
  303.     {
  304.         new num = toAddString[addLastIndex - i] - 48;
  305.        
  306.         new j=lastIndex - i;
  307.        
  308.         do
  309.         {
  310.             new num2 = communityID[j] - 48;
  311.             new sum = num + num2;
  312.            
  313.             communityID[j] = (sum % 10) + 48;
  314.            
  315.             num = sum / 10;
  316.            
  317.             j--;
  318.         }
  319.         while(num);
  320.     }
  321. }
  322. #endif
  323.  
  324. public client_command( id )
  325. {
  326.     static szCommand[MAX_CMD_LENGTH], iLen
  327.     iLen = read_argv(0, szCommand, charsmax(szCommand))
  328.  
  329.     strtolower(szCommand)
  330.  
  331.     if( szCommand[0] == '+' || szCommand[0] == '-' )
  332.     {
  333.         new iUnderScore = contain(szCommand, "_")
  334.         if( iUnderScore != -1 )
  335.     //  if( iLen > 5 && szCommand[4] == '_' )
  336.         {
  337.             if( TrieKeyExists(g_tKzhAliases2, szCommand[iUnderScore]) )
  338.         //  if( TrieKeyExists(g_tKzhAliases2, szCommand[5]) )
  339.             {
  340.                 BanIdKzhCustom(id, szCommand)
  341.             }
  342.         }
  343.         else if( TrieKeyExists(g_tKzhAliases, szCommand[1]) )
  344.         {
  345.             BanIdKzhCustom(id, szCommand)
  346.         }
  347.     }
  348.     else if( iLen > 4 && TrieKeyExists(g_tKzhAliases3, szCommand[4]) )
  349.     {
  350.         BanIdKzhCustom(id, szCommand)
  351.     }
  352. }
  353.  
  354. BanIdKzhCustom(const id, const szCommand[])
  355. {
  356.     new szName[32], szAuthid[32]
  357.  
  358.     get_user_name(id, szName, charsmax(szName))
  359.     get_user_authid(id, szAuthid, charsmax(szAuthid))
  360.  
  361.     #if defined BRE_SERVER
  362.         new szCommunityId[sizeof VoogruMagicNumber]
  363.         steamIDToCommunityID(szAuthid, szCommunityId)
  364.         LogBan("[url=http://steamcommunity.com/profiles/%s][color=#FF0000]%s[/color][/url] [color=#FFA500]%s[/color] (Kz Hack Command/Cvar : <%s>)", szCommunityId, szName, szAuthid, szCommand)
  365.         set_steamid_cheater( szAuthid )
  366.     #else
  367.         LogBan("%s %s (Kz Hack Custom)", szName, szAuthid)
  368.     #endif
  369.  
  370.     if( g_iAmxBans )
  371.     {
  372.         if( g_iAmxBans == AmxBans || !get_pcvar_num(amxbans_use_newbancmd) )
  373.         {
  374.             server_cmd("amx_ban %d ^"%s^" ^"Kz Hack Command/Cvar : <%s>^"", get_pcvar_num(g_pCvarBanTime), szAuthid, szCommand)
  375.         }
  376.         else
  377.         {
  378.             server_cmd("amx_ban ^"%s^" %d ^"Kz Hack Command/Cvar : <%s>^"", szAuthid, get_pcvar_num(g_pCvarBanTime), szCommand)
  379.         }
  380.     }
  381.     else
  382.     {
  383.         new szSite[128]
  384.         get_pcvar_string(g_pCvarSite, szSite, charsmax(szSite))
  385.         server_cmd("amx_ban ^"%s^" %d ^"Kz Hack Command/Cvar : <%s>, you can complain at %s^"", szAuthid, get_pcvar_num(g_pCvarBanTime), szCommand, szSite)
  386.     }
  387.     ColorChat(0, "^3%s ^4has been banned for ^3Kz Hack Custom ^4!!", szName)
  388. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement