Re: Spawn a HE grenade on player.
I'm not sure if you can execute a detonation but you can create your own detonation.
PHP Code:
public plugin_init(){ //... register_forward(FM_Think, "fwd_think") //... }
// iVictim is your target ;) public JohnDoe(iVictim){ //...
// Create a fake hegrenade new iEntity = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
engfunc(EngFunc_SetModel, iEntity, "models/w_hegrenade.mdl") set_pev(iEntity, pev_classname, "fake_hegrenade") set_pev(iEntity, pev_owner, iVictim) set_pev(iEntity, pev_iuser1, 0) set_pev(iEntity, pev_mins, { -2.5, -2.5, -2.5}) set_pev(iEntity, pev_maxs, { 2.5, 2.5, 2.5}) set_pev(iEntity, pev_solid, SOLID_TRIGGER) set_pev(iEntity, pev_movetype, MOVETYPE_TOSS)
// That's your timer for the detonation set_pev(iEntity, pev_nextthink, get_gametime() + 10.0)
new Float:f_vAngles[3] = { 0.0, 0.0, 0.0} f_vAngles[1] = random_float(0.0, 180.0) set_pev(iEntity, pev_angles, f_vAngles)
new Float:f_vOrigin[3] pev(iVictim, pev_origin, f_vOrigin) f_vOrigin[0] += 10.0 engfunc(EngFunc_SetOrigin, iEntity, f_vOrigin)
//... }
public fwd_think(iEntity){ if (!pev_valid(iEntity)){ return FMRES_IGNORED }
new szClass[20] pev(iEntity, pev_classname, szClass, 19)
if (equal(szClass, "fake_hegrenade")){ func_nade_explode(iEntity) } return FMRES_IGNORED }
public func_nade_explode(iEntity){
// ... Do anything
// Remove the nade engfunc(EngFunc_RemoveEntity, iEntity) }
|