When a zombie dies this plugin creating an explosion that should knock back humans.
The problem is that this sometimes happens(knock back humans), but not often(one in ten attempts approximately)but you should always happen when humans are in explode radius.
Does anyone know what could be the problem?
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <biohazard>
#define SOUND2 "garg/gar_stomp1.wav"
#define is_player(%0) (1 <= %0 <= giMaxplayers)
new cvar_radius, g_exploSpr, giMaxplayers
public plugin_precache( )
{
g_exploSpr = engfunc(EngFunc_PrecacheModel, "sprites/shockwave.spr")
precache_sound(SOUND2)
}
public plugin_init( )
{
register_plugin( "Zombie Explode", "1.0", "Krtola" )
register_event( "DeathMsg", "event_DeathMsg", "a" )
cvar_radius = register_cvar("zombie_explode_radius", "999.0")
giMaxplayers = get_maxplayers()
}
public event_DeathMsg( )
{
new id = read_data( 2 )
if( !is_user_connected( id ) || !is_user_zombie( id ) )
return PLUGIN_HANDLED
static Ent, Float: originF[3]
pev(id, pev_origin, originF)
static Float: ioriginF[3]
client_cmd(0, "spk %s", SOUND2)
create_blast(originF)
while( (Ent = engfunc(EngFunc_FindEntityInSphere, Ent, originF, get_pcvar_float(cvar_radius))) )
{
if(is_player(Ent) && Ent != id)
{
if(is_user_zombie(Ent))
return PLUGIN_CONTINUE
pev(Ent, pev_origin, ioriginF)
originF[0] = (ioriginF[0] - originF[0]) * 10.0
originF[1] = (ioriginF[1] - originF[1]) * 10.0
originF[2] = (ioriginF[2] - originF[2]) + 500.0
set_pev(Ent, pev_velocity, originF)
}
}
return PLUGIN_HANDLED
}
create_blast(const Float:originF[3])
{
// Medium ring
engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
write_byte(TE_BEAMCYLINDER) // TE id
engfunc(EngFunc_WriteCoord, originF[0]) // x
engfunc(EngFunc_WriteCoord, originF[1]) // y
engfunc(EngFunc_WriteCoord, originF[2]) // z
engfunc(EngFunc_WriteCoord, originF[0]) // x axis
engfunc(EngFunc_WriteCoord, originF[1]) // y axis
engfunc(EngFunc_WriteCoord, originF[2]+199.0) // z axis
write_short(g_exploSpr) // sprite
write_byte(0) // startframe
write_byte(0) // framerate
write_byte(6) // life
write_byte(40) // width
write_byte(20) // noise
write_byte(255) // red
write_byte(0) // green
write_byte(0) // blue
write_byte(200) // brightness
write_byte(0) // speed
message_end()
// Largest ring
engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
write_byte(TE_BEAMCYLINDER) // TE id
engfunc(EngFunc_WriteCoord, originF[0]) // x
engfunc(EngFunc_WriteCoord, originF[1]) // y
engfunc(EngFunc_WriteCoord, originF[2]) // z
engfunc(EngFunc_WriteCoord, originF[0]) // x axis
engfunc(EngFunc_WriteCoord, originF[1]) // y axis
engfunc(EngFunc_WriteCoord, originF[2]+299.0) // z axis
write_short(g_exploSpr) // sprite
write_byte(0) // startframe
write_byte(0) // framerate
write_byte(6) // life
write_byte(40) // width
write_byte(20) // noise
write_byte(255) // red
write_byte(0) // green
write_byte(0) // blue
write_byte(100) // brightness
write_byte(0) // speed
message_end()
// Luz Dinamica
engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
write_byte(TE_DLIGHT) // TE id
engfunc(EngFunc_WriteCoord, originF[0]) // x
engfunc(EngFunc_WriteCoord, originF[1]) // y
engfunc(EngFunc_WriteCoord, originF[2]) // z
write_byte(25) // radio
write_byte(250) // red
write_byte(250) // green
write_byte(250) // blue
write_byte(50) // vida en 0.1, 30 = 3 segundos
write_byte(50) // velocidad de decaimiento
message_end()
}