#include <amxmodx>
#include <fakemeta>
#include <dhudmessage>
#include <reapi>
#define VIP_ACCESS ADMIN_BAN
#define TIME_FOR_INFO 5.0 // Время после смерти, через которое живые не услышат игрока
#if !defined MAX_PLAYERS
#define MAX_PLAYERS 32
#endif
#define is_user_vip(%0) (get_user_flags(%0) & VIP_ACCESS)
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)
{
if(is_user_vip(id))
{
g_iUserAlive[id] = false;
g_bBlockVoice[id] = false;
}
else
{
g_iUserAlive[id] = false;
g_bBlockVoice[id] = true;
}
}
public fwdPlayerSpawnPost(id)
{
if(is_user_vip(id)) return;
g_iUserAlive[id] = is_user_alive(id);
if(g_iUserAlive[id])
g_bBlockVoice[id] = false;
}
public fwdPlayerKilledPost(const id)
{
if(is_user_vip(id)) return;
g_iUserAlive[id] = false;
g_bBlockVoice[id] = true;
}
public SendClientMessage(id)
{
g_iUserAlive[id] = 0;
set_hudmessage(70, 150, 0, -1.0, 0.3, 1, 5.0, 5.0, 0.1, 0.5,TIME_FOR_INFO);
show_hudmessage(id, "У вас 5 секунд. на инфу");
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;
set_hudmessage(255, 100, 0, -1.0, 0.3, 1, 5.0, 5.0, 0.1, 0.5, 4);
show_hudmessage(id, "Живые товарищи по команде^n больше не слышат вас!");
}
}