Eduardo_AC

[INC] Anti-Weapon/Ammo Hack [Updated - 18/07/2017]

Jul 13th, 2017
362
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.58 KB | None | 0 0
  1. /*
  2.     * CALLBACK'S
  3.         - CheckPlayerWeaponHack(playerid)
  4.         - OnPlayerWeaponHackDetected(playerid, detectionid, weaponid, ammo)
  5.     ______________________________________________
  6.  
  7.     * STOCK'S
  8.         - ACW_GivePlayerWeapon(playerid, weaponid, ammo)
  9.         - ACW_SetPlayerWeaponAmmo(playerid, weaponid, ammo)
  10.         - ACW_RemovePlayerWeapon(playerid, weaponid)
  11.         - ACW_ResetPlayerWeapons(playerid)
  12.     ______________________________________________
  13. */
  14. // -- Macros
  15. #define WEAPON_HACK_CHECK_TIME              (3) // Segundos
  16. // ______________________________________________
  17. // -- Variáveis do jogador
  18. static
  19.     dataWeapon[MAX_PLAYERS][13],
  20.     dataAmmo[MAX_PLAYERS][13],
  21.     dataTime[MAX_PLAYERS]
  22. ;
  23. static
  24.     serverAirVehicles[] =
  25.     {
  26.         417, 425, 447, 460, 469,
  27.         476, 487, 488, 497, 511,
  28.         512, 513, 519, 520, 548,
  29.         553, 563, 577, 592, 593
  30.     }
  31. ;
  32. // ______________________________________________
  33. // -- Forwards
  34. forward CheckPlayerWeaponHack(playerid);
  35. forward OnPlayerWeaponHackDetected(playerid, detectionid, weaponid, ammo);
  36. // ______________________________________________
  37. // -- Callback's
  38. public OnPlayerUpdate(playerid)
  39. {
  40.     if(dataTime[playerid] < gettime())
  41.     {
  42.         dataTime[playerid] = gettime() + WEAPON_HACK_CHECK_TIME;
  43.  
  44.         CheckPlayerWeaponHack(playerid);
  45.     }
  46.  
  47.     #if defined ACW_OnPlayerUpdate
  48.         return ACW_OnPlayerUpdate(playerid);
  49.     #else
  50.         return true;
  51.     #endif
  52. }
  53. public OnPlayerExitVehicle(playerid, vehicleid)
  54. {
  55.     new
  56.         getModel = GetVehicleModel(vehicleid)
  57.     ;
  58.  
  59.     dataTime[playerid] += 1;
  60.  
  61.     for(new x = 0; x < sizeof serverAirVehicles; ++ x)
  62.     {
  63.         if(getModel == serverAirVehicles[x])
  64.         {
  65.             dataWeapon[playerid][11] = 46;
  66.             dataAmmo[playerid][11] = 1;
  67.  
  68.             break;
  69.         }
  70.     }
  71.  
  72.     #if defined ACW_OnPlayerExitVehicle
  73.         return ACW_OnPlayerExitVehicle(playerid, vehicleid);
  74.     #else
  75.         return true;
  76.     #endif
  77. }
  78. public OnPlayerDeath(playerid, killerid, reason)
  79. {
  80.     ACW_ResetPlayerWeapons(playerid);
  81.  
  82.     #if defined ACW_OnPlayerDeath
  83.         return ACW_OnPlayerDeath(playerid, killerid, reason);
  84.     #else
  85.         return true;
  86.     #endif
  87. }
  88. public CheckPlayerWeaponHack(playerid)
  89. {
  90.     new
  91.         w,
  92.         a
  93.     ;
  94.  
  95.     for(new x = 0; x < 13; ++ x)
  96.     {
  97.         GetPlayerWeaponData(playerid, x, w, a);
  98.  
  99.         if(dataWeapon[playerid][x] == 40)
  100.         {
  101.             if(dataWeapon[playerid][8] == 39) continue;
  102.             else
  103.             {
  104.                 ACW_RemovePlayerWeapon(playerid, 40);
  105.  
  106.                 continue;
  107.             }
  108.         }
  109.  
  110.         if(dataWeapon[playerid][x] != w)
  111.         {
  112.             if(dataWeapon[playerid][x] == 46)
  113.             {
  114.                 if(w == 0)
  115.                 {
  116.                     dataWeapon[playerid][x] = 0;
  117.                     dataAmmo[playerid][x] = 0;
  118.  
  119.                     continue;
  120.                 }
  121.             }
  122.  
  123.             OnPlayerWeaponHackDetected(playerid, 1, w, a);
  124.         }
  125.  
  126.         if(a > dataAmmo[playerid][x]) OnPlayerWeaponHackDetected(playerid, 2, w, a);
  127.         else dataAmmo[playerid][x] = a;
  128.     }
  129.  
  130.     return true;
  131. }
  132. // ______________________________________________
  133. // -- Stock's
  134. stock ACW_GivePlayerWeapon(playerid, weaponid, ammo)
  135. {
  136.     ACW_RemovePlayerAmmo(playerid, weaponid);
  137.  
  138.     switch(weaponid)
  139.     {
  140.         case 0,1:
  141.         {
  142.             dataWeapon[playerid][0] = weaponid;
  143.             dataAmmo[playerid][0] = ammo;
  144.         }
  145.         case 2..9:
  146.         {
  147.             dataWeapon[playerid][1] = weaponid;
  148.             dataAmmo[playerid][1] = ammo;
  149.         }
  150.         case 22..24:
  151.         {
  152.             dataWeapon[playerid][2] = weaponid;
  153.             dataAmmo[playerid][2] = ammo;
  154.         }
  155.         case 25..27:
  156.         {
  157.             dataWeapon[playerid][3] = weaponid;
  158.             dataAmmo[playerid][3] = ammo;
  159.         }
  160.         case 28,29,32:
  161.         {
  162.             dataWeapon[playerid][4] = weaponid;
  163.             dataAmmo[playerid][4] = ammo;
  164.         }
  165.         case 30,31:
  166.         {
  167.             dataWeapon[playerid][5] = weaponid;
  168.             dataAmmo[playerid][5] = ammo;
  169.         }
  170.         case 33,34:
  171.         {
  172.             dataWeapon[playerid][6] = weaponid;
  173.             dataAmmo[playerid][6] = ammo;
  174.         }
  175.         case 35..38:
  176.         {
  177.             dataWeapon[playerid][7] = weaponid;
  178.             dataAmmo[playerid][7] = ammo;
  179.         }
  180.         case 16..18:
  181.         {
  182.             dataWeapon[playerid][8] = weaponid;
  183.             dataAmmo[playerid][8] = ammo;
  184.         }
  185.         case 39:
  186.         {
  187.             dataWeapon[playerid][8] = weaponid;
  188.             dataAmmo[playerid][8] = ammo;
  189.  
  190.             //WEAPON_BOMB (Detonator)
  191.             dataWeapon[playerid][12] = 40;
  192.             dataAmmo[playerid][12] = ammo;
  193.         }
  194.         case 41..43:
  195.         {
  196.             dataWeapon[playerid][9] = weaponid;
  197.             dataAmmo[playerid][9] = ammo;
  198.         }
  199.         case 10..15:
  200.         {
  201.             dataWeapon[playerid][10] = weaponid;
  202.             dataAmmo[playerid][10] = ammo;
  203.         }
  204.         case 44..46:
  205.         {
  206.             dataWeapon[playerid][11] = weaponid;
  207.             dataAmmo[playerid][11] = ammo;
  208.         }
  209.         case 40:
  210.         {
  211.             dataWeapon[playerid][12] = weaponid;
  212.             dataAmmo[playerid][12] = ammo;
  213.         }
  214.         default: return false;
  215.     }
  216.  
  217.     GivePlayerWeapon(playerid, weaponid, ammo);
  218.  
  219.     return true;
  220. }
  221. static stock ACW_RemovePlayerAmmo(playerid, weaponid)
  222. {
  223.     new
  224.         w,
  225.         a
  226.     ;
  227.  
  228.     for(new x = 0; x < 13; ++ x)
  229.     {
  230.         GetPlayerWeaponData(playerid, x, w, a);
  231.  
  232.         if(w == weaponid)
  233.         {
  234.             GivePlayerWeapon(playerid, weaponid, -a);
  235.  
  236.             break;
  237.         }
  238.     }
  239.  
  240.     return true;
  241. }
  242. stock ACW_SetPlayerWeaponAmmo(playerid, weaponid, ammo)
  243. {
  244.     new
  245.         w,
  246.         a
  247.     ;
  248.  
  249.     for(new x = 0; x < 13; ++ x)
  250.     {
  251.         GetPlayerWeaponData(playerid, x, w, a);
  252.  
  253.         if(w == weaponid)
  254.         {
  255.             GivePlayerWeapon(playerid, weaponid, -a);
  256.             GivePlayerWeapon(playerid, weaponid, ammo);
  257.  
  258.             dataAmmo[playerid][x] = ammo;
  259.  
  260.             break;
  261.         }
  262.     }
  263.  
  264.     return true;
  265. }
  266. stock ACW_RemovePlayerWeapon(playerid, weaponid)
  267. {
  268.     new
  269.         w[13],
  270.         a[13]
  271.     ;
  272.  
  273.     for(new x = 0; x < 13; ++ x)
  274.     {
  275.         GetPlayerWeaponData(playerid, x, w[x], a[x]);
  276.     }
  277.  
  278.     ResetPlayerWeapons(playerid);
  279.  
  280.     for(new x = 0; x < 13; ++ x)
  281.     {
  282.         if(w[x] != weaponid)
  283.         {
  284.             GivePlayerWeapon(playerid, w[x], a[x]);
  285.         }
  286.         else if(w[x] == weaponid)
  287.         {
  288.             dataWeapon[playerid][x] = 0;
  289.             dataAmmo[playerid][x] = 0;
  290.         }
  291.     }
  292.  
  293.     return true;
  294. }
  295. stock ACW_ResetPlayerWeapons(playerid)
  296. {
  297.     for(new x = 0; x < 13; ++ x)
  298.     {
  299.         dataWeapon[playerid][x] = 0;
  300.         dataAmmo[playerid][x] = 0;
  301.     }
  302.  
  303.     ResetPlayerWeapons(playerid);
  304.  
  305.     return true;
  306. }
  307. // ______________________________________________
  308. // -- Hook's
  309. #if defined _ALS_OnPlayerUpdate
  310.     #undef OnPlayerUpdate
  311. #else
  312.     #define _ALS_OnPlayerUpdate
  313. #endif
  314. #define OnPlayerUpdate ACW_OnPlayerUpdate
  315. #if defined ACW_OnPlayerUpdate
  316.     forward ACW_OnPlayerUpdate(playerid);
  317. #endif
  318. //
  319. #if defined _ALS_OnPlayerExitVehicle
  320.     #undef OnPlayerExitVehicle
  321. #else
  322.     #define _ALS_OnPlayerExitVehicle
  323. #endif
  324. #define OnPlayerExitVehicle ACW_OnPlayerExitVehicle
  325. #if defined ACW_OnPlayerExitVehicle
  326.     forward ACW_OnPlayerExitVehicle(playerid, vehicleid);
  327. #endif
  328. //
  329. #if defined _ALS_OnPlayerDeath
  330.     #undef OnPlayerDeath
  331. #else
  332.     #define _ALS_OnPlayerDeath
  333. #endif
  334. #define OnPlayerDeath ACW_OnPlayerDeath
  335. #if defined ACW_OnPlayerDeath
  336.     forward ACW_OnPlayerDeath(playerid, killerid, reason);
  337. #endif
Add Comment
Please, Sign In to add comment