#include <amxmodx>
#include <reapi>
#include <hamsandwich>
#define REGEN_TIME 5.0 // Interval time
#define REGEN_AMOUNT_HP 15.0 // Amount HP for interval
#define REGEN_AMOUNT_AP 15.0 // Amount AP for interval
#define MAX_HP 100.0 // max hp
#define MAX_AP 100.0 // max ap
public plugin_init() {
RegisterHam(Ham_Item_PostFrame, "weapon_knife", "Ham_KnifePostFrame", false);
}
public Ham_KnifePostFrame(iItem)
{
new pPlayer;
if(!(pPlayer = get_member(iItem, m_pPlayer)) || !is_user_connected(pPlayer))
return HAM_IGNORED;
new Float:fGametime; fGametime = get_gametime();
if(get_member(iItem, m_Weapon_fInSpecialReload) < fGametime) {
set_entvar(pPlayer, var_health, floatmin(Float:get_entvar(pPlayer, var_health) + REGEN_AMOUNT_HP, MAX_HP));
set_entvar(pPlayer, var_armorvalue, floatmin(Float:get_entvar(pPlayer, var_armorvalue) + REGEN_AMOUNT_AP, MAX_AP));
set_member(iItem, m_Weapon_fInSpecialReload, fGametime + REGEN_TIME);
}
return HAM_IGNORED;
}