#include <amxmodx>
#include <fakemeta>
#if !defined MAX_NAME_LENGTH
const MAX_NAME_LENGTH = 32
#endif
new g_bomb_icon, bomb_icon[MAX_NAME_LENGTH]
#define fm_find_ent_by_class(%1,%2) engfunc(EngFunc_FindEntityByString, %1, "classname", %2)
public plugin_init()
{
if (fm_find_ent_by_class(FM_NULLENT, "info_bomb_target") || fm_find_ent_by_class(FM_NULLENT, "func_bomb_target"))
{
register_plugin("C4 Timer [ON]", "1.0", "AcE")
g_bomb_icon = register_cvar("c4_bomb_icon", "bombticking")
server_cmd("exec addons/amxmodx/configs/c4_timer.cfg"); server_exec()
get_pcvar_string(g_bomb_icon, bomb_icon, charsmax(bomb_icon))
register_logevent("EventPlantedTheBomb", 3, "2=Planted_The_Bomb")
register_event("SendAudio", "EventSendAudio", "a", "1=0", "2=%!MRAD_BOMBDEF")
}
else
{
register_plugin("C4 Timer [OFF]", "1.0", "AcE")
pause("a")
}
}
public EventPlantedTheBomb()
{
static g_ShowTimer
if (g_ShowTimer || (g_ShowTimer = get_user_msgid("ShowTimer")))
{
message_begin(MSG_BROADCAST, g_ShowTimer)
message_end()
}
static g_RoundTime, g_C4Timer
g_C4Timer = get_cvar_num("mp_c4timer")
if (g_RoundTime || (g_RoundTime = get_user_msgid("RoundTime")))
{
message_begin(MSG_BROADCAST, g_RoundTime)
write_short(g_C4Timer +1)
message_end()
}
static g_Scenario
if (g_Scenario || (g_Scenario = get_user_msgid("Scenario")))
{
message_begin(MSG_BROADCAST, g_Scenario)
write_byte(1)
write_string(bomb_icon)
write_byte(150)
write_short(20)
message_end()
}
}
public EventSendAudio()
{
static g_SendAudio
if (g_SendAudio || (g_SendAudio = get_user_msgid("SendAudio")))
{
if (get_msg_block(g_SendAudio) == BLOCK_NOT)
set_msg_block(g_SendAudio, BLOCK_ONCE)
}
}