Advertisement
Guest User

Untitled

a guest
Sep 25th, 2018
558
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.06 KB | None | 0 0
  1. /* Speed Anticheat
  2.  
  3.                 by XStormiest
  4.                
  5.  
  6.     So how this script works, is very simple, it's based on some-kind of AI algorithm that detecks max Speed and checks for any anomally in the speed.
  7.  
  8.                
  9. */
  10. #define ANOMALLY 200
  11. #include <a_samp>
  12. new Float: MaxSpeed[MAX_PLAYERS][212][100];
  13. new K[MAX_PLAYERS][212];
  14. new Anomally = ANOMALLY;
  15. new CheckSpeedTimer;
  16.  
  17. stock GetPlayerSpeed(playerid, bool:kmh) // by misco
  18. {
  19.   new Float:Vx,Float:Vy,Float:Vz,Float:rtn;
  20.   if(IsPlayerInAnyVehicle(playerid)) GetVehicleVelocity(GetPlayerVehicleID(playerid),Vx,Vy,Vz); else GetPlayerVelocity(playerid,Vx,Vy,Vz);
  21.   rtn = floatsqroot(floatabs(floatpower(Vx + Vy + Vz,2)));
  22.   return kmh?floatround(rtn * 100 * 1.61):floatround(rtn * 100);
  23. }
  24.  
  25. forward CheckVehicles();
  26. public CheckVehicles()
  27. {
  28.     new vehicleid, modelid, Float: speed, bool: hack;
  29.     new name[MAX_PLAYER_NAME], string[256];
  30.     for(new i = 0; i < MAX_PLAYERS; i++)
  31.     {
  32.         if(IsPlayerInAnyVehicle(i))
  33.         {
  34.             hack = false;
  35.             vehicleid = GetPlayerVehicleID(i);
  36.             modelid = GetVehicleModel(vehicleid);
  37.             speed = GetPlayerSpeed(i, true);
  38.             if(speed > MaxSpeed[i][modelid-400][K[i][modelid-400]] && K[i][modelid-400] < 100)
  39.             {
  40.                 MaxSpeed[i][modelid-400][K[i][modelid-400]++];
  41.             }
  42.             for(new j = 1; i < K[i][modelid-400]; i++)
  43.             {
  44.                 if( (MaxSpeed[i][modelid][j] - MaxSpeed[i][modelid][j-1] ) >= Anomally )
  45.                 {
  46.                     hack = true;
  47.                 }
  48.             }
  49.            
  50.             if(hack == true)
  51.             {
  52.                 GetPlayerName(i, name, sizeof(name));
  53.                 format(string, sizeof(string), "Cheats: %s was detected using a car speed hack!!", name);
  54.                 SendClientMessageToAll(-1, string);
  55.                 BanEx(i, "Car Speed Hack");
  56.             }
  57.         }
  58.        
  59.     }
  60.     return 1;
  61. }
  62.  
  63. public OnFilterScriptInit()
  64. {
  65.     CheckSpeedTimer = SetTimer("CheckVehicles", 1000, true);
  66.     return 1;
  67. }
  68.  
  69. public OnFilterScriptExit()
  70. {
  71.     KillTimer(CheckSpeedTimer);
  72.     return 1;
  73. }
  74.  
  75. public OnPlayerConnect(playerid)
  76. {
  77.     for(new i = 0; i < 212; i++)
  78.     {
  79.         for(new j = 0; j < 100; j++)
  80.             MaxSpeed[playerid][i][j] = 0;
  81.         K[playerid][i] = 0;
  82.     }
  83.     return 1;
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement