VanGans

FS Anti Cheat

Aug 28th, 2020
1,705
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*<=============================================INFORMATION======================================================>
  2. Powered By VanGans - FILTERSCRIPT Anti Cheat + Hack
  3. FEATURES
  4. Anti Weapon Cheats-Like Anti-Minigun, Anti-C4, Anti-RPG, Anti-Rocket, Anti-FlameThrower
  5. Anti-GodMode
  6. Anti-Money Hack
  7. Anti-High Ping (700) u can change it later
  8. Anti-Bot
  9. Anti-Speed Hack
  10.  
  11. BENIFITS
  12. 1) NO bot can join
  13. 2) NO one can have hacked money
  14. 3) NO one can use GOD mode or Health hacks
  15. 4) High ping gets Kick
  16. 5) Speed of car cant go above 450 if so leads to a kick
  17. 6) Weapons like Minigun, Anti-C4, Anti-RPG, Anti-Rocket, Anti-FlameThrower if used gets Kick ( If its a freeroam server or you want to remove it you can just do it )
  18. <===================================================================================================>
  19. */     
  20.  
  21.  
  22. //--------------------------------------------INCLUDES-----------------------------------------
  23. #include "a_samp"
  24. //--------------------------------------------INCLUDES-----------------------------------------
  25.  
  26. new var[MAX_PLAYERS] = {-1,...}, warns[MAX_PLAYERS] = {0,...}, bool:npc[MAX_PLAYERS] = {false,...}, MAX_PLAYERS_ = MAX_PLAYERS;
  27.  
  28.  
  29. new Float:_oldHealth, Float:_oldArmour;
  30.  
  31. new pMoney[MAX_PLAYERS];
  32.  
  33. new PlayerPressedJump[MAX_PLAYERS];
  34.  
  35. new Timer[MAX_PLAYERS];
  36. //------------------------------------------------DEFINES-----------------------------------------------
  37. #define MAX_PING 700
  38. #define MAX_CAR_SPEED 450
  39. //--------------------------------------------OnFilterScriptInit-----------------------------------------
  40. public OnFilterScriptInit()
  41. {
  42.     SendRconCommand("reloadbans");
  43.     print("------------------------------------------------------");
  44.     print("-------------Anti Bot Attack By VanGans Now Loaded------");
  45.     print("------------------------------------------------------");
  46.     return 1;
  47. }
  48.  
  49. forward CP(playerid);
  50.  
  51. forward PJ(playerid);
  52.  
  53. forward PJR(playerid);
  54.  
  55. forward CarSpeed(playerid);
  56.  
  57. //--------------------------------------------OnFilterScriptInit-----------------------------------------
  58. //--------------------------------------------OnPlayerConnect-----------------------------------------
  59. public OnPlayerConnect(playerid)
  60. {
  61.     pMoney[playerid] = 0;
  62.     if(CountIP(GetIP(playerid)) >= 2) return BA(playerid), 0;
  63.     MAX_PLAYERS_ = playerid > MAX_PLAYERS_ ? playerid : GetHighestID(),
  64.     npc[playerid] = bool:IsPlayerNPC(playerid),
  65.     var[playerid] = SetTimerEx("BSS",2500,false,"i",playerid),
  66.     warns[playerid] = 0;
  67.     return 1;
  68. }
  69. //--------------------------------------------OnPlayerConnect-----------------------------------------
  70. //--------------------------------------------OnPlayerDisconnect-----------------------------------------
  71. public OnPlayerDisconnect(playerid, reason)
  72. {
  73.     pMoney[playerid] = 0;
  74.     MAX_PLAYERS_ = GetHighestID(playerid);
  75.     if(npc[playerid]) npc[playerid] = false;
  76.     if(var[playerid] != -1)
  77.     {
  78.         KillTimer(var[playerid]);
  79.         var[playerid] = -1;
  80.     }
  81.     warns[playerid] = 0;
  82.     return 1;
  83. }
  84. //--------------------------------------------OnPlayerDisconnect-----------------------------------------
  85. //--------------------------------------------OnPlayerSpawn----------------------------------------------
  86. public OnPlayerSpawn(playerid)
  87. {
  88.     Timer[playerid] = SetTimerEx("CP",990,1,"i",playerid);
  89.     return 1;
  90. }
  91. //--------------------------------------------OnPlayerSpawn-----------------------------------------------
  92. //--------------------------------------------ONPLAYERUPDATE-----------------------------------------------
  93. public OnPlayerUpdate(playerid)
  94. {
  95.     new Float:health, Float:armour;
  96.     GetPlayerHealth(playerid,health);
  97.     GetPlayerArmour(playerid,armour);
  98.     _oldHealth = health;
  99.     _oldArmour = armour;
  100.     new PlayerWeapon[MAX_PLAYERS];
  101.     new gunname[32];
  102.     new string[120];
  103.     PlayerWeapon[playerid] = GetPlayerWeapon(playerid);
  104.     if(PlayerWeapon[playerid] == 38 || PlayerWeapon[playerid] == 39 || PlayerWeapon[playerid] == 36 || PlayerWeapon[playerid] == 35 || PlayerWeapon[playerid] == 37 || PlayerWeapon[playerid] == 40)
  105.     {
  106.         GetWeaponName(PlayerWeapon[playerid],gunname,sizeof(gunname));
  107.         format(string,sizeof(string),"{FF00FF}[Anti Cheat / Hack] {15FF00}Player: {FF0000}%s {15FF00}with ID: {FF0000} %d {15FF00}has been Kicked from {FF0000}The Server || {FFFF00}Reason: {15FF00}Weapon Hack",GetName(playerid),playerid,gunname);
  108.         SendClientMessageToAll(-1,string);
  109.         Kick(playerid);
  110.     }
  111.     if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_USEJETPACK)
  112.     {
  113.         new string2[120];
  114.         format(string,sizeof(string),"{FF00FF}[Anti Cheat / Hack] {15FF00}Player: {FF0000}%s {15FF00}with ID: {FF0000} %d {15FF00}has been Kicked from {FF0000}The Server || {FFFF00}Reason: {15FF00}Jetpack Hack",GetName(playerid),playerid);
  115.         SendClientMessageToAll(-1,string2);
  116.         Kick(playerid);
  117.     }
  118.     new pName[MAX_PLAYER_NAME];
  119.     if(GetPlayerMoney(playerid) > pMoney[playerid])
  120.     {
  121.         GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
  122.     }
  123.     return 1;
  124. }
  125. //--------------------------------------------ONPLAYERUPDATE-----------------------------------------------
  126. //--------------------------------------------ONPLAYERTAKENDAMAGE-----------------------------------------------
  127. public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
  128. {
  129.     if(playerid != INVALID_PLAYER_ID)
  130.     {
  131.         new Float:nHealth, Float:nArmour, localString[128],pName[24];
  132.         GetPlayerHealth(playerid,nHealth);
  133.         GetPlayerArmour(playerid,nArmour);
  134.         GetPlayerName(playerid,pName,24);
  135.         if(nHealth == _oldHealth && nArmour == _oldArmour)
  136.         {
  137.             format(localString,sizeof(localString),"{FF00FF}[Anti Cheat / Hack] {15FF00}Player: {FF0000}%s {15FF00}with ID: {FF0000} %d {15FF00}has been Kicked from {FF0000}The Server || {FFFF00}Reason: {15FF00}Health/God/Armour Hack");
  138.             SendClientMessageToAll(-1,localString);
  139.             Kick(playerid);
  140.         }
  141.     }
  142.     return 1;
  143. }
  144.  
  145. //--------------------------------------------OnPlayerSpawn-----------------------------------------------
  146. //--------------------------------------------CP-----------------------------------------------
  147. public CP(playerid)
  148. {
  149.     if(GetPlayerPing(playerid) > MAX_PING) Kick(playerid);
  150. }
  151. //--------------------------------------------PJ-----------------------------------------------
  152. public PJ(playerid)
  153. {
  154.     PlayerPressedJump[playerid] = 0;
  155.     ClearAnimations(playerid);
  156.     return 1;
  157. }
  158. //--------------------------------------------PJR-----------------------------------------------
  159. public PJR(playerid)
  160. {
  161.     PlayerPressedJump[playerid] = 0;
  162.     return 1;
  163. }
  164. //--------------------------------------------A_SETPLAYERMONEY-----------------------------------------------
  165.  
  166. stock a_SetPlayerMoney(playerid, money)
  167. {
  168.     pMoney[playerid] = money;
  169.     ResetPlayerMoney(playerid);
  170.     GivePlayerMoney(playerid, money);
  171. }
  172. //--------------------------------------------GETNAME-----------------------------------------------
  173. stock GetName(playerid)
  174. {
  175.     new pName22[68];
  176.     GetPlayerName(playerid, pName22, sizeof(pName22));
  177.     return pName22;
  178. }
  179. //--------------------------------------------GETPLAYERSPEED-----------------------------------------------
  180. stock GetPlayerSpeed(playerid)
  181. {
  182.     new Float:ST[4];
  183.     if(IsPlayerInAnyVehicle(playerid))
  184.     GetVehicleVelocity(GetPlayerVehicleID(playerid),ST[0],ST[1],ST[2]);
  185.     else GetPlayerVelocity(playerid,ST[0],ST[1],ST[2]);
  186.     ST[3] = floatsqroot(floatpower(floatabs(ST[0]), 2.0) + floatpower(floatabs(ST[1]), 2.0) + floatpower(floatabs(ST[2]), 2.0)) * 179.28625;
  187.     return floatround(ST[3]);
  188. }
  189.  
  190. //--------------------------------------------A_GIVEPLAYERMONEY-----------------------------------------------
  191. stock a_GivePlayerMoney(playerid, money)
  192. {
  193.     pMoney[playerid] += money;
  194.     GivePlayerMoney(playerid, money);
  195. }
  196. //--------------------------------------------COUNTIP-----------------------------------------------
  197. stock CountIP(ip[])
  198. {
  199.     new c = 0;
  200.     for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && !strcmp(GetIP(i),ip)) c++;
  201.     return c;
  202. }
  203. //--------------------------------------------BSS-----------------------------------------------
  204. forward BSS(playerid);
  205. public BSS(playerid)
  206. {
  207.     new i = GetPlayerPing(playerid);
  208.     if(i <= 0 || i >= 50000)
  209.     {
  210.         if(warns[playerid] >= 1) BA(playerid);
  211.         else warns[playerid]++, var[playerid] = SetTimerEx("BSS",1500,false,"i",playerid);
  212.     }
  213.     return 0;
  214. }
  215. stock GetIP(playerid)
  216. {
  217.     new ip[16];
  218.     GetPlayerIp(playerid,ip,sizeof(ip));
  219.     return ip;
  220. }
  221. stock BA(playerid)
  222. {
  223.     new ip[32];
  224.     GetPlayerIp(playerid,ip,sizeof(ip));
  225.     for(new i = 0, p = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && !npc[i])
  226.     {
  227.         p = GetPlayerPing(i);
  228.         if(i == playerid || !strcmp(ip,GetIP(i)) || p <= 0 || p >= 50000)
  229.         {
  230.             BanEx(i,"Bot");
  231.             if(var[i] != -1)
  232.             {
  233.                 KillTimer(var[i]);
  234.                 var[i] = -1;
  235.             }
  236.         }
  237.     }
  238.     format(ip,sizeof(ip),"banip %s",ip);
  239.     return SendRconCommand(ip);
  240. }
  241. stock GetHighestID(exceptof = INVALID_PLAYER_ID)
  242. {
  243.     new h = 0;
  244.     for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && i != exceptof && i > h) h = i;
  245.     return h;
  246. }
RAW Paste Data