Advertisement
Guest User

Seif

a guest
Aug 1st, 2009
1,515
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.74 KB | None | 0 0
  1. /*
  2.                             Seifensive - Anti Cheat INCLUDE
  3. */
  4. /*x---------------------------------Important-------------------------------------x*/
  5. //**INCLUDES**//
  6. #include <a_samp>
  7. //**PRAGMAS**//
  8. //#pragma unused Seif_GivePlayerMoney
  9. //#pragma unused Seif_TakePlayerMoney
  10. //#pragma unused Seif_GivePlayerWeapon
  11. //**MISC**//
  12.  
  13. /*x---------------------------------Defining-------------------------------------x*/
  14. //**COLORS*//
  15. #define GREEN 0x21DD00FF
  16. #define RED 0xE60000FF
  17. #define ADMIN_RED 0xFB0000FF
  18. #define YELLOW 0xFFFF00FF
  19. #define ORANGE 0xF97804FF
  20. #define LIGHTRED 0xFF8080FF
  21. #define LIGHTBLUE 0x00C2ECFF
  22. #define PURPLE 0xB360FDFF
  23. #define PLAYER_COLOR 0xFFFFFFFF
  24. #define BLUE 0x1229FAFF
  25. #define LIGHTGREEN 0x38FF06FF
  26. #define DARKPINK 0xE100E1FF
  27. #define DARKGREEN 0x008040FF
  28. #define ANNOUNCEMENT 0x6AF7E1FF
  29. #define COLOR_SYSTEM 0xEFEFF7AA
  30. #define GREY 0xCECECEFF
  31. #define PINK 0xD52DFFFF
  32. #define DARKGREY    0x626262FF
  33. #define AQUAGREEN   0x03D687FF
  34. #define NICESKY 0x99FFFFAA
  35. #define WHITE           0xFFFFFFFF
  36. //**MISC**//
  37. #define ON                          1
  38. #define OFF                         0
  39. #define MAX_WEAPONS                 47
  40. #define MONEY_HACK                  5000 // Maximum money amount found as extra between current cash and script cash
  41. #define MAX_AMMO_HACK               69  // Maximum bullets found as extra between normal ammo and scripted one. (69 = s0beit)
  42. #define KICK                        1
  43. #define BAN                         2
  44. //**VARIABLES**//
  45. enum acInfo
  46. {
  47.     acWeapon[13],
  48.     acCash,
  49.     acWAmmo[MAX_WEAPONS],
  50. }
  51. new Seifensive[MAX_PLAYERS][acInfo];
  52. new hhtime[MAX_PLAYERS];
  53. new HACKER = BAN;
  54.  
  55. new TOGGLE_WEAPON_DETECTION = ON;
  56. new TOGGLE_JETPACK_DETECTION = ON;
  57. // **FORWARDS** //
  58. forward HackingDetected(playerid, reason[]);
  59. forward WeaponDetection();
  60. forward MoneyDetection();
  61. forward HealthDetection(playerid);
  62. forward HealthHackSuspection(suspectid);
  63. forward Seifensive_OnInit();
  64. forward Seifensive_OnPlayerSpawn(playerid);
  65. forward Seifensive_OnPlayerConnect(playerid);
  66. forward Seifensive_OnPlayerDisconnect(playerid, reason);
  67. /*x---------------------------------CallBacks-------------------------------------x*/
  68. public WeaponDetection()
  69. {
  70.     new w[MAX_PLAYERS],a[MAX_PLAYERS];
  71.     for(new i = 0; i < MAX_PLAYERS; i++)
  72.     {
  73.         if (IsPlayerConnected(i))
  74.         {
  75.             if (TOGGLE_JETPACK_DETECTION == ON)
  76.             {
  77.                 if (GetPlayerSpecialAction(i) == SPECIAL_ACTION_USEJETPACK)
  78.                 {
  79.                     HackingDetected(i, "Jetpack hacking");
  80.                     break;
  81.                 }
  82.             }
  83.             w[i] = 0;
  84.             a[i] = 0;
  85.             for(new s = 0; s < 13; s++)
  86.             {
  87.                 GetPlayerWeaponData(i, s, w[i], a[i]);
  88.                 if (Seifensive[i][acWeapon][s] != w[i])
  89.                 {
  90.                     if (a[i] > Seifensive[i][acWAmmo][w[i]])
  91.                     {
  92.                         if ((a[i] - Seifensive[i][acWAmmo][w[i]]) >= MAX_AMMO_HACK)
  93.                         {
  94.                             HackingDetected(i, "Weapon/Ammo hacking");
  95.                             break;
  96.                         }
  97.                     }
  98.                 }
  99.             }
  100.         }
  101.     }
  102. }
  103.  
  104. public MoneyDetection()
  105. {
  106.     for(new i = 0; i < MAX_PLAYERS; i++)
  107.     {
  108.         if (IsPlayerConnected(i))
  109.         {
  110.             new cash = GetPlayerMoney(i);
  111.             if (cash > Seifensive[i][acCash])
  112.             {
  113.                 if ((cash - Seifensive[i][acCash]) > MONEY_HACK)
  114.                 {
  115.                     HackingDetected(i, "Money hacking");
  116.                     break;
  117.                 }
  118.             }
  119.         }
  120.     }
  121. }
  122.  
  123. public HealthDetection(playerid)
  124. {
  125.     if (IsPlayerConnected(playerid))
  126.     {
  127.         KillTimer(hhtime[playerid]);
  128.         new Float:hp;
  129.         GetPlayerHealth(playerid, hp);
  130.         if (hp >= 100)
  131.         {
  132.             if (GetPlayerPing(playerid) < 700)
  133.             {
  134.                 SetPlayerHealth(playerid, 99);
  135.                 hhtime[playerid] = SetTimerEx("HealthDetection",1000,0,"d",playerid);
  136.                 return;
  137.             }
  138.         }
  139.         hhtime[playerid] = SetTimerEx("HealthDetection",1000,0,"d",playerid);
  140.     }
  141. }
  142.  
  143. public HealthHackSuspection(suspectid)
  144. {
  145.     if (IsPlayerConnected(suspectid))
  146.     {
  147.         new Float:hp;
  148.         GetPlayerHealth(suspectid, hp);
  149.         if (hp >= 100)
  150.         {
  151.             if (GetPlayerPing(suspectid) < 700) HackingDetected(suspectid, "Health hacking");
  152.         }
  153.     }
  154. }
  155.  
  156. public HackingDetected(playerid, reason[])
  157. {
  158.     new string[128];
  159.     new name[MAX_PLAYER_NAME];
  160.     GetPlayerName(playerid, name, sizeof(name));
  161.     if (HACKER == BAN)
  162.     {
  163.         format(string, sizeof(string), "|- SeifensiveBot has banned %s | Reason: %s -|", name, reason);
  164.         SendClientMessageToAll(ADMIN_RED, string);
  165.         BanEx(playerid, reason);
  166.     }
  167.     else if (HACKER == KICK)
  168.     {
  169.         format(string, sizeof(string), "|- SeifensiveBot has kicked %s | Reason: %s -|", name, reason);
  170.         SendClientMessageToAll(ADMIN_RED, string);
  171.         Kick(playerid);
  172.     }
  173. }
  174.  
  175. public Seifensive_OnInit()
  176. {
  177.     SetTimer("MoneyDetection",2000,1);
  178.     if (TOGGLE_WEAPON_DETECTION == ON) SetTimer("WeaponDetection",5000,1);
  179. }
  180.  
  181. public Seifensive_OnPlayerSpawn(playerid)
  182. {
  183.     hhtime[playerid] = SetTimerEx("HealthDetection",1000,0,"d",playerid);
  184. }
  185.  
  186. public Seifensive_OnPlayerConnect(playerid)
  187. {
  188.     for(new i = 0; i <= 12; i++) Seifensive[playerid][acWeapon][i] = 0;
  189.     for(new w = 0; w <= MAX_WEAPONS; w++) Seifensive[playerid][acWAmmo][w] = 0;
  190.     Seifensive[playerid][acCash] = 0;
  191. }
  192.  
  193. public Seifensive_OnPlayerDisconnect(playerid, reason)
  194. {
  195.     for(new i = 0; i <= 12; i++) Seifensive[playerid][acWeapon][i] = 0;
  196.     for(new w = 0; w <= MAX_WEAPONS; w++) Seifensive[playerid][acWAmmo][w] = 0;
  197.     Seifensive[playerid][acCash] = 0;
  198.     KillTimer(hhtime[playerid]);
  199. }
  200.  
  201. stock GetWeapSlotID(weaponid)
  202. {
  203.     switch (weaponid)
  204.     {
  205.         case 0,1: return 0;
  206.         case 2..9: return 1;
  207.         case 10..15: return 10;
  208.         case 16..18,39: return 8;
  209.         case 22..24: return 2;
  210.         case 25..27: return 3;
  211.         case 28,29,32: return 4;
  212.         case 33,34: return 6;
  213.         case 35..38: return 7;
  214.         case 41..43: return 9;
  215.         case 44..46: return 11;
  216.         default: return 12;
  217.     }
  218.     return 0;
  219. }
  220.  
  221. stock IsValidWeapon(weaponid)
  222. {
  223.     if (weaponid > 0) return 1;
  224.     return 0;
  225. }
  226.  
  227. Seif_GivePlayerMoney(playerid, amount)
  228. {
  229.     Seifensive[playerid][acCash] += amount;
  230.     GivePlayerMoney(playerid, amount);
  231. }
  232.  
  233. Seif_TakePlayerMoney(playerid, amount)
  234. {
  235.     Seifensive[playerid][acCash] -= amount;
  236.     GivePlayerMoney(playerid, -amount);
  237. }
  238.  
  239. Seif_GivePlayerWeapon(playerid, weaponid, ammos)
  240. {
  241.     Seifensive[playerid][acWeapon][GetWeapSlotID(weaponid)] = weaponid;
  242.     Seifensive[playerid][acWAmmo][weaponid] = ammos;
  243.     GivePlayerWeapon(playerid, weaponid, ammos);
  244. }
  245.  
  246. Seif_ResetPlayerMoney(playerid)
  247. {
  248.     Seifensive[playerid][acCash] -= Seifensive[playerid][acCash];
  249.     GivePlayerMoney(playerid, Seifensive[playerid][acCash]-Seifensive[playerid][acCash]);
  250. }
  251.  
  252. Seif_GetPlayerMoney(playerid)
  253. {
  254.     return Seifensive[playerid][acCash];
  255. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement