I'm using the throw knife entity code from throwing knives plugin.
the problem is when i type /throw, sometimes it throw's a knife and sometimes no.
Why is that?
This is the code:
PHP Code:
public ThrowKnife( iIndex )
{
static Float:flOrigin[ 3 ], Float:flVelocity[ 3 ], Float:flAngles[ 3 ], iEnt;
entity_get_vector( iIndex, EV_VEC_origin, flOrigin );
entity_get_vector( iIndex, EV_VEC_v_angle, flAngles );
iEnt = create_entity( "info_target" );
if( !is_valid_ent( iEnt ) )
{
return;
}
entity_set_string( iEnt, EV_SZ_classname, KNIFE_ENT );
entity_set_model( iEnt, KNIFE_MODEL );
entity_set_size( iEnt, Float:{ -1.0, -7.0, -1.0 }, Float:{ 1.0, 7.0, 1.0 } );
entity_set_origin( iEnt, flOrigin );
flAngles[ 0 ] -= 90.0;
entity_set_vector( iEnt, EV_VEC_angles, flAngles );
entity_set_int( iEnt, EV_INT_effects, 32 );
entity_set_int( iEnt, EV_INT_solid, SOLID_TRIGGER );
entity_set_int( iEnt, EV_INT_movetype, MOVETYPE_TOSS );
entity_set_edict( iEnt, EV_ENT_owner, iIndex );
set_rendering( iEnt, kRenderFxGlowShell, 0, 250, 0, kRenderNormal, 25 );
VelocityByAim( iIndex, KNIFE_SPEED, flVelocity );
entity_set_vector( iEnt, EV_VEC_velocity, flVelocity );
}
In the touch forward i just removed the entity with remove_entity( iEntity );
Thanks for help!