Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- //#define DM_USE_OPTD
- forward OnPlayerDamageModding(suspectid, involvedid, weaponid, Float:damageamt);
- #if defined DM_USE_OPTD
- static DM_CallbackProcessCheck[MAX_PLAYERS char]; // Used to prevent both callbacks from flagging a player on the same shot.
- #endif
- // Weapon Info Data
- enum e_DMWepData
- {
- DM_WeaponID,
- Float:DM_WeaponDamage
- }
- static const DM_WeaponInfo[][e_DMWepData] =
- {
- {0, 0.0},
- {1, 0.0},
- {2, 0.0},
- {3, 0.0},
- {4, 0.0},
- {5, 0.0},
- {6, 0.0},
- {7, 0.0},
- {8, 0.0},
- {9, 0.0},
- {10, 0.0},
- {11, 0.0},
- {12, 0.0},
- {13, 0.0},
- {14, 0.0},
- {15, 0.0},
- {16, 0.0},
- {17, 0.0},
- {18, 0.0},
- {19, 0.0},
- {20, 0.0},
- {21, 0.0},
- {22, 8.2500000000000000000},
- {23, 13.200000762939453125},
- {24, 46.200000762939453125},
- {25, 3.3},
- {26, 3.3},
- {27, 4.95},
- {28, 6.6000003814697265625},
- {29, 8.2500000000000000000},
- {30, 9.90000057220458984375},
- {31, 9.90000057220458984375},
- {32, 6.6000003814697265625},
- {33, 24.7500019073486328125},
- {34, 41.2500000000000000000}
- };
- // Callbacks
- public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
- {
- switch(amount)
- {
- case 1.32000005245208740234375,
- 1.650000095367431640625,
- 1.980000019073486328125,
- 2.3100001811981201171875,
- 2.6400001049041748046875,
- 2.9700000286102294921875,
- 3.96000003814697265625,
- 4.28999996185302734375,
- 4.62000036239624023437,
- 5.280000209808349609375,
- 6.6000003814697265625,
- 13.5300006866455078125,
- 16.1700000762939453125,
- 26.40000152587890625,
- 27.060001373291015625: {} // Damages that can be generated by weapon bugs
- default:
- {
- switch(weaponid)
- {
- case 22..24,28..34: // Standard bullet weapons (always give the same amount of damage)
- {
- if(amount != DM_WeaponInfo[weaponid][DM_WeaponDamage]) // If their damage isn't the same as the defined, they're damage modding.
- {
- #if defined DM_USE_OPTD
- DM_CallbackProcessCheck{playerid} = true;
- #endif
- OnPlayerDamageModding(playerid, damagedid, weaponid, amount);
- }
- }
- case 25..27: // Shotguns give damage based on a multiplier of the spread that hits
- {
- new Float:dmgamount = amount / DM_WeaponInfo[weaponid][DM_WeaponDamage]; // Divide the damage by the base damage per bullet.
- new Float:fraction = floatfract(dmgamount); // Get the numbers after the decimal point.
- new Float:final = floatround(fraction); // Get the value returned above and round it (for added accuracy).
- if(final != 0.000000) // If the final result is anything other than 0 after the decimal point, they're damage modding.
- {
- #if defined DM_USE_OPTD
- DM_CallbackProcessCheck{playerid} = true;
- #endif
- OnPlayerDamageModding(playerid, damagedid, weaponid, amount);
- }
- }
- }
- }
- }
- #if defined DMGMod_OnPlayerGiveDamage
- return DMGMod_OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart);
- #else
- return 1;
- #endif
- }
- #if defined _ALS_OnPlayerGiveDamage
- #undef OnPlayerGiveDamage
- #else
- #define _ALS_OnPlayerGiveDamage
- #endif
- #define OnPlayerGiveDamage DMGMod_OnPlayerGiveDamage
- #if defined DMGMod_OnPlayerGiveDamage
- forward DMGMod_OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart);
- #endif
- #if defined DM_USE_OPTD
- public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
- {
- if(!DM_CallbackProcessCheck{playerid})
- {
- switch(amount)
- {
- case 1.32000005245208740234375,
- 1.650000095367431640625,
- 1.980000019073486328125,
- 2.3100001811981201171875,
- 2.6400001049041748046875,
- 2.9700000286102294921875,
- 3.96000003814697265625,
- 4.28999996185302734375,
- 4.62000036239624023437,
- 5.280000209808349609375,
- 6.6000003814697265625,
- 13.5300006866455078125,
- 16.1700000762939453125,
- 26.40000152587890625,
- 27.060001373291015625: {} // Damages that can be generated by weapon bugs
- default:
- {
- switch(weaponid)
- {
- case 22..24,28..34: // Standard bullet weapons (always give the same amount of damage)
- {
- if(amount != DM_WeaponInfo[weaponid][DM_WeaponDamage]) // If their damage isn't the same as the defined, they're damage modding.
- {
- OnPlayerDamageModding(playerid, issuerid, weaponid, amount);
- }
- }
- case 25..27: // Shotguns give damage based on a multiplier of the spread that hits
- {
- new Float:dmgamount = amount / DM_WeaponInfo[weaponid][DM_WeaponDamage]; // Divide the damage by the base damage per bullet.
- new Float:fraction = floatfract(dmgamount); // Get the numbers after the decimal point.
- new Float:final = floatround(fraction); // Get the value returned above and round it (for added accuracy).
- if(final != 0.000000) // If the final result is anything other than 0 after the decimal point, they're damage modding.
- {
- OnPlayerDamageModding(playerid, issuerid, weaponid, amount);
- }
- }
- }
- }
- }
- }
- else
- {
- DM_CallbackProcessCheck{playerid} = false; // If it's set to true, reset it to false.
- }
- #if defined DMGMod_OnPlayerTakeDamage
- return DMGMod_OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart);
- #else
- return 1;
- #endif
- }
- #if defined _ALS_OnPlayerTakeDamage
- #undef OnPlayerTakeDamage
- #else
- #define _ALS_OnPlayerTakeDamage
- #endif
- #define OnPlayerTakeDamage DMGMod_OnPlayerTakeDamage
- #if defined DMGMod_OnPlayerTakeDamage
- forward DMGMod_OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart);
- #endif
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement