#include amxmodx
#include map_manager
#include reapi
new pcvar_c4timer, g_c4timer, ent_c4, count;
new bool:is_planted = false, bool:is_extend = false, bool:is_defusing = false;
public plugin_init()
{
register_plugin("C4 Timer", "0.1", "phe");
RegisterHookChain(RG_RoundEnd, "RoundEndPost", 1);
RegisterHookChain(RG_PlantBomb, "PlantBombPost", 1);
RegisterHookChain(RG_CGrenade_DefuseBombStart, "DefuseBombStart", 1);
pcvar_c4timer = get_cvar_pointer("mp_c4timer");
}
public DefuseBombStart()
{
is_defusing = true;
}
public RoundEndPost()
{
g_c4timer = -1;
count = 0;
remove_task(9991);
is_planted = false;
}
public PlantBombPost()
{
is_planted = true;
g_c4timer = get_pcvar_num(pcvar_c4timer);
ent_c4 = rg_find_ent_by_class(ent_c4, "grenade");
C4TimerCount();
set_task(1.0, "C4TimerCount", 9991, .flags="b");
}
public C4TimerCount()
{
if(!is_planted)
{
remove_task(9991);
return;
}
if(is_vote_started() && !is_defusing)
{
++count;
set_dhudmessage(100, 100, 100, -1.0, 0.65, 0, 1.0, 1.0, 0.01, 0.01);
show_dhudmessage(0,"Бомба взорвётся через: [PAUSED]");
return;
}
if(is_vote_finished())
{
if(!is_extend)
{
new Float:time = get_member(ent_c4, m_Grenade_flC4Blow);
set_member(ent_c4, m_Grenade_flC4Blow, time + count);
}
is_extend = true;
}
if(g_c4timer >= 0)
{
switch(g_c4timer)
{
case 0..8: set_dhudmessage(255, 0, 0, -1.0, 0.65, 0, 1.0, 1.0, 0.01, 0.01);
case 9..14: set_dhudmessage(255, 100, 0, -1.0, 0.65, 0, 1.0, 1.0, 0.01, 0.01);
case 15..59: set_dhudmessage(0, 255, 255, -1.0, 0.65, 0, 1.0, 1.0, 0.01, 0.01);
}
show_dhudmessage(0, "Бомба взорвётся через: [%d]", --g_c4timer);
}
}