#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
stock const PluginName[] = "Sound Heath In AWP Zoom";
stock const PluginVersion[] = "1.0";
stock const PluginAuthor[] = "nothing to say. / Idea: MayroN";
const SMALL_SNIPERS_ZOOM = 40;
const m_iFOV = 363; // Оффсэт FOVа игрока.
const m_pPlayer = 41; // Оффсэт индекса игрока.
const NeedHealth = 25; // Минимальное количество HP для звука.
const Float: fDelayToNextSound = 3.0; // Задержка для нового звука.
new const szWeaponList[][] =
{
"weapon_awp",
"weapon_scout"
};
new const szSound[] = "awp_zoom/heartbeat.wav"; // Звук.
public plugin_init()
{
register_plugin(PluginName, PluginVersion, PluginAuthor);
for(new i; i < sizeof(szWeaponList); i++) {
RegisterHam(Ham_Weapon_SecondaryAttack, szWeaponList[i], "WeaponBase__SecondaryAttack_Post", true);
}
}
public plugin_precache()
{
precache_sound(szSound);
}
public client_putinserver(pPlayer)
{
remove_task(pPlayer);
}
public client_disconnected(pPlayer)
{
remove_task(pPlayer);
}
public WeaponBase__SecondaryAttack_Post(const pItem)
{
new pPlayer = get_pdata_cbase(pItem, m_pPlayer, 4);
new iPlayerFov = get_pdata_int(pPlayer, m_iFOV, 5);
if(iPlayerFov <= SMALL_SNIPERS_ZOOM) {
if(get_user_health(pPlayer) <= NeedHealth) {
if(!task_exists(pPlayer)) {
client_cmd(pPlayer, "speak %s", szSound);
set_task(fDelayToNextSound, "CTask__SendUserAudio", pPlayer, .flags = "b");
}
}
}
else {
remove_task(pPlayer);
}
}
public CTask__SendUserAudio(pPlayer)
{
if(get_user_health(pPlayer) > NeedHealth || !is_user_alive(pPlayer)) {
remove_task(pPlayer);
return;
}
new iPlayerFov = get_pdata_int(pPlayer, m_iFOV, 5);
if(iPlayerFov > SMALL_SNIPERS_ZOOM) {
remove_task(pPlayer);
return;
}
client_cmd(pPlayer, "speak %s", szSound);
}