Advertisement
Guest User

zBlock Anti-Cheat ( SAMP ) v2 | made by Kyance

a guest
Jun 16th, 2014
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 39.63 KB | None | 0 0
  1. #define FILTERSCRIPT
  2.  
  3. #define COLOR_NOTES 0x2894FFFF
  4. #define COLOR_NOTES2 0xFF0000AA
  5.  
  6. #define WEBSITE "www.google.com"
  7. #define BOT_NAME "zBlock"
  8.  
  9. #define DIALOG_LOCKMODE 1
  10. #define DIALOG_SETTINGS 2
  11. #define DIALOG_SUSPECTS 3
  12.  
  13. #define ResetMoneyBar ResetPlayerMoney
  14. #define UpdateMoneyBar GivePlayerMoney
  15.  
  16. #include <a_samp>
  17. #include <zcmd>
  18. #include <sscanf2>
  19. #include <foreach>
  20.  
  21. #if defined FILTERSCRIPT
  22.  
  23. new DB:zBlock;
  24. new
  25.     datestring[ 24 ],
  26.     timestring[ 24 ]
  27. ;
  28. new
  29.     bool: Muted[ MAX_PLAYERS char ],
  30.     bool: ACDetected[ MAX_PLAYERS char ],
  31.     bool: FirstSpawn[ MAX_PLAYERS char ],
  32.     bool: AdminImmunity[ MAX_PLAYERS char ],
  33.     bool: LoggedIn[ MAX_PLAYERS char ],
  34.     AntiSpam[ MAX_PLAYERS ],
  35.     MutedTimes[ MAX_PLAYERS ],
  36.     ACTimesDetected[ MAX_PLAYERS ],
  37.     WarnForAdvert[ MAX_PLAYERS ],
  38.     RCONLoginFails[ MAX_PLAYERS ],
  39.     Cash[ MAX_PLAYERS ]
  40. ;
  41. new
  42.     DefaultPass = 1,
  43.     ServerLocked = 0,
  44.     BanForMoneyHack = 0,
  45.     BanForSpeedHack = 1
  46. ;
  47. new
  48.     Text:zBlockWarns[ MAX_PLAYERS ],
  49.     HitMarker[ MAX_PLAYERS ],
  50.     DetectedFor[ MAX_PLAYERS ][ 240 ]
  51. ;
  52. public OnFilterScriptInit()
  53. {
  54.     print("--------------------------------------");
  55.     print("Loading zBlock Anti-Cheat. . .");
  56.     print("--------------------------------------\n");
  57.    
  58.     zBlock = db_open("zBlock.db");
  59.     db_query(zBlock, "CREATE TABLE IF NOT EXISTS `BANNED` (`NAME`, `IP`, `REASON`, `ADMIN`, `DATE`, `TIME`)");
  60.    
  61.     if(!fexist("/zblock"))
  62.     {
  63.         print("WARNING: folder 'zblock' at 'scriptfiles' does NOT exist");
  64.         print("ERROR: server has crashed due to a missing folder (scriptfiles/zblock)");
  65.     }
  66.     if(!fexist("/zblock/password.txt"))
  67.     {
  68.         print("WARNING: 'password.txt' does NOT exist at the 'scriptfiles/zblock' folder");
  69.         print("NOTIFICATION: attempting to create 'password.txt'");
  70.         SetTimer("CheckForFile", 5000, false);
  71.         fcreate("/zblock/password.txt");
  72.     }
  73.     else
  74.     {
  75.         new
  76.             File: zBlockstuff = fopen("/zblock/password.txt", io_read),
  77.             string[50]
  78.         ;
  79.         if(zBlockstuff)
  80.         {
  81.             if (!fread(zBlockstuff, string))
  82.             {
  83.                 new
  84.                     File: zBlockstuff2 = fopen("/zblock/password.txt", io_write)
  85.                 ;
  86.                 fwrite(zBlockstuff2, "defaultpassword5791");
  87.                 fclose(zBlockstuff2);
  88.                 DefaultPass = 1;
  89.                 print("** zBlock: 'password.txt' was empty, default password was writen");
  90.             }
  91.             else
  92.             {
  93.                 if(!strcmp(string, "defaultpassword5791", true))
  94.                 {
  95.                     DefaultPass = 1;
  96.                     print("** zBlock: Server is using the default password\n** zBlock: Please change it for your own safety.");
  97.                 }
  98.                 else
  99.                 {
  100.                     DefaultPass = 0;
  101.                     print("** zBlock: Server is NOT using the default password\n** zBlock: The 'CP' is ready for use.");
  102.                 }
  103.             }
  104.             fclose(zBlockstuff);
  105.         }
  106.         return 1;
  107.     }
  108.     SetTimer("AntiCheat", 6500, true);
  109.     foreach(Player, i)
  110.     {
  111.         ResetInfo(i);
  112.     }
  113.     ServerLocked = 0;
  114.     BanForMoneyHack = 0;
  115.     BanForSpeedHack = 1;
  116.     return 1;
  117. }
  118.  
  119. public OnFilterScriptExit()
  120. {
  121.     print("\n--------------------------------------");
  122.     print("zBlock Anti-Cheat has been disabled. . .");
  123.     print("--------------------------------------\n");
  124.     return 1;
  125. }
  126.  
  127. #endif
  128.  
  129. public OnPlayerConnect(playerid)
  130. {
  131.     if(ServerLocked == 1)
  132.     {
  133.         SendClientMessage(playerid, COLOR_NOTES2, "zBlock: The server is in 'Lock-Mode #1', you can't connect.");
  134.         SetTimerEx("KickTimer", 100, false, "i", playerid);
  135.     }
  136.     else
  137.     {
  138.         new Query[120], DBResult:Result, day, month, year, second, minute, hour, reason[20] = "Ban Evade";
  139.         getdate(day, month, year);
  140.         gettime(hour, minute, second);
  141.  
  142.         format(Query, sizeof(Query), "SELECT `NAME` FROM `BANNED` WHERE `NAME` = '%s'", DB_Escape(GetName(playerid)));
  143.         Result = db_query(zBlock, Query);
  144.         if(db_num_rows(Result))
  145.         {
  146.             ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, "{FC4949}Ban detected.", "{FFFFFF}Our system has detected that your username is banned.\nIf you think this is a mistake visit our website.\n"WEBSITE"", "Close", "");
  147.             printf(">> %s has been kicked from OnPlayerConnect - Username ban detection", GetName(playerid));
  148.             SetTimerEx("KickTimer", 100, false, "i", playerid);
  149.  
  150.             format(Query, sizeof(Query), "SELECT `IP` FROM `BANNED` WHERE `IP` = '%s'", DB_Escape(PlayerIP(playerid)));
  151.             Result = db_query(zBlock, Query);
  152.             if(!db_num_rows(Result))
  153.             {
  154.                 format(datestring, sizeof(datestring), "%i-%i-%i", day, month, year);
  155.                 format(timestring, sizeof(timestring), "%i:%i:%i", hour, minute, second);
  156.  
  157.                 format(Query, sizeof(Query), "INSERT INTO `BANNED` (`NAME`, `IP`, `REASON`, `ADMIN`, `DATE`, `TIME`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s')", DB_Escape(GetName(playerid)), DB_Escape(PlayerIP(playerid)), reason, BOT_NAME, datestring, timestring);
  158.                 Result = db_query(zBlock, Query);
  159.             }
  160.         }
  161.         else
  162.         {
  163.             format(Query, sizeof(Query), "SELECT `IP` FROM `BANNED` WHERE `IP` = '%s'", DB_Escape(PlayerIP(playerid)));
  164.             Result = db_query(zBlock, Query);
  165.             if(db_num_rows(Result))
  166.             {
  167.                 ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, "{FC4949}Ban detected.", "{FFFFFF}Our system has detected that your ip is banned.\nIf you think this is a mistake visit our website.\n"WEBSITE"", "Close", "");
  168.                 printf(">> %s has been kicked from OnPlayerConnect - IP ban detection", GetName(playerid));
  169.                 SetTimerEx("KickTimer", 100, false, "i", playerid);
  170.  
  171.                 format(Query, sizeof(Query), "SELECT `NAME` FROM `BANNED` WHERE `NAME` = '%s'", DB_Escape(GetName(playerid)));
  172.                 Result = db_query(zBlock, Query);
  173.                 if(!db_num_rows(Result))
  174.                 {
  175.                     format(datestring, sizeof(datestring), "%i-%i-%i", day, month, year);
  176.                     format(timestring, sizeof(timestring), "%i:%i:%i", hour, minute, second);
  177.  
  178.                     format(Query, sizeof(Query), "INSERT INTO `BANNED` (`NAME`, `IP`, `REASON`, `ADMIN`, `DATE`, `TIME`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s')", DB_Escape(GetName(playerid)), DB_Escape(PlayerIP(playerid)), reason, BOT_NAME, datestring, timestring);
  179.                     Result = db_query(zBlock, Query);
  180.                 }
  181.             }
  182.         }
  183.  
  184.         ResetInfo(playerid);
  185.         zBlockWarns[playerid] = TextDrawCreate(142.500000,352.500000,"~r~zBlock - latest detection~n~~w~blablabla");
  186.         TextDrawAlignment(zBlockWarns[playerid],0);
  187.         TextDrawBackgroundColor(zBlockWarns[playerid],0x000000FF);
  188.         TextDrawFont(zBlockWarns[playerid],1);
  189.         TextDrawLetterSize(zBlockWarns[playerid],0.199999,1.000000);
  190.         TextDrawColor(zBlockWarns[playerid],0xffffffFF);
  191.         TextDrawSetOutline(zBlockWarns[playerid],1);
  192.         TextDrawSetProportional(zBlockWarns[playerid],1);
  193.         TextDrawSetShadow(zBlockWarns[playerid],1);
  194.        
  195.         FirstSpawn{ playerid } = true;
  196.     }
  197.     return 1;
  198. }
  199.  
  200. public OnPlayerDisconnect(playerid, reason)
  201. {
  202.     ResetInfo(playerid);
  203.     TextDrawDestroy(zBlockWarns[playerid]);
  204.     return 1;
  205. }
  206. public OnPlayerRequestSpawn(playerid)
  207. {
  208.     if(ServerLocked == 2)
  209.     {
  210.         SendClientMessage(playerid, COLOR_NOTES2, "zBlock: The server is in 'Lock-Mode #2', you can't spawn.");
  211.         return 0;
  212.     }
  213.     return 1;
  214. }
  215. public OnPlayerSpawn(playerid)
  216. {
  217.     if(FirstSpawn{ playerid })
  218.     {
  219.         TogglePlayerControllable(playerid, 0);
  220.         SendClientMessage(playerid, COLOR_NOTES2, "* Please wait for the server to processes you, and sets up data for you.");
  221.         SetTimerEx("EndProcessing", 3500, false, "i", playerid);
  222.     }
  223.     return 1;
  224. }
  225.  
  226. public OnPlayerDeath(playerid, killerid, reason)
  227. {
  228.     return 1;
  229. }
  230.  
  231. public OnPlayerText(playerid, text[])
  232. {
  233.     new stringz[108];
  234.     if(!AdminImmunity{ playerid })
  235.     {
  236.         if(!Muted{ playerid })
  237.         {
  238.             AntiSpam[playerid]++;
  239.             if(AntiSpam[playerid] >= 3 && AntiSpam[playerid] < 4) SendClientMessage(playerid, COLOR_NOTES2, "zBlock: Please stop flooding.");
  240.             else if(AntiSpam[playerid] >= 4)
  241.             {
  242.                 Muted{ playerid } = true;
  243.                 MutedTimes[playerid]++;
  244.                 if(MutedTimes[playerid] < 2)
  245.                 {
  246.                     SendClientMessage(playerid, COLOR_NOTES, "zBlock: You've been muted for 5 seconds due to flooding the chat.");
  247.                     SetTimerEx("Unmute", 5000, false, "i", playerid);
  248.                 }
  249.                 else if(MutedTimes[playerid] < 5 && MutedTimes[playerid] >= 2)
  250.                 {
  251.                     SendClientMessage(playerid, COLOR_NOTES, "zBlock: You've been muted for 20 seconds due to flooding the chat.");
  252.                     SetTimerEx("Unmute", 20000, false, "i", playerid);
  253.                 }
  254.                 else if(MutedTimes[playerid] >= 5)
  255.                 {
  256.                     Muted{ playerid } = false;
  257.                     format(stringz, sizeof(stringz), "zBlock: %s(%d) has been kicked for constant flood ( %d mutes )", GetName(playerid), playerid, MutedTimes[playerid]);
  258.                     SendClientMessageToAll(COLOR_NOTES2, stringz);
  259.  
  260.                     format(stringz, sizeof(stringz), "zBlock: You've been kicked for constant flood ( %d mutes )", MutedTimes[playerid]);
  261.                     SendClientMessage(playerid, COLOR_NOTES2, stringz);
  262.  
  263.                     SetTimerEx("KickTimer", 100, false, "i", playerid);
  264.                 }
  265.             }
  266.         }
  267.         SetTimerEx("ResetAntiSpam", 1700, false, "i", playerid);
  268.     }
  269.    
  270.     if(strfind(text, ":", true) != -1)
  271.     {
  272.         new i_numcount, i_period, i_pos;
  273.         while(text[i_pos])
  274.         {
  275.             if('0' <= text[i_pos] <= '9') i_numcount ++;
  276.             else if(text[i_pos] == '.') i_period ++;
  277.             i_pos++;
  278.         }
  279.         if(i_numcount >= 8 && i_period >= 3)
  280.         {
  281.             WarnForAdvert[playerid]++;
  282.             if(WarnForAdvert[playerid] < 2)
  283.             {
  284.                 format(stringz, sizeof(stringz), "zBlock: Advertising here isn't allowed.. ( %d warnings )", WarnForAdvert[playerid]);
  285.                 SendClientMessage(playerid, COLOR_NOTES2, stringz);
  286.                
  287.                 format(stringz, sizeof(stringz), "zBlock: Player %s(%d) has tried to advertise on the main-chat!", GetName(playerid), playerid);
  288.                 SendMessageToAdmins(COLOR_NOTES2, stringz);
  289.                
  290.                 printf("* zBlock: Advertise attempt by %s, proof: %s", GetName(playerid), text);
  291.                 return 0;
  292.             }
  293.             else if(WarnForAdvert[playerid] >= 2)
  294.             {
  295.                 new Query[240], reason[20] = "Advertisement", day, month, year, second, minute, hour;
  296.                 getdate(day, month, year);
  297.                 gettime(hour, minute, second);
  298.  
  299.                 format(datestring, sizeof(datestring), "%i-%i-%i", day, month, year);
  300.                 format(timestring, sizeof(timestring), "%i:%i:%i", hour, minute, second);
  301.  
  302.                 format(Query, sizeof(Query), "INSERT INTO `BANNED` (`NAME`, `IP`, `REASON`, `ADMIN`, `DATE`, `TIME`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s')", DB_Escape(GetName(playerid)), DB_Escape(PlayerIP(playerid)), reason, BOT_NAME, datestring, timestring);
  303.                 db_query(zBlock, Query);
  304.                 SetTimerEx("KickTimer", 100, false, "i", playerid);
  305.                
  306.                 printf("* zBlock: Ban applied on '%s'\n* zBlock: Reason: Advertisement\n* zBlock: Proof: %s", GetName(playerid), text);
  307.                
  308.                 format(stringz, sizeof(stringz), "zBlock: %s(%d) has been banned for advertising", GetName(playerid), playerid);
  309.                 SendClientMessageToAll(COLOR_NOTES2, stringz);
  310.                 return 0;
  311.             }
  312.         }
  313.     }
  314.     return 1;
  315. }
  316. public OnPlayerCommandPerformed(playerid, cmdtext[], success)
  317. {
  318.     new stringz[72];
  319.     if(strfind(cmdtext, ":", true) != -1)
  320.     {
  321.         new i_numcount, i_period, i_pos;
  322.         while(cmdtext[i_pos])
  323.         {
  324.             if('0' <= cmdtext[i_pos] <= '9') i_numcount ++;
  325.             else if(cmdtext[i_pos] == '.') i_period ++;
  326.             i_pos++;
  327.         }
  328.         if(i_numcount >= 8 && i_period >= 3)
  329.         {
  330.             WarnForAdvert[playerid]++;
  331.             if(WarnForAdvert[playerid] < 2)
  332.             {
  333.                 format(stringz, sizeof(stringz), "zBlock: Advertising here isn't allowed.. ( %d warnings )", WarnForAdvert[playerid]);
  334.                 SendClientMessage(playerid, COLOR_NOTES2, stringz);
  335.                
  336.                 format(stringz, sizeof(stringz), "zBlock: Player %s(%d) has tried to advertise via a command!", GetName(playerid), playerid);
  337.                 SendMessageToAdmins(COLOR_NOTES2, stringz);
  338.                
  339.                 printf("* zBlock: Advertise attempt by %s, proof: %s", GetName(playerid), cmdtext);
  340.                 return 0;
  341.             }
  342.             else if(WarnForAdvert[playerid] >= 2)
  343.             {
  344.                 new Query[240], reason[20] = "Advertisement", day, month, year, second, minute, hour;
  345.                 getdate(day, month, year);
  346.                 gettime(hour, minute, second);
  347.  
  348.                 format(datestring, sizeof(datestring), "%i-%i-%i", day, month, year);
  349.                 format(timestring, sizeof(timestring), "%i:%i:%i", hour, minute, second);
  350.  
  351.                 format(Query, sizeof(Query), "INSERT INTO `BANNED` (`NAME`, `IP`, `REASON`, `ADMIN`, `DATE`, `TIME`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s')", DB_Escape(GetName(playerid)), DB_Escape(PlayerIP(playerid)), reason, BOT_NAME, datestring, timestring);
  352.                 db_query(zBlock, Query);
  353.                 SetTimerEx("KickTimer", 100, false, "i", playerid);
  354.  
  355.                 printf("* zBlock: Ban applied on '%s'\n* zBlock: Reason: Advertisement\n* zBlock: Proof: %s", GetName(playerid), cmdtext);
  356.  
  357.                 format(stringz, sizeof(stringz), "zBlock: %s(%d) has been banned for advertising", GetName(playerid), playerid);
  358.                 SendClientMessageToAll(COLOR_NOTES2, stringz);
  359.                 return 0;
  360.             }
  361.         }
  362.     }
  363.     return 1;
  364. }
  365. CMD:zblock_login(playerid, params[])
  366. {
  367.     new FirstParam[50], string[82];
  368.     if(fexist("/zblock/password.txt"))
  369.     {
  370.         if(!DefaultPass)
  371.         {
  372.             if(sscanf(params, "s[50]", FirstParam)) return SendClientMessage(playerid, COLOR_NOTES, "/zblock_login (password)");
  373.             if(isnull(params)) return SendClientMessage(playerid, COLOR_NOTES2, "* You didn't type anything in the Password 'slot'!");
  374.            
  375.             new
  376.                 File: zBlockstuff = fopen("/zblock/password.txt", io_read)
  377.             ;
  378.             if(zBlockstuff)
  379.             {
  380.                 if(!LoggedIn{ playerid })
  381.                 {
  382.                     fread(zBlockstuff, string);
  383.                     fclose(zBlockstuff);
  384.                     if(!strcmp(FirstParam, string, true))
  385.                     {
  386.                         LoggedIn{ playerid } = true;
  387.                         AdminImmunity{ playerid } = true;
  388.                        
  389.                         format(string, sizeof(string), "zBlock: %s(%d) has logged in the zBlock 'CP', and has received his 'Immunity'", GetName(playerid), playerid);
  390.                         SendMessageToAdmins(COLOR_NOTES, string);
  391.                     }
  392.                     else SendClientMessage(playerid, COLOR_NOTES2, "zBlock: Invalid Password!");
  393.                 }
  394.                 else SendClientMessage(playerid, COLOR_NOTES, "zBlock: You're already logged in!");
  395.             }
  396.             else SendClientMessage(playerid, COLOR_NOTES2, "zBlock: Can't find 'password.txt' file..");
  397.         }
  398.         else SendClientMessage(playerid, COLOR_NOTES2, "zBlock: Server is using Default Password, logging in is forbidden!");
  399.     }
  400.     FirstParam = "\0", string = "\0";
  401.     return 1;
  402. }
  403. CMD:zblock(playerid, params[])
  404. {
  405.     new FirstParam[18], SecondParam[50], messagestring[112], extradialog[240], string[82], hackerstring[148], count = 0;
  406.     if(fexist("/zblock/password.txt"))
  407.     {
  408.         new
  409.             File: zBlockstuff = fopen("/zblock/password.txt", io_read)
  410.         ;
  411.         if(zBlockstuff)
  412.         {
  413.             fread(zBlockstuff, string);
  414.             fclose(zBlockstuff);
  415.         }
  416.         if(LoggedIn{ playerid })
  417.         {
  418.             if(sscanf(params, "s[18]", FirstParam)) return SendClientMessage(playerid, COLOR_NOTES, "/zblock (hackers/changepassword/lock/settings)");
  419.             {
  420.                 if(strcmp(FirstParam, "suspects", true, 8) == 0 || strcmp(FirstParam, "hackers", true, 7) == 0 )
  421.                 {
  422.                     if(AdminImmunity{ playerid })
  423.                     {
  424.                         foreach(Player, i)
  425.                         {
  426.                             if(ACTimesDetected[i] >= 1) count++;
  427.                         }
  428.                         if(count >= 1)
  429.                         {
  430.                             foreach(Player, i)
  431.                             {
  432.                                 if(ACTimesDetected[i] >= 1)
  433.                                 {
  434.                                     format(hackerstring, sizeof(hackerstring), "{FFCC66}%s\n%s(%d) - IP: %s - Has been detected %d times", hackerstring, GetName(i), i, PlayerIP(i), ACTimesDetected[i]);
  435.                                 }
  436.                             }
  437.                             ShowPlayerDialog(playerid, DIALOG_SUSPECTS, DIALOG_STYLE_MSGBOX, "{FF9933}zBlock CP {FF6633}(v1.5)", hackerstring, "Close", "");
  438.                         }
  439.                         else ShowPlayerDialog(playerid, DIALOG_SUSPECTS, DIALOG_STYLE_MSGBOX, "{FF9933}zBlock CP {FF6633}(v1.5)", "{FFCC66}No hackers detected", "Close", "");
  440.                     }
  441.                 }
  442.                 else if(strcmp(FirstParam, "changepassword", true, 14) == 0)
  443.                 {
  444.                     if(IsPlayerAdmin(playerid) && AdminImmunity{ playerid })
  445.                     {
  446.                         if(zBlockstuff)
  447.                         {
  448.                             if(sscanf(params, "s[50]", SecondParam))
  449.                             {
  450.                                 SendClientMessage(playerid, COLOR_NOTES, "/zblock (changepassword) (newpass)");
  451.                             }
  452.                             else
  453.                             {
  454.                                 if(!isnull(SecondParam))
  455.                                 {
  456.                                     SecondParam = "\0";
  457.  
  458.                                     zBlockstuff = fopen("/zblock/password.txt", io_write);
  459.                                     fwrite(zBlockstuff, SecondParam);
  460.                                     fclose(zBlockstuff);
  461.  
  462.                                     format(messagestring, sizeof(messagestring), "zBlock: %s(%d) has changed the password to %s", GetName(playerid), playerid, SecondParam);
  463.                                     SendMessageToAdmins(COLOR_NOTES2, messagestring);
  464.  
  465.                                     printf("* zBlock: PASS CHANGE! %s has changed the password to %s!", GetName(playerid), SecondParam);
  466.                                 }
  467.                             }
  468.                         }
  469.                     }
  470.                     else SendClientMessage(playerid, COLOR_NOTES2, "zBlock: You aren't an RCON admin, or an zBlock 'CP admin'!");
  471.                 }
  472.                 else if(strcmp(FirstParam, "lock", true, 4) == 0)
  473.                 {
  474.                     if(IsPlayerAdmin(playerid) && AdminImmunity{ playerid })
  475.                     {
  476.                         if(zBlockstuff)
  477.                         {
  478.                             if(ServerLocked == 0)
  479.                             {
  480.                                 ShowPlayerDialog(playerid, DIALOG_LOCKMODE, DIALOG_STYLE_LIST, "{FF9933}zBlock CP {FF6633}(v1.5)", "{FF9933}Lock Mode #1 {FF6633}- Disable connections\n{FF9933}Lock Mode #2 {FF6633}- Disable spawning", "Select", "Close");
  481.                             }
  482.                             else if(ServerLocked == 1)
  483.                             {
  484.                                 ShowPlayerDialog(playerid, DIALOG_LOCKMODE, DIALOG_STYLE_LIST, "{FF9933}zBlock CP {FF6633}(v1.5)", "{FF9933}Lock Mode #0 {FF6633}- Disable lock-mode\n{FF9933}Lock Mode #2 {FF6633}- Disable spawning", "Select", "Close");
  485.                             }
  486.                             else if(ServerLocked == 2)
  487.                             {
  488.                                 ShowPlayerDialog(playerid, DIALOG_LOCKMODE, DIALOG_STYLE_LIST, "{FF9933}zBlock CP {FF6633}(v1.5)", "{FF9933}Lock Mode #0 {FF6633}- Disable lock-mode\n{FF9933}Lock Mode #1 {FF6633}- Disable connections", "Select", "Close");
  489.                             }
  490.                         }
  491.                     }
  492.                     else SendClientMessage(playerid, COLOR_NOTES2, "zBlock: You aren't an RCON admin, or an zBlock 'CP admin'!");
  493.                 }
  494.                 else if(strcmp(FirstParam, "settings", true, 8) == 0)
  495.                 {
  496.                     if(AdminImmunity{ playerid })
  497.                     {
  498.                         if(zBlockstuff)
  499.                         {
  500.                             if(!BanForMoneyHack)
  501.                             {
  502.                                 format(extradialog, sizeof(extradialog), "{FF9933}Enable {FF6633}'Ban for Money-Hack'");
  503.                             }
  504.                             else
  505.                             {
  506.                                 format(extradialog, sizeof(extradialog), "{FF9933}Disable {FF6633}'Ban for Money-Hack'");
  507.                             }
  508.                             if(!BanForSpeedHack)
  509.                             {
  510.                                 format(extradialog, sizeof(extradialog), "%s\n{FF9933}Enable {FF6633}'Ban for Speed-Hack'", extradialog);
  511.                             }
  512.                             else
  513.                             {
  514.                                 format(extradialog, sizeof(extradialog), "%s\n{FF9933}Disable {FF6633}'Ban for Speed-Hack'", extradialog);
  515.                             }
  516.                             ShowPlayerDialog(playerid, DIALOG_SETTINGS, DIALOG_STYLE_LIST, "{FF9933}zBlock CP {FF6633}(v1.5)", extradialog, "Select", "Close");
  517.                         }
  518.                     }
  519.                 }
  520.             }
  521.         }
  522.         else SendClientMessage(playerid, COLOR_NOTES2, "zBlock: You have to be logged in via the zBlock 'CP'!");
  523.     }
  524.     else SendClientMessage(playerid, COLOR_NOTES2, "zBlock: File 'password.txt' does NOT exist, zBlock CP is DISABLED.");
  525.    
  526.     FirstParam = "\0", SecondParam = "\0", messagestring = "\0", hackerstring = "\0", string = "\0", extradialog = "\0";
  527.     return 1;
  528. }
  529. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  530. {
  531.     new string[92];
  532.     switch(dialogid)
  533.     {
  534.         case DIALOG_LOCKMODE:
  535.         {
  536.             if(response)
  537.             {
  538.                 if(ServerLocked == 0)
  539.                 {
  540.                     switch(listitem)
  541.                     {
  542.                         case 0:
  543.                         {
  544.                             ServerLocked = 1;
  545.                             format(string, sizeof(string), "zBlock: %s(%d) has enabled Lock-Mode #1 ( Connections will be 'rejected' )", GetName(playerid), playerid);
  546.                             SendClientMessageToAll(COLOR_NOTES2, string);
  547.                             foreach(Player, i)
  548.                             {
  549.                                 PlayerPlaySound(i, 1085, 0.0, 0.0, 0.0);
  550.                             }
  551.                         }
  552.                         case 1:
  553.                         {
  554.                             ServerLocked = 2;
  555.                             format(string, sizeof(string), "zBlock: %s(%d) has enabled Lock-Mode #2 ( Spawning is disabled )", GetName(playerid), playerid);
  556.                             SendClientMessageToAll(COLOR_NOTES2, string);
  557.                             foreach(Player, i)
  558.                             {
  559.                                 PlayerPlaySound(i, 1085, 0.0, 0.0, 0.0);
  560.                             }
  561.                         }
  562.                     }
  563.                 }
  564.                 else if(ServerLocked == 1)
  565.                 {
  566.                     switch(listitem)
  567.                     {
  568.                         case 0:
  569.                         {
  570.                             ServerLocked = 0;
  571.                             format(string, sizeof(string), "zBlock: %s(%d) has disabled Lock-Mode ( Spawning/Connecting is allowed )", GetName(playerid), playerid);
  572.                             SendClientMessageToAll(COLOR_NOTES, string);
  573.                             foreach(Player, i)
  574.                             {
  575.                                 PlayerPlaySound(i, 1083, 0.0, 0.0, 0.0);
  576.                             }
  577.                         }
  578.                         case 1:
  579.                         {
  580.                             ServerLocked = 2;
  581.                             format(string, sizeof(string), "zBlock: %s(%d) has enabled Lock-Mode #2 ( Spawning is disabled )", GetName(playerid), playerid);
  582.                             SendClientMessageToAll(COLOR_NOTES2, string);
  583.                             foreach(Player, i)
  584.                             {
  585.                                 PlayerPlaySound(i, 1085, 0.0, 0.0, 0.0);
  586.                             }
  587.                         }
  588.                     }
  589.                 }
  590.                 else if(ServerLocked == 2)
  591.                 {
  592.                     switch(listitem)
  593.                     {
  594.                         case 0:
  595.                         {
  596.                             ServerLocked = 0;
  597.                             format(string, sizeof(string), "zBlock: %s(%d) has disabled Lock-Mode ( Spawning/Connecting is allowed )", GetName(playerid), playerid);
  598.                             SendClientMessageToAll(COLOR_NOTES, string);
  599.                             foreach(Player, i)
  600.                             {
  601.                                 PlayerPlaySound(i, 1083, 0.0, 0.0, 0.0);
  602.                             }
  603.                         }
  604.                         case 1:
  605.                         {
  606.                             ServerLocked = 1;
  607.                             format(string, sizeof(string), "zBlock: %s(%d) has enabled Lock-Mode #1 ( Connections will be 'rejected' )", GetName(playerid), playerid);
  608.                             SendClientMessageToAll(COLOR_NOTES2, string);
  609.                             foreach(Player, i)
  610.                             {
  611.                                 PlayerPlaySound(i, 1085, 0.0, 0.0, 0.0);
  612.                             }
  613.                         }
  614.                     }
  615.                 }
  616.             }
  617.         }
  618.         case DIALOG_SETTINGS:
  619.         {
  620.             if(response)
  621.             {
  622.                 switch(listitem)
  623.                 {
  624.                     case 0:
  625.                     {
  626.                         if(!BanForMoneyHack)
  627.                         {
  628.                             BanForMoneyHack = 1;
  629.                             format(string, sizeof(string), "zBlock: %s(%d) has enabled the 'Ban for Money-Hack' feature.", GetName(playerid), playerid);
  630.                             SendClientMessageToAll(COLOR_NOTES, string);
  631.                             foreach(Player, i)
  632.                             {
  633.                                 PlayerPlaySound(i, 1085, 0.0, 0.0, 0.0);
  634.                             }
  635.                         }
  636.                         else
  637.                         {
  638.                             BanForMoneyHack = 0;
  639.                             format(string, sizeof(string), "zBlock: %s(%d) has disabled the 'Ban for Money-Hack' feature.", GetName(playerid), playerid);
  640.                             SendClientMessageToAll(COLOR_NOTES2, string);
  641.                             SendMessageToAdmins(COLOR_NOTES2, "zBlock: The hacked money will be removed!");
  642.                             foreach(Player, i)
  643.                             {
  644.                                 PlayerPlaySound(i, 1085, 0.0, 0.0, 0.0);
  645.                             }
  646.                         }
  647.                     }
  648.                     case 1:
  649.                     {
  650.                         if(!BanForSpeedHack)
  651.                         {
  652.                             BanForSpeedHack = 1;
  653.                             format(string, sizeof(string), "zBlock: %s(%d) has enabled the 'Ban for Speed-Hack' feature.", GetName(playerid), playerid);
  654.                             SendClientMessageToAll(COLOR_NOTES, string);
  655.                             foreach(Player, i)
  656.                             {
  657.                                 PlayerPlaySound(i, 1085, 0.0, 0.0, 0.0);
  658.                             }
  659.                         }
  660.                         else
  661.                         {
  662.                             BanForSpeedHack = 0;
  663.                             format(string, sizeof(string), "zBlock: %s(%d) has disabled the 'Ban for Speed-Hack' feature.", GetName(playerid), playerid);
  664.                             SendClientMessageToAll(COLOR_NOTES2, string);
  665.                             foreach(Player, i)
  666.                             {
  667.                                 PlayerPlaySound(i, 1085, 0.0, 0.0, 0.0);
  668.                             }
  669.                         }
  670.                     }
  671.                 }
  672.             }
  673.         }
  674.     }
  675.     return 1;
  676. }
  677.  
  678. public OnPlayerStateChange(playerid, newstate, oldstate)
  679. {
  680.     return 1;
  681. }
  682.  
  683. public OnVehicleMod(playerid, vehicleid, componentid)
  684. {
  685.     return 1;
  686. }
  687.  
  688. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  689. {
  690.     return 1;
  691. }
  692.  
  693. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  694. {
  695.     return 1;
  696. }
  697.  
  698. public OnRconLoginAttempt(ip[], password[], success)
  699. {
  700.     new stringz[92];
  701.     if(!success)
  702.     {
  703.         foreach(Player, i)
  704.         {
  705.             GetPlayerIp(i, ip, 16);
  706.  
  707.             if(strcmp(PlayerIP(i),ip) == 0)
  708.             {
  709.                 RCONLoginFails[i]++;
  710.                 if(RCONLoginFails[i] <= 2)
  711.                 {
  712.                     SendClientMessage(i, COLOR_NOTES2, "zBlock: Please don't try to get the RCON pass..");
  713.                     return 0;
  714.                 }
  715.                 else
  716.                 {
  717.                     RCONLoginFails[i] = 0;
  718.  
  719.                     new Query[240], DBResult:result, day, month, year, second, minute, hour;
  720.                     new reason[20] = "RCON Login Attempt";
  721.  
  722.                     getdate(day, month, year);
  723.                     gettime(hour, minute, second);
  724.                     format(datestring, sizeof(datestring), "%i-%i-%i", day, month, year);
  725.                     format(timestring, sizeof(timestring), "%i:%i:%i", hour, minute, second);
  726.  
  727.                     format(Query, sizeof(Query), "INSERT INTO `BANNED` (`NAME`, `IP`, `REASON`, `ADMIN`, `DATE`, `TIME`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s')", DB_Escape(GetName(i)), DB_Escape(PlayerIP(i)), reason, BOT_NAME, datestring, timestring);
  728.                     result = db_query(zBlock, Query);
  729.                     if(result) printf(">> SQLITE: successfully added %s's ban info", GetName(i));
  730.                     else printf(">> SQLITE: could not add %s's ban info", GetName(i));
  731.  
  732.  
  733.                     SetTimerEx("KickTimer", 100, false, "i", i);
  734.  
  735.                     format(stringz, sizeof(stringz), "* {F81414}zBlock has banned {FFFFFF}%s(%d) {F81414}for {FFFFFF}RCON Login attempts!", GetName(i), i);
  736.                     SendClientMessageToAll(-1, stringz);
  737.                 }
  738.             }
  739.         }
  740.     }
  741.     else
  742.     {
  743.         foreach(Player, i)
  744.         {
  745.             GetPlayerIp(i, ip, 16);
  746.             if(strcmp(PlayerIP(i),ip) == 0)
  747.             {
  748.                 if(!AdminImmunity{ i })
  749.                 {
  750.                     SendClientMessage(i, COLOR_NOTES, "zBlock: RCON login successfull, use '/zblock_login (password)' to get your 'Immunity'");
  751.                 }
  752.             }
  753.         }
  754.     }
  755.     return 1;
  756. }
  757.  
  758. public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
  759. {
  760.     new Float:X, Float:Y, Float:Z;
  761.     GetPlayerPos(playerid, X, Y, Z);
  762.     foreach(Player, i)
  763.     {
  764.         if(AdminImmunity{ i } && PLAYER_STATE_SPECTATING && i != playerid) //Replace these with your admin stuff..
  765.         {
  766.             if(IsPlayerInRangeOfPoint(i, 40, X, Y, Z))
  767.             {
  768.                 HitMarker[i] = CreatePlayerObject(i, 19282, fX, fY, fZ, 0, 0, 0); //18724 is a "fire" thing
  769.                 SetTimerEx("RemoveHitMarker", 4500, false, "ii", i, HitMarker);
  770.             }
  771.         }
  772.     }
  773.     /*foreach(Player, i)
  774.     {
  775.         if(IsPlayerInRangeOfPoint(i, 40, X, Y, Z))
  776.         {
  777.             HitMarker[i] = CreatePlayerObject(i, 19282, fX, fY, fZ, 0, 0, 0);
  778.             SetTimerEx("RemoveHitMarker", 4500, false, "ii", i, HitMarker);
  779.         }
  780.     }*/
  781.     return 1;
  782. }
  783.  
  784. /***** STOCKs, zBlock TIMERs etc. *****/
  785.  
  786. forward RemoveHitMarker(playerid, objectid);
  787. public RemoveHitMarker(playerid, objectid)
  788. {
  789.     DestroyPlayerObject(playerid, objectid);
  790.     return 1;
  791. }
  792. stock SendMessageToAdmins(color, text[])
  793. {
  794.     foreach(Player, i)
  795.     {
  796.         if(AdminImmunity{ i })
  797.         {
  798.             SendClientMessage(i, color, text);
  799.         }
  800.     }
  801. }
  802.  
  803. stock GetName(playerid)
  804. {
  805.     new pnameid[24];
  806.     GetPlayerName(playerid,pnameid,sizeof(pnameid));
  807.     return pnameid;
  808. }
  809. stock PlayerIP(playerid)
  810. {
  811.     new str[16];
  812.     GetPlayerIp(playerid, str, sizeof(str));
  813.     return str;
  814. }
  815.  
  816. stock ResetInfo(playerid)
  817. {
  818.     Muted{ playerid } = false;
  819.     ACDetected{ playerid } = false;
  820.     AdminImmunity{ playerid } = false;
  821.     LoggedIn{ playerid } = false;
  822.    
  823.     AntiSpam[playerid] = 0;
  824.     MutedTimes[playerid] = 0;
  825.     ACTimesDetected[playerid] = 0;
  826.     WarnForAdvert[playerid] = 0;
  827.     RCONLoginFails[playerid] = 0;
  828. }
  829. stock DB_Escape(text[])
  830. {
  831.     new
  832.         ret[80 * 2],
  833.         ch,
  834.         i,
  835.         j;
  836.     while ((ch = text[i++]) && j < sizeof (ret))
  837.     {
  838.         if (ch == '\'')
  839.         {
  840.             if (j < sizeof (ret) - 2)
  841.             {
  842.                 ret[j++] = '\'';
  843.                 ret[j++] = '\'';
  844.             }
  845.         }
  846.         else if (j < sizeof (ret))
  847.         {
  848.             ret[j++] = ch;
  849.         }
  850.         else
  851.         {
  852.             j++;
  853.         }
  854.     }
  855.     ret[sizeof (ret) - 1] = '\0';
  856.     return ret;
  857. }
  858. stock GetPlayerSpeed(playerid)
  859. {
  860.     new Float:ST[4];
  861.     if(IsPlayerInAnyVehicle(playerid))
  862.     GetVehicleVelocity(GetPlayerVehicleID(playerid),ST[0],ST[1],ST[2]);
  863.     else GetPlayerVelocity(playerid,ST[0],ST[1],ST[2]);
  864.     ST[3] = floatsqroot(floatpower(floatabs(ST[0]), 2.0) + floatpower(floatabs(ST[1]), 2.0) + floatpower(floatabs(ST[2]), 2.0)) * 179.28625;
  865.     return floatround(ST[3]);
  866. }
  867. stock GivePlayerCash(playerid, money)
  868. {
  869.     Cash[playerid] += money;
  870.     ResetMoneyBar(playerid);
  871.     UpdateMoneyBar(playerid,Cash[playerid]);
  872.     return Cash[playerid];
  873. }
  874. stock SetPlayerCash(playerid, money)
  875. {
  876.     Cash[playerid] = money;
  877.     ResetMoneyBar(playerid);
  878.     UpdateMoneyBar(playerid,Cash[playerid]);
  879.     return Cash[playerid];
  880. }
  881. stock ResetPlayerCash(playerid)
  882. {
  883.     Cash[playerid] = 0;
  884.     ResetMoneyBar(playerid);
  885.     UpdateMoneyBar(playerid,Cash[playerid]);
  886.     return Cash[playerid];
  887. }
  888. stock GetPlayerCash(playerid)
  889. {
  890.     return Cash[playerid];
  891. }
  892. forward KickTimer(playerid);
  893. public KickTimer(playerid)
  894. {
  895.     Kick(playerid);
  896.     return 1;
  897. }
  898. forward Unmute(playerid);
  899. public Unmute(playerid)
  900. {
  901.     Muted{ playerid } = false;
  902.     return 1;
  903. }
  904. forward ResetAntiSpam(playerid);
  905. public ResetAntiSpam(playerid)
  906. {
  907.     AntiSpam[playerid] = 0;
  908.     return 1;
  909. }
  910. CMD:hacktest(playerid, params[]) {
  911.     new Float:vx, Float:vy, Float:vz;
  912.     if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "You're not in any vehicle!");
  913.     if( sscanf( params, "fff", vx, vy, vz)) return SendClientMessage(playerid, -1, "Usage: /vl X Y Z");
  914.     {
  915.         SetVehicleVelocity(GetPlayerVehicleID(playerid), vx, vy, vz);
  916.     }
  917.     return 1;
  918. }
  919. forward AntiCheat();
  920. public AntiCheat()
  921. {
  922.     new Float:health, Float:armour, reason[24], stringz[120];
  923.     new Float:x,Float:y,Float:z;
  924.     new anim;
  925.     new Difference, Result;
  926.  
  927.     new Query[240], DBResult:result, day, month, year, second, minute, hour;
  928.     getdate(day, month, year);
  929.     gettime(hour, minute, second);
  930.    
  931.     format(datestring, sizeof(datestring), "%i-%i-%i", day, month, year);
  932.     format(timestring, sizeof(timestring), "%i:%i:%i", hour, minute, second);
  933.  
  934.     foreach(Player, i)
  935.     {
  936.         GetPlayerHealth(i, health);
  937.         GetPlayerArmour(i, armour);
  938.         anim = GetPlayerAnimationIndex(i);
  939.         GetPlayerVelocity(i,x,y,z);
  940.        
  941.         if(!AdminImmunity{ i })
  942.         {
  943.             if(GetPlayerWeapon(i) == 38)
  944.             {
  945.                 reason = "Minigun";
  946.                 format(stringz, sizeof(stringz), "* {F81414}zBlock has banned {FFFFFF}%s(%d) {F81414}for using {FFFFFF}Weapon Hacks!", GetName(i), i);
  947.                 SendClientMessageToAll(-1, stringz);
  948.                 SetTimerEx("KickTimer", 100, false, "i", i);
  949.  
  950.                 format(Query, sizeof(Query), "INSERT INTO `BANNED` (`NAME`, `IP`, `REASON`, `ADMIN`, `DATE`, `TIME`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s')", DB_Escape(GetName(i)), DB_Escape(PlayerIP(i)), reason, BOT_NAME, datestring, timestring);
  951.                 result = db_query(zBlock, Query);
  952.  
  953.                 if(result) printf(">> SQLITE: successfully added %s's ban info", GetName(i));
  954.                 else printf(">> SQLITE: could not add %s's ban info", GetName(i));
  955.  
  956.                 printf("« ANTI-CHEAT has banned %s for using Weapon-Hacks!", GetName(i));
  957.             }
  958.             if(x <= -0.800000  || y <= -0.800000 || z <= -0.800000 && anim == 1008)
  959.             {
  960.                 if(GetPlayerWeapon(i) != 46)
  961.                 {
  962.                     ACTimesDetected[i]++;
  963.                     reason = "Fly hack";
  964.                     if(ACTimesDetected[i] < 3)
  965.                     {
  966.                         format(stringz, sizeof(stringz), "* {F81414}zBlock has detected {FFFFFF}%s(%d){F81414} using {FFFFFF}Fly hacks!", GetName(i), i);
  967.                         SendMessageToAdmins(-1, stringz);
  968.                        
  969.                         format(DetectedFor[i], sizeof(DetectedFor), "~r~zBlock - latest detection~n~~w~%s", reason);
  970.                         TextDrawSetString(zBlockWarns[i], DetectedFor[i]);
  971.                         TextDrawShowForPlayer(i, zBlockWarns[i]);
  972.                     }
  973.                     else if(ACTimesDetected[i] >= 3)
  974.                     {
  975.                         format(stringz, sizeof(stringz), "* {F81414}zBlock has banned {FFFFFF}%s(%d) {F81414}for using {FFFFFF}Fly Hacks!", GetName(i), i);
  976.                         SendClientMessageToAll(-1, stringz);
  977.                         SetTimerEx("KickTimer", 100, false, "i", i);
  978.  
  979.                         format(Query, sizeof(Query), "INSERT INTO `BANNED` (`NAME`, `IP`, `REASON`, `ADMIN`, `DATE`, `TIME`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s')", DB_Escape(GetName(i)), DB_Escape(PlayerIP(i)), reason, BOT_NAME, datestring, timestring);
  980.                         result = db_query(zBlock, Query);
  981.  
  982.                         if(result) printf(">> SQLITE: successfully added %s's ban info", GetName(i));
  983.                         else printf(">> SQLITE: could not add %s's ban info", GetName(i));
  984.  
  985.                         printf("zBlock: %s has been banned for using Fly-Hacks!", GetName(i));
  986.                     }
  987.                 }
  988.             }
  989.             if(armour >= 100)
  990.             {
  991.                 if(ACTimesDetected[i] == 0)
  992.                 {
  993.                     ACTimesDetected[i]++;
  994.  
  995.                     format(stringz, sizeof(stringz), "* {F81414}zBlock has detected {FFFFFF}%s(%d) {F81414}POSSIBLY using {FFFFFF}Armour hacks!", GetName(i), i);
  996.                     SendMessageToAdmins(-1, stringz);
  997.                 }
  998.             }
  999.             if(GetPlayerSpeed(i) > 271)
  1000.             {
  1001.                 ACTimesDetected[i]++;
  1002.                 reason = "Speed Hack";
  1003.                 if(ACTimesDetected[i] <= 4)
  1004.                 {
  1005.                     format(stringz, sizeof(stringz), "zBlock: %s(%d) is possibly Speed-Hacking, KM/H: %d - %d warnings", GetName(i), i, GetPlayerSpeed(i), ACTimesDetected[i]);
  1006.                     SendMessageToAdmins(COLOR_NOTES2, stringz);
  1007.                     printf("zBlock: %s has been detected using Speed-Hacks | %d KM/H, %d/5 warnings |", GetName(i), GetPlayerSpeed(i), ACTimesDetected[i]);
  1008.                    
  1009.                     format(DetectedFor[i], sizeof(DetectedFor), "~r~zBlock - latest detection~n~~w~%s", reason);
  1010.                     TextDrawSetString(zBlockWarns[i], DetectedFor[i]);
  1011.                     TextDrawShowForPlayer(i, zBlockWarns[i]);
  1012.                 }
  1013.                 else
  1014.                 {
  1015.                     if(BanForSpeedHack)
  1016.                     {
  1017.                         format(stringz, sizeof(stringz), "zBlock: %s(%d) has been BANNED for using Speed-Hacks %d warnings", GetName(i), i, ACTimesDetected[i]);
  1018.                         SendMessageToAdmins(COLOR_NOTES2, stringz);
  1019.  
  1020.                         SetTimerEx("KickTimer", 100, false, "i", i);
  1021.  
  1022.                         format(stringz, sizeof(stringz), "* {F81414}zBlock has banned {FFFFFF}%s(%d) {F81414}for using Speed hacks!", GetName(i), i);
  1023.                         SendClientMessageToAll(-1, stringz);
  1024.                         printf("zBlock: %s has been banned for using Speed-Hacks!", GetName(i));
  1025.  
  1026.                         format(Query, sizeof(Query), "INSERT INTO `BANNED` (`NAME`, `IP`, `REASON`, `ADMIN`, `DATE`, `TIME`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s')", DB_Escape(GetName(i)), DB_Escape(PlayerIP(i)), reason, BOT_NAME, datestring, timestring);
  1027.                         result = db_query(zBlock, Query);
  1028.                         if(result) printf(">> SQLITE: successfully added %s's ban info", GetName(i));
  1029.                         else printf(">> SQLITE: could not add %s's ban info", GetName(i));
  1030.                     }
  1031.                 }
  1032.                 printf("*** zBlock: %s | Possibly speed-hacking, %d/271", GetName(i), GetPlayerSpeed(i));
  1033.             }
  1034.             if(GetPlayerCash(i) > GetPlayerMoney(i))
  1035.             {
  1036.                 reason = "Money hack";
  1037.                 if(!BanForMoneyHack)
  1038.                 {
  1039.                     ACDetected{ i } = true;
  1040.                     ACTimesDetected[i]++;
  1041.                    
  1042.                     if(!ACDetected { i })
  1043.                     {
  1044.                         format(stringz, sizeof(stringz), "zBlock: %s(%d) is ( possibly ) Money-Hacking, money reset.", GetName(i), i);
  1045.                         SendMessageToAdmins(COLOR_NOTES2, stringz);
  1046.                         format(stringz, sizeof(stringz), "zBlock: Summary about %s's warning: SSM: %d$ PSM: %d$", GetPlayerCash(i), GetPlayerMoney(i));
  1047.                         SendMessageToAdmins(COLOR_NOTES2, stringz);
  1048.                     }
  1049.                    
  1050.                     Difference = GetPlayerCash(i) - GetPlayerMoney(i);
  1051.                     Result = GetPlayerCash(i) - Difference;
  1052.                     SetPlayerCash(i, Result);
  1053.                    
  1054.                     format(DetectedFor[i], sizeof(DetectedFor), "~r~zBlock - latest detection~n~~w~%s", reason);
  1055.                     TextDrawSetString(zBlockWarns[i], DetectedFor[i]);
  1056.                     TextDrawShowForPlayer(i, zBlockWarns[i]);
  1057.                 }
  1058.                 else
  1059.                 {
  1060.                     ACTimesDetected[i]++;
  1061.                     Difference = GetPlayerCash(i) - GetPlayerMoney(i);
  1062.                     Result = GetPlayerCash(i) - Difference;
  1063.                    
  1064.                     printf("* zBlock: Adding ban on '%s' due to Money-Hacks", GetName(i));
  1065.                     printf("* zBlock: Proof: (SERVER SIDE) %d$ - (PLAYER SIDE) %d$, %d$ difference.", GetPlayerCash(i), GetPlayerMoney(i), Difference);
  1066.  
  1067.                     SetTimerEx("KickTimer", 100, false, "i", i);
  1068.  
  1069.                     format(stringz, sizeof(stringz), "* {F81414}zBlock has banned {FFFFFF}%s(%d) {F81414}for using Money hacks!", GetName(i), i);
  1070.                     SendClientMessageToAll(-1, stringz);
  1071.  
  1072.                     format(Query, sizeof(Query), "INSERT INTO `BANNED` (`NAME`, `IP`, `REASON`, `ADMIN`, `DATE`, `TIME`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s')", DB_Escape(GetName(i)), DB_Escape(PlayerIP(i)), reason, BOT_NAME, datestring, timestring);
  1073.                     result = db_query(zBlock, Query);
  1074.                     if(result) printf(">> SQLITE: successfully added %s's ban info", GetName(i));
  1075.                     else printf(">> SQLITE: could not add %s's ban info", GetName(i));
  1076.                 }
  1077.             }
  1078.         }
  1079.     }
  1080.     return 1;
  1081. }
  1082. forward EndProcessing(playerid);
  1083. public EndProcessing(playerid)
  1084. {
  1085.     new Float:x, Float:y, Float:z, reason[18] = "s0beit client", stringz[112];
  1086.     GetPlayerCameraFrontVector(playerid, x, y, z);
  1087.     #pragma unused x
  1088.     #pragma unused y
  1089.     if(z < -0.8)
  1090.     {
  1091.         format(DetectedFor[playerid], sizeof(DetectedFor), "~r~zBlock - latest detection~n~~w~%s", reason);
  1092.         TextDrawSetString(zBlockWarns[playerid], DetectedFor[playerid]);
  1093.         TextDrawShowForPlayer(playerid, zBlockWarns[playerid]);
  1094.  
  1095.         SendClientMessage(playerid, COLOR_NOTES, "Processed successfully.");
  1096.  
  1097.         ACDetected{ playerid } = true;
  1098.         FirstSpawn{ playerid } = true;
  1099.  
  1100.         ACTimesDetected[playerid]++;
  1101.         if(ACTimesDetected[playerid] == 1)
  1102.         {
  1103.             printf("« ANTI-CHEAT has detected %s using Hacked Client - s0beit! »", GetName(playerid));
  1104.         }
  1105.         else if(ACTimesDetected[playerid] == 2)
  1106.         {
  1107.             SpawnPlayer(playerid);
  1108.             printf("« ANTI-CHEAT has detected %s using Hacked Client - s0beit! »", GetName(playerid));
  1109.         }
  1110.         else if(ACTimesDetected[playerid] >= 3)
  1111.         {
  1112.             SetTimerEx("KickTimer", 100, false, "i", playerid);
  1113.  
  1114.             SendClientMessage(playerid, -1, "{F81414}zBlock {FFFFFF}- {F81414}You've been banned for using {FFFFFF}s0beit {F81414}client!");
  1115.             format(stringz, sizeof(stringz), "* {F81414}zBlock has banned {FFFFFF}%s(%d){F81414} for using {FFFFFF}s0beit {F81414}client!", GetName(playerid), playerid);
  1116.             SendClientMessageToAll(-1, stringz);
  1117.  
  1118.             printf("« ANTI-CHEAT has banned %s for Hacked Client - s0beit! »", GetName(playerid));
  1119.             SetPlayerSpecialAction(playerid,SPECIAL_ACTION_HANDSUP);
  1120.  
  1121.             new Query[240], DBResult:result,  day, month, year, second, minute, hour;
  1122.             getdate(day, month, year);
  1123.             gettime(hour, minute, second);
  1124.  
  1125.             format(datestring, sizeof(datestring), "%i-%i-%i", day, month, year);
  1126.             format(timestring, sizeof(timestring), "%i:%i:%i", hour, minute, second);
  1127.  
  1128.             format(Query, sizeof(Query), "INSERT INTO `BANNED` (`NAME`, `IP`, `REASON`, `ADMIN`, `DATE`, `TIME`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s')", DB_Escape(GetName(playerid)), DB_Escape(PlayerIP(playerid)), reason, BOT_NAME, datestring, timestring);
  1129.             result = db_query(zBlock, Query);
  1130.             if(result) printf(">> SQLITE: successfully added %s's ban info", GetName(playerid));
  1131.             else printf(">> SQLITE: could not add %s's ban info", GetName(playerid));
  1132.         }
  1133.     }
  1134.     else
  1135.     {
  1136.         SendClientMessage(playerid, -1, "Processed successfully.");
  1137.         FirstSpawn{ playerid } = false;
  1138.         TogglePlayerControllable(playerid, 1);
  1139.     }
  1140.     return 1;
  1141. }
  1142. forward CheckForFile();
  1143. public CheckForFile()
  1144. {
  1145.     new slhour, slminute, slsecond, slyear, slmonth, slday;
  1146.     if(fexist("/zblock/password.txt"))
  1147.     {
  1148.         print("NOTIFICATION: 'password.txt' has been successfully created'");
  1149.         print("INFO: File location: /scriptfiles/zBlock/\nINFO: Automatically set the default password.");
  1150.         gettime(slhour, slminute, slsecond);
  1151.         getdate(slyear, slmonth, slday);
  1152.  
  1153.         new File:zBlockstuff = fopen("/zblock/password.txt", io_write);
  1154.         if(zBlockstuff)
  1155.         {
  1156.             fwrite(zBlockstuff, "defaultpassword5791");
  1157.             fclose(zBlockstuff);
  1158.         }
  1159.     }
  1160.     else print("WARNING: could NOT create 'password.txt' at 'scriptfiles/zblock'");
  1161.     return 1;
  1162. }
  1163. forward fcreate(filename[]);
  1164. public fcreate(filename[])
  1165. {
  1166.     if (fexist(filename)){return false;}
  1167.     new File:fhandle = fopen(filename,io_write);
  1168.     fclose(fhandle);
  1169.     return true;
  1170. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement