#pragma semicolon 1
#include <amxmodx>
#include <reapi>
#define TIME_BLOCK_VOICE_CHAT 120.0
new Float:g_flTimeReuseHear[MAX_PLAYERS + 1];
new HookChain:g_iForward_CanPlayerHearPlayer_Pre;
public plugin_init()
{
register_plugin("Block All Chats On Map Start", "1.0", "Ноунейм");
register_clcmd("say", "@Command_Say");
register_clcmd("say_team", "@Command_Say");
g_iForward_CanPlayerHearPlayer_Pre = RegisterHookChain(RG_CSGameRules_CanPlayerHearPlayer, "@CCSGameRules_CanPlayerHearPlayer_Pre", false);
}
@Command_Say(const iPlayer)
{
new Float:flTime = get_gametime();
if (flTime < TIME_BLOCK_VOICE_CHAT)
{
client_print(iPlayer, print_chat, "Чат запрещен ещё %.0f секунд", TIME_BLOCK_VOICE_CHAT - flTime);
return PLUGIN_HANDLED_MAIN;
}
return HC_CONTINUE;
}
@CCSGameRules_CanPlayerHearPlayer_Pre(const iListener, const iSender)
{
new Float:flTime = get_gametime();
if (flTime < TIME_BLOCK_VOICE_CHAT)
{
if (g_flTimeReuseHear[iSender] < flTime)
client_print(iSender, print_chat, "Запрещено говорить в начале карты. Осталось: %.0f секунд", TIME_BLOCK_VOICE_CHAT - flTime);
g_flTimeReuseHear[iSender] = flTime + 1.0;
SetHookChainReturn(ATYPE_INTEGER, false);
return HC_BREAK;
}
DisableHookChain(g_iForward_CanPlayerHearPlayer_Pre);
return HC_CONTINUE;
}