Guest User

Speed Anticheat Vehicles Only v1.2

a guest
Sep 25th, 2018
494
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. #include <mapandreas>
  13. new Float: MaxSpeed[MAX_PLAYERS][212][100];
  14. new K[MAX_PLAYERS][212];
  15. new Anomally = ANOMALLY;
  16. new CheckSpeedTimer;
  17.  
  18. stock GetPlayerSpeed(playerid, bool:kmh) // by misco
  19. {
  20. new Float:Vx,Float:Vy,Float:Vz,Float:rtn;
  21. if(IsPlayerInAnyVehicle(playerid)) GetVehicleVelocity(GetPlayerVehicleID(playerid),Vx,Vy,Vz); else GetPlayerVelocity(playerid,Vx,Vy,Vz);
  22. rtn = floatsqroot(floatabs(floatpower(Vx + Vy + Vz,2)));
  23. return kmh?floatround(rtn * 100 * 1.61):floatround(rtn * 100);
  24. }
  25.  
  26. forward CheckVehicles();
  27. public CheckVehicles()
  28. {
  29. new vehicleid, modelid, Float: speed, Float: highestZ, bool: hack;
  30. new name[MAX_PLAYER_NAME], string[256];
  31. new Float:X, Float:Y, Float:Z;
  32. for(new i = 0; i < MAX_PLAYERS; i++)
  33. {
  34. if(IsPlayerInAnyVehicle(i))
  35. {
  36. hack = false;
  37. vehicleid = GetPlayerVehicleID(i);
  38. modelid = GetVehicleModel(vehicleid);
  39. speed = GetPlayerSpeed(i, true);
  40. GetVehiclePos(vehicleid, X, Y, Z);
  41. MapAndreas_FindZ_For2DCoord(X, Y, highestZ);
  42. #pragma unused X
  43. #pragma unused Y
  44. if(speed > MaxSpeed[i][modelid-400][K[i][modelid-400]] && K[i][modelid-400] < 100)
  45. {
  46. MaxSpeed[i][modelid-400][K[i][modelid-400]++];
  47. }
  48. for(new j = 1; i < K[i][modelid-400]; i++)
  49. {
  50. if( (MaxSpeed[i][modelid][j] - MaxSpeed[i][modelid][j-1] ) >= Anomally && Z <= highestZ)
  51. {
  52. hack = true;
  53. }
  54. }
  55.  
  56. if(hack == true)
  57. {
  58. GetPlayerName(i, name, sizeof(name));
  59. format(string, sizeof(string), "Cheats: %s was detected using a car speed hack!!", name);
  60. SendClientMessageToAll(-1, string);
  61. BanEx(i, "Car Speed Hack");
  62. }
  63. }
  64.  
  65. }
  66. return 1;
  67. }
  68.  
  69. public OnFilterScriptInit()
  70. {
  71. CheckSpeedTimer = SetTimer("CheckVehicles", 1000, true);
  72. MapAndreas_Init(MAP_ANDREAS_MODE_FULL); //
  73. return 1;
  74. }
  75.  
  76. public OnFilterScriptExit()
  77. {
  78. KillTimer(CheckSpeedTimer);
  79. return 1;
  80. }
  81.  
  82. public OnPlayerConnect(playerid)
  83. {
  84. for(new i = 0; i < 212; i++)
  85. {
  86. for(new j = 0; j < 100; j++)
  87. MaxSpeed[playerid][i][j] = 0;
  88. K[playerid][i] = 0;
  89. }
  90. return 1;
  91. }
RAW Paste Data