Advertisement
Guest User

Untitled

a guest
May 29th, 2018
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.56 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. //#define DM_USE_OPTD
  4.  
  5. forward OnPlayerDamageModding(suspectid, involvedid, weaponid, Float:damageamt);
  6.  
  7.  
  8. #if defined DM_USE_OPTD
  9. static DM_CallbackProcessCheck[MAX_PLAYERS char]; // Used to prevent both callbacks from flagging a player on the same shot.
  10. #endif
  11.  
  12. // Weapon Info Data
  13. enum e_DMWepData
  14. {
  15.     DM_WeaponID,
  16.     Float:DM_WeaponDamage
  17. }
  18.  
  19. static const DM_WeaponInfo[][e_DMWepData] =
  20. {
  21.     {0, 0.0},
  22.     {1, 0.0},
  23.     {2, 0.0},
  24.     {3, 0.0},
  25.     {4, 0.0},
  26.     {5, 0.0},
  27.     {6, 0.0},
  28.     {7, 0.0},
  29.     {8, 0.0},
  30.     {9, 0.0},
  31.     {10, 0.0},
  32.     {11, 0.0},
  33.     {12, 0.0},
  34.     {13, 0.0},
  35.     {14, 0.0},
  36.     {15, 0.0},
  37.     {16, 0.0},
  38.     {17, 0.0},
  39.     {18, 0.0},
  40.     {19, 0.0},
  41.     {20, 0.0},
  42.     {21, 0.0},
  43.     {22, 8.2500000000000000000},
  44.     {23, 13.200000762939453125},
  45.     {24, 46.200000762939453125},
  46.     {25, 3.3},
  47.     {26, 3.3},
  48.     {27, 4.95},
  49.     {28, 6.6000003814697265625},
  50.     {29, 8.2500000000000000000},
  51.     {30, 9.90000057220458984375},
  52.     {31, 9.90000057220458984375},
  53.     {32, 6.6000003814697265625},
  54.     {33, 24.7500019073486328125},
  55.     {34, 41.2500000000000000000}
  56. };
  57.  
  58. // Callbacks
  59. public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
  60. {
  61.     switch(amount)
  62.     {
  63.         case 1.32000005245208740234375,
  64.         1.650000095367431640625,
  65.         1.980000019073486328125,
  66.         2.3100001811981201171875,
  67.         2.6400001049041748046875,
  68.         2.9700000286102294921875,
  69.         3.96000003814697265625,
  70.         4.28999996185302734375,
  71.         4.62000036239624023437,
  72.         5.280000209808349609375,
  73.         6.6000003814697265625,
  74.         13.5300006866455078125,
  75.         16.1700000762939453125,
  76.         26.40000152587890625,
  77.         27.060001373291015625: {} // Damages that can be generated by weapon bugs
  78.         default:
  79.         {
  80.             switch(weaponid)
  81.             {
  82.                 case 22..24,28..34: // Standard bullet weapons (always give the same amount of damage)
  83.                 {
  84.                     if(amount != DM_WeaponInfo[weaponid][DM_WeaponDamage]) // If their damage isn't the same as the defined, they're damage modding.
  85.                     {
  86.                         #if defined DM_USE_OPTD
  87.                         DM_CallbackProcessCheck{playerid} = true;
  88.                         #endif
  89.                         OnPlayerDamageModding(playerid, damagedid, weaponid, amount);
  90.                     }
  91.                 }
  92.                 case 25..27: // Shotguns give damage based on a multiplier of the spread that hits
  93.                 {
  94.                     new Float:dmgamount = amount / DM_WeaponInfo[weaponid][DM_WeaponDamage]; // Divide the damage by the base damage per bullet.
  95.                     new Float:fraction = floatfract(dmgamount); // Get the numbers after the decimal point.
  96.                     new Float:final = floatround(fraction); // Get the value returned above and round it (for added accuracy).
  97.                     if(final != 0.000000) // If the final result is anything other than 0 after the decimal point, they're damage modding.
  98.                     {
  99.                         #if defined DM_USE_OPTD
  100.                         DM_CallbackProcessCheck{playerid} = true;
  101.                         #endif
  102.                         OnPlayerDamageModding(playerid, damagedid, weaponid, amount);
  103.                     }
  104.                 }
  105.             }
  106.         }
  107.     }
  108.     #if defined DMGMod_OnPlayerGiveDamage
  109.         return DMGMod_OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart);
  110.     #else
  111.         return 1;
  112.     #endif
  113. }
  114. #if defined _ALS_OnPlayerGiveDamage
  115.     #undef OnPlayerGiveDamage
  116. #else
  117.     #define _ALS_OnPlayerGiveDamage
  118. #endif
  119. #define OnPlayerGiveDamage DMGMod_OnPlayerGiveDamage
  120. #if defined DMGMod_OnPlayerGiveDamage
  121.     forward DMGMod_OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart);
  122. #endif
  123.  
  124. #if defined DM_USE_OPTD
  125. public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
  126. {
  127.     if(!DM_CallbackProcessCheck{playerid})
  128.     {
  129.         switch(amount)
  130.         {
  131.             case 1.32000005245208740234375,
  132.             1.650000095367431640625,
  133.             1.980000019073486328125,
  134.             2.3100001811981201171875,
  135.             2.6400001049041748046875,
  136.             2.9700000286102294921875,
  137.             3.96000003814697265625,
  138.             4.28999996185302734375,
  139.             4.62000036239624023437,
  140.             5.280000209808349609375,
  141.             6.6000003814697265625,
  142.             13.5300006866455078125,
  143.             16.1700000762939453125,
  144.             26.40000152587890625,
  145.             27.060001373291015625: {} // Damages that can be generated by weapon bugs
  146.             default:
  147.             {
  148.                 switch(weaponid)
  149.                 {
  150.                     case 22..24,28..34: // Standard bullet weapons (always give the same amount of damage)
  151.                     {
  152.                         if(amount != DM_WeaponInfo[weaponid][DM_WeaponDamage]) // If their damage isn't the same as the defined, they're damage modding.
  153.                         {
  154.                             OnPlayerDamageModding(playerid, issuerid, weaponid, amount);
  155.                         }
  156.                     }
  157.                     case 25..27: // Shotguns give damage based on a multiplier of the spread that hits
  158.                     {
  159.                         new Float:dmgamount = amount / DM_WeaponInfo[weaponid][DM_WeaponDamage]; // Divide the damage by the base damage per bullet.
  160.                         new Float:fraction = floatfract(dmgamount); // Get the numbers after the decimal point.
  161.                         new Float:final = floatround(fraction); // Get the value returned above and round it (for added accuracy).
  162.                         if(final != 0.000000) // If the final result is anything other than 0 after the decimal point, they're damage modding.
  163.                         {
  164.                             OnPlayerDamageModding(playerid, issuerid, weaponid, amount);
  165.                         }
  166.                     }
  167.                 }
  168.             }
  169.         }
  170.     }
  171.     else
  172.     {
  173.         DM_CallbackProcessCheck{playerid} = false; // If it's set to true, reset it to false.
  174.     }
  175.     #if defined DMGMod_OnPlayerTakeDamage
  176.         return DMGMod_OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart);
  177.     #else
  178.         return 1;
  179.     #endif
  180. }
  181. #if defined _ALS_OnPlayerTakeDamage
  182.     #undef OnPlayerTakeDamage
  183. #else
  184.     #define _ALS_OnPlayerTakeDamage
  185. #endif
  186. #define OnPlayerTakeDamage DMGMod_OnPlayerTakeDamage
  187. #if defined DMGMod_OnPlayerTakeDamage
  188.     forward DMGMod_OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart);
  189. #endif
  190. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement