#include amxmodx
#include map_manager
#include reapi
new iEnt, bool:is_planted = false; //, bool:is_defusing = false;
new Float:g_ExplodeTime, /*Float:g_NextBeepTime,*/ Float:g_C4timer, Float:g_C4int, Float:g_C4beep;
public plugin_init()
{
register_plugin("C4 Timer", "-", "-");
RegisterHookChain(RG_PlantBomb, "PlantBombPost", 1);
//RegisterHookChain(RG_CGrenade_DefuseBombStart, "DefuseBombPost", 1);
RegisterHookChain(RG_RoundEnd, "RoundEndPost", 1);
RegisterHookChain(RG_CSGameRules_RestartRound, "RoundStartPost", 1);
}
public RoundStartPost()
{
is_planted = false;
remove_task(9991);
}
public RoundEndPost()
{
remove_task(9991);
}
/*public DefuseBombPost()
{
is_defusing = true;
}*/
public PlantBombPost()
{
is_planted = true;
iEnt = GetHookChainReturn(ATYPE_INTEGER);
g_ExplodeTime = get_member(iEnt, m_Grenade_flC4Blow);
//g_NextBeepTime = get_member(iEnt, m_Grenade_flNextBeep);
C4timerCount();
set_task(1.0, "C4timerCount", 9991, .flags="b");
}
public C4timerCount()
{
if(!is_planted)
{
remove_task(9991);
return;
}
/*if(is_vote_started() && !is_defusing)
{
g_ExplodeTime++; g_NextBeepTime++;
set_member(iEnt, m_Grenade_flC4Blow, g_ExplodeTime);
set_member(iEnt, m_Grenade_flNextBeep, g_NextBeepTime);
set_dhudmessage(100, 100, 100, -1.0, 0.65, 0, 1.0, 1.0, 0.01, 0.01);
show_dhudmessage(0, "Бомба взорвётся через: [%0.f] %0.f %0.f", get_member(iEnt, m_Grenade_flC4Blow), get_member(iEnt, m_Grenade_flNextBeep), get_member(iEnt, m_Grenade_flNextFreqInterval));
return;
}*/
g_C4timer = g_ExplodeTime - get_gametime();
g_C4int = get_member(iEnt, m_Grenade_flNextFreqInterval);
g_C4beep = get_member(iEnt, m_Grenade_flNextBeep);
//if(g_C4timer <= 0)
// return;
set_dhudmessage(100, 100, 100, -1.0, 0.65, 0, 1.0, 1.0, 0.01, 0.01);
show_dhudmessage(0, "Бомба взорвётся через: [%0.f] beep: %0.f, int: %0.f ", g_C4timer, g_C4beep, g_C4int);
}