#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#define PLUGIN "Bomb Defuse Predictions"
#define VERSION "1.2"
#define AUTHOR "Starsailor"
new HamHook:g_iHamForward
new g_C4Ent, g_iTime = -1
new iTime
new Float:fC4Timer
new pEnabled
new bIsEnabled
public plugin_init()
{
new szPluginName[32]
if(engfunc(EngFunc_FindEntityByString, -1, "classname","func_bomb_target") || engfunc(EngFunc_FindEntityByString, -1, "classname","info_bomb_target"))
{
register_event("BarTime", "event_defusing", "be", "1=5", "1=10")
register_logevent("logevent_bomb_planted", 3, "2=Planted_The_Bomb")
register_logevent("logevent_bomb_defused", 3, "2=Defused_The_Bomb")
register_event("HLTV","event_new_round","a","1=0","2=0")
g_iHamForward = RegisterHam(Ham_Think, "grenade", "C4_Think", 1)
pEnabled = register_cvar("bdp_enabled","1")
register_cvar("bdp_version",VERSION,FCVAR_SERVER|FCVAR_SPONLY)
format(szPluginName,charsmax(szPluginName),"%s (On)",PLUGIN)
register_dictionary("bomb_defuse_predictions.txt")
register_plugin(szPluginName,VERSION,AUTHOR)
}
else
{
format(szPluginName,charsmax(szPluginName),"%s (Off)",PLUGIN)
register_plugin(szPluginName, VERSION, AUTHOR)
pause("ad")
return
}
}
public event_defusing(id)
{
if(!bIsEnabled)
{
return
}
new Float:flTime = get_pdata_float(g_C4Ent, 99,5) - get_gametime()
if(iTime > floatround(flTime))
{
client_print(id,print_center,"%L",id,"YOU_HAVE_TIME")
}
else
{
client_print(id,print_center,"%L",id,"YOU_DONT_HAVE_TIME")
}
}
public event_new_round()
{
if((bIsEnabled = get_pcvar_num(pEnabled)) == 1)
{
DisableHamForward(g_iHamForward)
g_iTime = -1
}
}
public logevent_bomb_planted()
{
if(bIsEnabled)
{
new iC4Ent = FM_NULLENT
while((iC4Ent = engfunc(EngFunc_FindEntityByString, iC4Ent, "classname","grenade")))
{
if(get_pdata_int(iC4Ent, 96, 5) & (1<<8))
{
g_C4Ent = iC4Ent
fC4Timer = get_pdata_float(g_C4Ent, 100, 5)
EnableHamForward(g_iHamForward)
return
}
}
}
}
public logevent_bomb_defused()
{
if(bIsEnabled)
{
DisableHamForward(g_iHamForward)
}
}
public C4_Think(iC4)
{
if(g_C4Ent != iC4)
{
return
}
static Float:flTime
flTime = fC4Timer - get_gametime()
iTime = floatround(flTime, floatround_ceil)
if(g_iTime != iTime)
{
g_iTime = iTime
}
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang3082\\ f0\\ fs16 \n\\ par }
*/