Try this
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
new amxx_touch_explode_he
new amxx_touch_explode_fb
new amxx_touch_explode_sg
public plugin_init()
{
register_plugin("PLUGIN", "VERSION", "AUTHOR")
amxx_touch_explode_he = register_cvar("amxx_touch_explode_he","1")
amxx_touch_explode_fb = register_cvar("amxx_touch_explode_fb","1")
amxx_touch_explode_sg = register_cvar("amxx_touch_explode_sg","1")
RegisterHam(Ham_Touch,"grenade","cmd_touch")
}
public cmd_touch(this)
{
new cvar;
switch(Get_Grenade_Type(this, false))
{
case CSW_HEGRENADE: cvar = amxx_touch_explode_he;
case CSW_FLASHBANG: cvar = amxx_touch_explode_fb;
case CSW_SMOKEGRENADE: cvar = amxx_touch_explode_sg;
}
if(cvar && get_pcvar_num(cvar))
{
set_pev(this, pev_dmgtime, 0.0)
}
}
Get_Grenade_Type( ent, bool:bCheckClass = true )
{
const m_bIsC4 = 385;
const m_usEvent_Grenade = 228;
if( bCheckClass )
{
new class[9]
pev(ent, pev_classname, class, charsmax(class))
if( !equal(class, "grenade") )
{
return 0
}
}
if( get_pdata_bool(ent, m_bIsC4) )
{
return CSW_C4
}
new usEvent = get_pdata_int(ent, m_usEvent_Grenade)
if( !usEvent )
{
return CSW_FLASHBANG
}
static m_usHgrenExplo, m_usSmokeExplo
if( !m_usHgrenExplo )
{
m_usHgrenExplo = engfunc(EngFunc_PrecacheEvent, 1, "events/createexplo.sc")
m_usSmokeExplo = engfunc(EngFunc_PrecacheEvent, 1, "events/createsmoke.sc")
}
return usEvent == m_usHgrenExplo ? CSW_HEGRENADE : CSW_SMOKEGRENADE
}
#define SHORT_BYTES 2
#define INT_BYTES 4
#define 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 get_pdata_short(ent, shortbased_offset, intbase_linuxdiff = 5)
{
return ( get_pdata_int(ent, shortbased_offset / SHORT_BYTES, intbase_linuxdiff)>>((shortbased_offset % SHORT_BYTES) * BYTE_BITS) ) & 0xFFFF
}