#include <amxmodx>
#include <fakemeta>
#include <reapi>
#define TIME_FOR_INFO 5.0 // Время после смерти, через которое живые не услышат мертвого игрока
#if !defined MAX_PLAYERS
#define MAX_PLAYERS 32
#endif
#if AMXX_VERSION_NUM < 183
#define client_disconnected client_disconnect
#include <colorchat>
#endif
new bool:g_bBlockVoice[MAX_PLAYERS + 1];
new g_iUserAlive[MAX_PLAYERS + 1];
public plugin_init()
{
register_plugin("Time for info", "1.0", "neugomon");
RegisterHookChain(RG_CBasePlayer_Spawn, "fwdPlayerSpawnPost", true);
RegisterHookChain(RG_CBasePlayer_Killed, "fwdPlayerKilledPost", true);
register_forward(FM_Voice_SetClientListening, "FwdSetClientListening", false);
}
public client_putinserver(id)
{
g_bBlockVoice[id] = true;
g_iUserAlive[id] = false;
}
public client_disconnected(id)
remove_task(id);
public fwdPlayerSpawnPost(id)
{
g_iUserAlive[id] = is_user_alive(id);
if(g_iUserAlive[id])
g_bBlockVoice[id] = false;
}
public fwdPlayerKilledPost(const id)
{
g_iUserAlive[id] = 0;
client_print_color(id, 0, "^4[Voice] ^1У тебя есть ^3%.0f сек.^1, чтобы что-то сказать живым", TIME_FOR_INFO);
set_task(TIME_FOR_INFO, "BlockVoice", id);
}
public FwdSetClientListening(iReciever, iSender)
{
if(iSender != iReciever && g_bBlockVoice[iSender] && g_iUserAlive[iReciever])
{
engfunc(EngFunc_SetClientListening, iReciever, iSender, false);
forward_return(FMV_CELL, false);
return FMRES_SUPERCEDE;
}
return FMRES_IGNORED;
}
public BlockVoice(id)
{
if(!g_iUserAlive[id])
{
g_bBlockVoice[id] = true;
client_print_color(id, 0, "^4[Voice] ^1Время для инфы истекло. ^3Живые тебя не слышат.");
}
}