#include <amxmodx>
#include <reapi>
new HookChain:g_hcDefuseBombStart_Post
new g_msgBarTime
enum _:Mode
{
Mode_Disabled,
Mode_IfEnoughTime,
Mode_AlwaysOn
}
new g_iMode = Mode_Disabled
public plugin_init()
{
register_plugin( "Instant Defuse", "1.0.0", "Ayk" )
if( get_member_game(m_bMapHasBombTarget) == false )
{
log_amx( "Not a bomb/defusal scenario map. Plugin paused." )
pause( "ad" )
return;
}
bind_pcvar_num( create_cvar("instant_defuse", "1", _, "Instant defuse mode", true, 0.0, true, 2.0), g_iMode )
g_msgBarTime = get_user_msgid( "BarTime" )
RegisterHookChain( RG_CGrenade_DefuseBombStart, "DefuseBombStart_Pre", false )
g_hcDefuseBombStart_Post = RegisterHookChain( RG_CGrenade_DefuseBombStart, "DefuseBombStart_Post", true )
DisableHookChain( g_hcDefuseBombStart_Post )
}
public DefuseBombStart_Pre( const iEntity, const iPlayer )
{
if( g_iMode == Mode_Disabled )
return;
new iAliveT
rg_initialize_player_counts( iAliveT, _, _, _ )
if( iAliveT > 0 )
return;
new Float:fDefuseTime = get_member(iPlayer, m_bHasDefuser) ? 5.0 : 10.0;
new bool:bHasTime = (Float:get_member(iEntity, m_Grenade_flC4Blow) - get_gametime() > fDefuseTime)
if( g_iMode == Mode_AlwaysOn || (g_iMode == Mode_IfEnoughTime && bHasTime) )
{
set_msg_block( g_msgBarTime, BLOCK_SET )
EnableHookChain( g_hcDefuseBombStart_Post )
}
}
public DefuseBombStart_Post( const iEntity, const iPlayer )
{
set_member( iEntity, m_Grenade_flDefuseCountDown, get_gametime() )
set_msg_block( g_msgBarTime, BLOCK_NOT )
DisableHookChain( g_hcDefuseBombStart_Post )
}