What I was meant if you want to do the same thing than this
but using TE_USERTRACER, using the position from gun is perfectly fine since with the speed you won't see any difference.
Code:
#include <amxmodx>
#include <fakemeta>
#include <engine>
new gMaxClients;
enum _:Coord_e { Float:x, Float:y, Float:z };
enum _:Angle_e { Float:Pitch, Float:Yaw, Float:Roll };
#define VectorAdd(%0,%1,%2) ( %2[ x ] = %0[ x ] + %1[ x ], %2[ y ] = %0[ y ] + %1[ y ], %2[ z ] = %0[ z ] + %1[ z ] )
#define VectorMA(%0,%1,%2,%3) ( %3[ x ] = %0[ x ] + %1 * %2[ x ], %3[ y ] = %0[ y ] + %1 * %2[ y ], %3[ z ] = %0[ z ] + %1 * %2[ z ] )
#define VectorScale(%0,%1,%2) ( %2[ x ] = %1 * %0[ x ], %2[ y ] = %1 * %0[ y ], %2[ z ] = %1 * %0[ z ] )
#define write_coord_f(%0) ( engfunc( EngFunc_WriteCoord, %0 ) )
public plugin_init ()
{
register_clcmd( "tracer", "ClientCommand_ShootTracer" );
register_forward( FM_PlaybackEvent, "Forward_PlaybackEvent" );
gMaxClients = get_maxplayers();
}
public Forward_PlaybackEvent ( Flags, Invoker, EventId )
{
if ( 1 <= Invoker <= gMaxClients )
{
ClientCommand_ShootTracer( Invoker );
}
}
public ClientCommand_ShootTracer ( const Player )
{
new Float:Origin [ Coord_e ];
new Float:Velocity[ Coord_e ];
new Float:Forward [ Coord_e ];
new Float:VAngle [ Angle_e ];
UTIL_GetGunPosition( Player, Origin );
// engfunc( EngFunc_GetAttachment, Player, 0 , Origin, VAngle );
pev( Player, pev_v_angle, VAngle );
angle_vector( VAngle, ANGLEVECTOR_FORWARD, Velocity );
VectorScale( Velocity, 4096.0, Velocity );
FX_UserTracer( .Source = Origin,
.Velocity = Velocity,
.Life = 3,
.Color = 1,
.Length = 1 );
}
UTIL_GetGunPosition ( const Player, Float:Source[ Coord_e ] )
{
static Float:ViewOfs[ Coord_e ];
pev( Player, pev_origin, Source );
pev( Player, pev_view_ofs, ViewOfs );
VectorAdd( Source, ViewOfs, Source );
}
FX_UserTracer ( const Float:Source[ Coord_e ], const Float:Velocity[ Coord_e ], const Life, const Color, const Length )
{
client_print( 0, print_chat, "BANG" );
message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
write_byte( TE_USERTRACER );
write_coord_f( Source[ x ] );
write_coord_f( Source[ y ] );
write_coord_f( Source[ z ] );
write_coord_f( Velocity[ x ] );
write_coord_f( Velocity[ y ] );
write_coord_f( Velocity[ z ] );
write_byte( Life * 10 );
write_byte( Color );
write_byte( Length * 10 );
message_end();
}