#include <amxmodx>
#include <hamsandwich>
#include <reapi>
new Float:g_eCvar[MAX_WEAPONS - 1];
public plugin_init()
{
register_plugin("[AMXX] Weapon Damage Control", "0.2", "Flymic24");
const IGNORE_WEAPON = 1<<CSW_HEGRENADE|1<<CSW_SMOKEGRENADE|1<<CSW_FLASHBANG|1<<CSW_C4|1<<CSW_GLOCK;
for(new iWeaponID = 1, szWeaponName[MAX_NAME_LENGTH]; iWeaponID < MAX_WEAPONS - 1; iWeaponID++)
{
if((1<<iWeaponID) & ~IGNORE_WEAPON)
{
get_weaponname(iWeaponID, szWeaponName, charsmax(szWeaponName));
RegisterHam(Ham_Spawn, szWeaponName, "Ham_Weapon_Spawn_Post", .Post = true);
replace(szWeaponName, charsmax(szWeaponName), "weapon_", NULL_STRING);
bind_pcvar_float(create_cvar(
fmt("amx_dmg_%s", szWeaponName),
"1.0",
FCVAR_NONE,
fmt("damage %s: 0.0 - Disable", szWeaponName),
true,
0.0),
g_eCvar[iWeaponID]
);
}
}
AutoExecConfig(true, "weapon_damage_control");
}
public Ham_Weapon_Spawn_Post(const iWeapon)
{
if(get_entvar(iWeapon, var_impulse)) // Ignore Custom Weapon
return HAM_IGNORED;
new iWeaponID = get_member(iWeapon, m_iId);
set_member(iWeapon, m_Weapon_flBaseDamage, Float:get_member(iWeapon, m_Weapon_flBaseDamage) * g_eCvar[iWeaponID]);
switch(iWeaponID)
{
case CSW_M4A1: set_member(iWeapon, m_M4A1_flBaseDamageSil, Float:get_member(iWeapon, m_M4A1_flBaseDamageSil) * g_eCvar[iWeaponID]);
case CSW_USP: set_member(iWeapon, m_USP_flBaseDamageSil, Float:get_member(iWeapon, m_USP_flBaseDamageSil) * g_eCvar[iWeaponID]);
case CSW_FAMAS: set_member(iWeapon, m_Famas_flBaseDamageBurst, Float:get_member(iWeapon, m_Famas_flBaseDamageBurst) * g_eCvar[iWeaponID]);
case CSW_KNIFE:
{
set_member(iWeapon, m_Knife_flStabBaseDamage, Float:get_member(iWeapon, m_Knife_flStabBaseDamage) * g_eCvar[iWeaponID]);
set_member(iWeapon, m_Knife_flSwingBaseDamage, Float:get_member(iWeapon, m_Knife_flSwingBaseDamage) * g_eCvar[iWeaponID]);
set_member(iWeapon, m_Knife_flSwingBaseDamage_Fast, Float:get_member(iWeapon, m_Knife_flSwingBaseDamage_Fast) * g_eCvar[iWeaponID]);
}
}
return HAM_IGNORED;
}