Experimental version with new forwards and natives :
Make sure you have latest cstrike_pdata includes files, some weapon_c4 pdatas were missing, i've edited attachment today.
.: Forwards :.
Code:
// C4 forwards
forward OnC4C4Touch(ent, pOther);
forward OnC4C4Think(ent);
forward OnC4Detonate2(ent);
forward OnC4Smoke2(ent);
.: Natives :.
Code:
// Returns C4Think index // C4
native Get_C4_C4Think();
// Returns Detonate2 index // C4
native Get_C4_Detonate2();
// Returns C4Touch index // C4
native Get_C4_C4Touch();
// Returns Smoke2 index // C4
native Get_C4_Smoke2();
.: Test Plugin :.
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <nades_api>
#tryinclude <cstrike_pdatas>
#if !defined _cbaseentity_included
#assert Cstrike Pdatas and Offsets library required! Read the below instructions: \
1. Download it at forums.alliedmods.net/showpost.php?p=1712101#post1712101 \
2. Put it into amxmodx/scripting/include/ folder \
3. Compile this plugin locally, details: wiki.amxmodx.org/index.php/Compiling_Plugins_%28AMX_Mod_X%29 \
4. Install compiled plugin, details: wiki.amxmodx.org/index.php/Configuring_AMX_Mod_X#Installing
#endif
#define PLUGIN ""
#define VERSION "0.0.1"
#define GetThink(%0) get_pdata_int(%0, m_pfnThink, 0)
#define GetTouch(%0) get_pdata_int(%0, m_pfnTouch, 1)
#define GetUse(%0) get_pdata_int(%0, m_pfnUse, 2)
#define GetBlocked(%0) get_pdata_int(%0, m_pfnBlocked, 3)
#define GetCallWhenMoveDone(%0) get_pdata_int(%0, m_pfnCallWhenMoveDone, 4)
#define SetThink(%0,%1) set_pdata_int(%0, m_pfnThink, %1, 0)
#define SetTouch(%0,%1) set_pdata_int(%0, m_pfnTouch, %1, 1)
#define SetUse(%0,%1) set_pdata_int(%0, m_pfnUse, %1, 2)
#define SetBlocked(%0,%1) set_pdata_int(%0, m_pfnBlocked, %1, 3)
#define SetCallWhenMoveDone(%0,%1) set_pdata_int(%0, m_pfnCallWhenMoveDone, %1, 4)
new SG_Detonate, Detonate2, Detonate3
new g_iEvent_CreateSmoke
public plugin_init()
{
register_plugin( PLUGIN, VERSION, "ConnorMcLeod" )
g_iEvent_CreateSmoke = engfunc(EngFunc_PrecacheEvent, 1, "events/createsmoke.sc")
}
public plugin_cfg()
{
SG_Detonate = Get_Nade_SG_Detonate()
Detonate2 = Get_C4_Detonate2()
Detonate3 = Get_Nade_Detonate3()
}
public OnFlashNadeDetonate( ent )
{
if( pev(ent, pev_flags) & FL_ONGROUND )
{
ExecuteHam(Ham_Think, ent) // make explode as flash
SetThink(ent, Detonate3)
ExecuteHam(Ham_Think, ent) // make explode as HE
SetThink(ent, SG_Detonate)
set_pdata_short(ent, m_usEvent_Grenade, g_iEvent_CreateSmoke) // set Smoke explosion so on this think game makes it explode as a smoke grenade
return PLUGIN_CONTINUE
}
set_pev(ent, pev_nextthink, get_gametime() + 0.1)
return PLUGIN_HANDLED
}
public OnHeNadeDetonate( ent )
{
SetThink(ent, Detonate2) // make HE detonate as planted c4 (terminates round on de_ maps)
}