Advertisement
Guest User

SAMP - Anti ATJ (Cleo Carjacker)

a guest
Sep 15th, 2014
956
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.22 KB | None | 0 0
  1. #define FILTERSCRIPT
  2.  
  3. #include <a_samp>
  4. #include <callbacks>
  5. #include <foreach>
  6.  
  7. new
  8.     bool:Suspect[ MAX_PLAYERS char ], bool:PressedKey[ MAX_PLAYERS char ]
  9. ;
  10.  
  11. #define PRESSED(%0) \
  12.     (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
  13. #define PUB:%0(%1)  forward %0(%1); \
  14.                     public %0(%1)
  15.  
  16. #if defined FILTERSCRIPT
  17.  
  18. public OnFilterScriptInit()
  19. {
  20.     print("\n--------------------------------------");
  21.     print("Anti 'ATJ' by Kyance\nBETA VERSION -LOADED-");
  22.     print("--------------------------------------\n");
  23.     foreach(Player,i) OnPlayerConnect(i);
  24.     return 1;
  25. }
  26.  
  27. public OnFilterScriptExit()
  28. {
  29.     print("\n--------------------------------------");
  30.     print("Anti 'ATJ' by Kyance\nBETA VERSION -UNLOADED-");
  31.     print("--------------------------------------\n");
  32.     return 1;
  33. }
  34.  
  35. #endif
  36.  
  37. public OnPlayerConnect(playerid)
  38. {
  39.     Suspect{ playerid } = false, PressedKey{ playerid } = false;
  40.     return 1;
  41. }
  42. public OnPlayerCarJack(playerid, targetid, vehicleid)
  43. {
  44.     if(PressedKey{ playerid })
  45.     {
  46.         Suspect{ playerid } = true;
  47.         CheckATJ(playerid, targetid);
  48.     }
  49.     return 1;
  50. }
  51. /*
  52. This part of the code isn't tested, that's why it's 'commented'
  53. IMPORTANT: If you wish to uncomment this line, please do some changes in this code, or in the 'OnPlayerCarJack', since then, 2 messages will be sent (if a player gets carjacked by this)
  54. public OnPlayerStateChange(playerid, newstate, oldstate)
  55. {
  56.     if(PressedKey{ playerid })
  57.     {
  58.         if(newstate == PLAYER_STATE_DRIVER && Suspect{ playerid })
  59.         {
  60.             new string[96];
  61.             format(string, sizeof(string), "SERVER: %s is possibly using the 'ATJ' cleo hack!", GetName(playerid)), SendClientMessageToAll(-1, string), string = "\0";
  62.         }
  63.     }
  64.     return 1;
  65. }
  66. IMPORTANT: If you wish to uncomment this line, please do some changes in this code, or in the 'OnPlayerCarJack', since then, 2 messages will be sent (if a player gets carjacked by this)
  67. This part of the code isn't tested, that's why it's 'commented'
  68. */
  69. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  70. {
  71.     if(PRESSED(KEY_HANDBRAKE)) PressedKey{ playerid } = true, SetTimerEx("ResetPK", 2000, false, "i", playerid);
  72.     return 1;
  73. }
  74. stock CheckATJ(playerid, targetid = INVALID_PLAYER_ID)
  75. {
  76.     if(targetid != INVALID_PLAYER_ID && Suspect{ playerid })
  77.     {
  78.         new vehicleid = GetPlayerVehicleID(playerid), string[98];
  79.            
  80.         RemovePlayerFromVehicle(playerid), SetTimerEx("PutInVehicle", 1500, false, "ii", targetid, vehicleid);
  81.         format(string, sizeof(string), "SERVER: We've detected that you've possibly been a 'ATJ' target by '%s'", GetName(playerid));
  82.         SendClientMessage(targetid, -1, string), string = "\0";
  83.         format(string, sizeof(string), "SERVER: %s is possibly using the 'ATJ' cleo hack!", GetName(playerid)), SendClientMessageToAll(-1, string), string = "\0";
  84.         //You can delete the 83rd line, and use a Kick instead(or ban... or w.e you want to).
  85.     }
  86. }
  87. stock GetName(playerid)
  88. {
  89.     new pnameid[24];
  90.     GetPlayerName(playerid,pnameid,sizeof(pnameid));
  91.     return pnameid;
  92. }
  93. PUB:ResetPK(playerid)
  94. {
  95.     PressedKey{ playerid } = false;
  96.     return 1;
  97. }
  98. PUB:PutInVehicle(playerid, vehicleid)
  99. {
  100.     PutPlayerInVehicle(playerid, vehicleid, 0);
  101.     SendClientMessage(playerid, -1, "SERVER: You've been put back in your vehicle!");
  102.     return 1;
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement