I'm using this code to spawn a grenade.
PHP Code:
int entity = CreateEntityByName("hegrenade_projectile");
SetEntProp(entity, Prop_Data, "m_takedamage", 2);
SetEntProp(entity, Prop_Data, "m_iMaxHealth", 1);
SetEntProp(entity, Prop_Data, "m_iHealth", 1);
SetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity", client);
SetEntPropEnt(entity, Prop_Data, "m_hThrower", client);
SetEntProp(entity, Prop_Data, "m_iTeamNum", GetClientTeam(client));
SetEntPropFloat(entity, Prop_Data, "m_flDamage", 200.0);
SetEntPropFloat(entity, Prop_Data, "m_DmgRadius", 350.0);
SetEntPropFloat(entity, Prop_Send, "m_flElasticity", 0.0);
TeleportEntity(entity, grenadeloc, NULL_VECTOR, fVelocity);
DispatchSpawn(entity);
And I detonate it with
PHP Code:
SDKHooks_TakeDamage(entity, 0, 0, 1.0);
The problem is when it hits someone the server crashes, but when it hits no one it explodes normally (like a real grenade).
What did I missed?
Edit:
I fixed it.
For anyone who wants:
PHP Code:
int ent_explosion = CreateEntityByName("env_explosion");
SetEntProp(ent_explosion, Prop_Data, "m_iMagnitude", 99);
SetEntProp(ent_explosion, Prop_Data, "m_iRadiusOverride", 250);
SetEntPropFloat(ent_explosion, Prop_Data, "m_flDamageForce", 99.0);
SetEntPropEnt(ent_explosion, Prop_Data, "m_hInflictor", owner);
SetEntPropEnt(ent_explosion, Prop_Data, "m_hOwnerEntity", owner);
DispatchKeyValue(ent_explosion, "rendermode", "5");
DispatchKeyValue(ent_explosion, "spawnflags", "2");
DispatchKeyValue(ent_explosion, "classname", "weapon_hegrenade");
DispatchSpawn(ent_explosion);
TeleportEntity(ent_explosion, fOrigin, NULL_VECTOR, NULL_VECTOR);
AcceptEntityInput(ent_explosion, "Explode");
AcceptEntityInput(ent_explosion, "Kill");