Advertisement
Voke_Bass

Anti-Cheat Speed-Hack [UPDATED 2020-12-17]

Jun 24th, 2019 (edited)
550
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.87 KB | None | 0 0
  1. //Updated 2020-12-17 | Rewiews: 144
  2. //Created by Vok3
  3.  
  4. #define Velocity 0.5
  5. #define SpeedCap 1.0
  6.  
  7. public OnPlayerUpdate(playerid)
  8. {
  9.     GetPlayerVehicleVelocity(playerid);
  10.     return 1;
  11. }
  12.  
  13. stock GetPlayerVehicleVelocity(playerid)
  14. {
  15.     if(IsPlayerInAnyVehicle(playerid))
  16.     {
  17.         if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
  18.         {
  19.             new Float: Veloc[3];
  20.             GetVehicleVelocity(GetPlayerVehicleID(playerid), Veloc[0], Veloc[1], Veloc[2]);
  21.  
  22.             if(Veloc[0] > Velocity || Veloc[0] < -Velocity || Veloc[1] > Velocity || Veloc[1] < -Velocity || Veloc[2] > Velocity)
  23.             {
  24.                 static Float:s_fX, Float:s_fY, Float:s_fZ, Float:s_fVX, Float:s_fVY, Float:s_fVZ;
  25.  
  26.                 GetVehiclePos(GetPlayerVehicleID(playerid), s_fX, s_fY, s_fZ);
  27.                 GetVehicleVelocity(GetPlayerVehicleID(playerid), s_fVX, s_fVY, s_fVZ);
  28.  
  29.                 if(!IsPlayerInRangeOfPoint(playerid, SpeedCap + 0.05, s_fX + s_fVX, s_fY + s_fVY, s_fZ + s_fVZ))
  30.                 {
  31.                     static Float:s_fLength;
  32.                     s_fLength = floatsqroot((s_fVX * s_fVX ) + ( s_fVY * s_fVY ) + ( s_fVZ * s_fVZ ) );
  33.  
  34.                     s_fVX=(s_fVX / s_fLength) * SpeedCap;
  35.                     s_fVY=(s_fVY / s_fLength) * SpeedCap;
  36.                     s_fVZ=(s_fVZ / s_fLength) * SpeedCap;
  37.  
  38.                     SetVehicleVelocity(GetPlayerVehicleID(playerid), s_fVX, s_fVY, s_fVZ );
  39.                 }
  40.             }
  41.         }
  42.     }
  43.     else
  44.     {
  45.         new Float: Veloc[3];
  46.         GetPlayerVelocity(playerid, Veloc[0], Veloc[1], Veloc[2]);
  47.        
  48.         if(Veloc[0] > Velocity || Veloc[0] < -Velocity || Veloc[1] > Velocity || Veloc[1] < -Velocity || Veloc[2] > Velocity)
  49.         {
  50.             FixPlayerPosition(playerid);
  51.         }
  52.     }
  53.     return 1;
  54. }
  55.  
  56. stock FixPlayerPosition(playerid)
  57. {
  58.     new Float:Position[3];
  59.     GetPlayerPos(playerid, Position[0], Position[1], Position[2]);
  60.     SetPlayerPos(playerid, Position[0], Position[1], Position[2]);
  61.     return 1;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement