Here is a stock that does what you want:
PHP Code:
StopDefuser()
{
const m_pBombDefuser = 388
const m_bIsC4 = 385
const m_bJustBlew = 432
const m_bStartDefuse = 384
const m_bIsDefusing = 929
const m_flDefuseCountDown = 99
static gmsgBarTime
if(!gmsgBarTime)
{
gmsgBarTime = get_user_msgid("BarTime")
}
new GrenadeEntity = FM_NULLENT
while((GrenadeEntity = engfunc(EngFunc_FindEntityByString, GrenadeEntity, "classname", "grenade")))
{
if(pev_valid(GrenadeEntity) && get_pdata_bool(GrenadeEntity, m_bIsC4))
{
if(!get_pdata_bool(GrenadeEntity, m_bJustBlew))
{
new DefuserIndex
if(is_user_connected((DefuserIndex = get_pdata_ent(GrenadeEntity, m_pBombDefuser))))
{
set_pdata_bool(DefuserIndex, m_bIsDefusing, false)
set_pdata_bool(DefuserIndex, m_bStartDefuse, false)
message_begin(MSG_ONE, gmsgBarTime, _, DefuserIndex)
{
write_short(0)
message_end()
}
engclient_cmd(DefuserIndex, "lastinv")
engclient_cmd(DefuserIndex, "lastinv")
}
}
}
}
}
For amxx < 183 you also need this function in order to get it working:
PHP Code:
#if AMXX_VERSION_NUM < 183
const INT_BYTES = 4
const BYTE_BITS = 8
stock bool:get_pdata_bool(ent, charbased_offset, intbase_linuxdiff = 5)
{
return !!(get_pdata_int(ent, charbased_offset / INT_BYTES, intbase_linuxdiff) & (0xFF<<((charbased_offset % INT_BYTES) * BYTE_BITS)))
}
stock set_pdata_bool(ent, charbased_offset, _:value, intbase_linuxdiff = 5)
{
value &= 0xFF
new int_offset_value = get_pdata_int(ent, charbased_offset / INT_BYTES, intbase_linuxdiff)
new bit_decal = (charbased_offset % INT_BYTES) * BYTE_BITS
int_offset_value &= ~(0xFF<<bit_decal) // clear byte
int_offset_value |= value<<bit_decal
set_pdata_int(ent, charbased_offset / INT_BYTES, int_offset_value, intbase_linuxdiff)
}
#endif
Just call StopDefuser() and it will automatically check if there's a player defusing and stop him.
__________________