Before calling the TE_ message TE_BEAMENTPOINT, call the message TE_KILLBEAM
It should be like this:
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <engine>
#include <xs>
new sprite;
public plugin_init()
{
register_plugin("Laser Beam", "1.0", "stupok")
register_forward(FM_PlayerPreThink, "fw_playerprethink")
}
public plugin_precache()
{
sprite = precache_model("sprites/laserbeam.spr");
}
public fw_playerprethink(id)
{
show_beam(id)
}
public show_beam(id)
{
static Float:fStart[3], Float:fEnd[3];
static tr;
pev(id, pev_origin, fStart)
velocity_by_aim(id, 9999, fEnd)
xs_vec_add(fStart, fEnd, fEnd)
trace_line(id, fStart, fEnd, fEnd)
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
write_byte(TE_KILLBEAM)
write_short(id)
message_end()
message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
write_byte(1);
write_short(id | 0x1000); // start entity
engfunc(EngFunc_WriteCoord, fEnd[0])
engfunc(EngFunc_WriteCoord, fEnd[1])
engfunc(EngFunc_WriteCoord, fEnd[2])
write_short(sprite); // sprite index
write_byte(0); // starting frame
write_byte(0); // frame rate in 0.1's
write_byte(1); // life in 0.1's
write_byte(10); // line wdith in 0.1's
write_byte(0); // noise amplitude in 0.01's
write_byte(0); // red
write_byte(0); // green
write_byte(255); // blue
write_byte(255); // brightness
write_byte(255); // scroll speed in 0.1's
message_end();
return PLUGIN_HANDLED;
}
Btw, I optimized it.
__________________