#include <amxmodx>
#include <reapi>
new g_iMoney;
new g_iBlockDamage;
new g_iMPFriendlyFire;
public plugin_init()
{
register_plugin("FriendlyFire_Punish", "1.3", "w0w & perf");
RegisterHookChain(RG_CBasePlayer_TakeDamage, "CBasePlayer_TakeDamage_Pre", false);
new pCvar;
pCvar = create_cvar("ff_punish_money", "10", FCVAR_NONE, "Money that will be taken for friendlyfire", true, 0.0, true, 999.999);
bind_pcvar_num(pCvar, g_iMoney);
pCvar = create_cvar("ff_punish_blockdamage", "1", FCVAR_NONE, "Block damage when friendlyfire or not", true, 0.0, true, 1.0);
bind_pcvar_num(pCvar, g_iBlockDamage);
AutoExecConfig(true, "ff_punish");
pCvar = get_cvar_pointer("mp_friendlyfire");
bind_pcvar_num(pCvar, g_iMPFriendlyFire);
}
public CBasePlayer_TakeDamage_Pre(iVictim, iInflictor, iAttacker, Float:flDamage, iBitsDamageType)
{
if(iAttacker == iVictim || iBitsDamageType & DMG_BLAST || !g_iMPFriendlyFire)
return HC_CONTINUE;
if(get_member(iAttacker, m_iTeam) == get_member(iVictim, m_iTeam))
{
if(iBitsDamageType & DMG_GRENADE || iAttacker == iInflictor)
{
rg_add_account(iAttacker, max(get_member(iAttacker, m_iAccount) - floatround(flDamage) * g_iMoney, 0), .typeSet = AS_SET);
if(g_iBlockDamage)
{
SetHookChainReturn(ATYPE_INTEGER, false);
return HC_SUPERCEDE;
}
}
}
return HC_CONTINUE;
}