/* code secondattack by Knife Secondary Attack Modification by Safety1st */
#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
/* EDIT ME */
const Float:Knife_Speed = 350.0
/* EDIT ME */
const m_pActiveItem = 373
const m_pPlayer = 41
const m_flNextSecondaryAttack = 47
const linux_diff_player = 5
const linux_diff_weapon = 4
const SAFE_PDATA = 2
const Float:knife_rate_after_secondattack = 1.1
new Ham:Ham_Player_ResetMaxSpeed = Ham_Item_PreFrame
public plugin_init()
{
register_plugin("[AMXX] Knife Bonus", "", "steelzorrr (for dev-cs)")
RegisterHam(Ham_Player_ResetMaxSpeed, "player", "CBasePlayer_ResetMaxSpeed_Pre", .Post = false)
RegisterHam(Ham_TakeDamage, "player", "CBasePlayer_TakeDamage_Post", .Post = true)
}
public CBasePlayer_ResetMaxSpeed_Pre(iPlayer)
{
if(!is_user_alive(iPlayer)) return HAM_IGNORED
static iEnt; iEnt = get_pdata_cbase(iPlayer, m_pActiveItem, linux_diff_player)
if(pev_valid(iEnt) != SAFE_PDATA) return HAM_IGNORED
if(get_user_weapon(iPlayer) == CSW_KNIFE) set_pev(iPlayer, pev_maxspeed, Knife_Speed)
//else set_pev(iPlayer, pev_maxspeed, -1.0) // ??
return HAM_IGNORED
}
public CBasePlayer_TakeDamage_Post(iVictim, iInflictor, iAttacker, Float:flDamage, iBitsDamage)
{
if(!is_user_connected(iAttacker) || iVictim == iAttacker) return HAM_IGNORED
if(!(pev(iAttacker, pev_button) & IN_ATTACK2)) return HAM_IGNORED
if(iBitsDamage & DMG_GRENADE) return HAM_IGNORED
static iEnt; iEnt = get_pdata_cbase(iAttacker, m_pActiveItem, linux_diff_weapon)
if(get_user_weapon(iAttacker) != CSW_KNIFE && get_pdata_float(iEnt, m_flNextSecondaryAttack, linux_diff_weapon) != knife_rate_after_secondattack) return HAM_IGNORED
ExecuteHamB(Ham_Killed, iVictim, iAttacker, 2)
return HAM_HANDLED
}