Advertisement
icra

[Include] acd.inc for SA-MP

Jul 23rd, 2014
436
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.07 KB | None | 0 0
  1. /*
  2.     +--------------------------+
  3.     |    _                 |
  4.     |   (_)                |
  5.     |    _  ___ _ __ __ _  |
  6.     |   | |/ __| '__/ _` | |
  7.     |   | | (__| | | (_| | |
  8.     |   |_|\___|_|  \__,_| |
  9.     |                          |
  10.     +--------------------------+
  11.    
  12.     [!] Automatic Cheats Detector R1.0
  13.         [!] Developed by icra
  14.     [!] Please, keep credits!
  15. */
  16.  
  17. // Stores player positions at spawn so it can be restored after cheat check.
  18. new
  19.     Float:ACD_pSpawn[MAX_PLAYERS][4],
  20.     ACD_pInterior[MAX_PLAYERS];
  21.  
  22. // Amount of banned/kicked players (resets every gamemode restart)
  23. new ACD_BannedPlayers = 0,
  24.     ACD_KickedPlayers = 0;
  25.  
  26. // Main configuration, type "true" or "false" to enable/disable something.
  27. new
  28.     bool:ACD_Toggled = true, // Enable or disables the cheat check. Console / RCON (in game) command: togacd
  29.     bool:ACD_LOGToggled = true, // Stores when a player get kicked/banned for mod detected. Console / RCON (in game) command: togacdlogs
  30.     bool:ACD_BANToggled = false; // Bans player IP Address if mod is detected, else kicks him. Console / RCON (in game) command: togacdban
  31.  
  32. public OnPlayerSpawn(playerid) {
  33.     if(ACD_Toggled) {
  34.         SetCameraBehindPlayer(playerid); // Stops possible camera moving
  35.         TogglePlayerControllable(playerid, false); // Freezes the player
  36.        
  37.         GetPlayerPos(playerid, ACD_pSpawn[playerid][0], ACD_pSpawn[playerid][1], ACD_pSpawn[playerid][2]); // Stores current player position
  38.         GetPlayerFacingAngle(playerid, ACD_pSpawn[playerid][3]); // Stores current player facing angle
  39.         ACD_pInterior[playerid] = GetPlayerInterior(playerid); // Stores current player interior
  40.        
  41.         SetPlayerPos(playerid,-1155.2751,29.5401,14.1484); // Sets players pos to a random one (different by the stored)
  42.         SetPlayerFacingAngle(playerid,134.4939); // Sets player facing angle to a random one (different by the stored)
  43.         SetPlayerInterior(playerid,ACD_pInterior[playerid]+random(15)+playerid); // Sets player interior to a random one (different by the stored)
  44.        
  45.         // Note: ACD_pInterior[playerid]+random(15)+playerid is an algorithm that sets player in a unique interior and a different from its.
  46.        
  47.         SetTimerEx("ACD_HackShieldTimer", 2000, false, "i", playerid); // Starts timer to check if player is hacking or not
  48.     }
  49.     return true;
  50. }
  51.  
  52. forward ACD_HackShieldTimer(playerid);
  53. public ACD_HackShieldTimer(playerid) {
  54.     new Float:ACD_pVector[3], playeraddress[14], playername[MAX_PLAYER_NAME];
  55.    
  56.     GetPlayerCameraPos(playerid, ACD_pVector[0], ACD_pVector[1], ACD_pVector[2]); // Stores into pVector player's camera to detect if he's cheating.
  57.    
  58.     if(ACD_pVector[2] > 15.3) { // Checks if player camera has moved. If true, there is an unallowed mod installed.
  59.         GetPlayerIp(playerid, playeraddress, sizeof(playeraddress)); // Stores player IP Address to report it in logs.
  60.         GetPlayerName(playerid, playername, sizeof(playername));
  61.        
  62.         if(ACD_LOGToggled) printf("[!ACD!] Kicked player %s (%i), hacks detected. IP: %s",playername,playerid,playeraddress); // Sends a log to admin console.
  63.         GameTextForPlayer(playerid, "~r~UNALLOWED GAME MODIFICATION", 2, 5000); // Notificate user.
  64.        
  65.         if(ACD_BANToggled) Kick(playerid), ACD_KickedPlayers++; else Ban(playerid), ACD_BannedPlayers++; // Kick / Ban the player (depends on your config)
  66.     } else {
  67.         SetPlayerPos(playerid, ACD_pSpawn[playerid][0], ACD_pSpawn[playerid][1], ACD_pSpawn[playerid][2]); // Stores back player position
  68.         SetPlayerFacingAngle(playerid, ACD_pSpawn[playerid][3]); // Stores back player facing angle
  69.         SetPlayerInterior(playerid, ACD_pInterior[playerid]); // Stores back player interior
  70.        
  71.         TogglePlayerControllable(playerid, true); // Allows players move again
  72.     }
  73.     return true;
  74. }
  75.  
  76. stock ACD_Toggle(bool:ACD_status) {
  77.     return ACD_Toggled = ACD_status;
  78. }
  79.  
  80. stock ACD_ToggleLogs(bool:ACD_status) {
  81.     return ACD_LOGToggled = ACD_status;
  82. }
  83.  
  84. stock ACD_ToggleBan(bool:ACD_status) {
  85.     return ACD_BANToggled = ACD_status;
  86. }
  87.  
  88. stock ACD_KickedCount() {
  89.     return ACD_KickedPlayers ++;
  90. }
  91.  
  92. stock ACD_BannedCount() {
  93.     return ACD_BannedPlayers ++;
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement