Hello, I've done a laser sight, it's working but with some problems. As the item_PostFrame is called many times per second, they are appearing 4 lasers instead of just one. Any suggestions?
Code:
public fw_Item_PostFrame(entity)
{
if (!is_valid_ent(entity))
return HAM_IGNORED;
static id
id = get_pdata_cbase(entity, OFFSET_WEAPONOWNER, OFFSET_LINUX_WEAPONS)
if (!is_user_alive(id))
return HAM_IGNORED;
if (!GetPlayerBit(g_has_plasma_caster, id))
return HAM_IGNORED;
static Float:victim_origin[3], victim
victim = get_aim_ent(id, victim_origin)
static Float:origin[3]
GetGunPosition(id, 3.0, -9.0, 0.0, origin)
static end[3]
if (victim)
FVecIVec(victim_origin, end)
else
get_user_origin(id, end, 3)
message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, id)
write_byte(TE_BEAMPOINTS)
write_coord(floatround(origin[0]))
write_coord(floatround(origin[1]))
write_coord(floatround(origin[2]))
write_coord(end[0])
write_coord(end[1])
write_coord(end[2])
write_short(sprite_laser)
write_byte(0)
write_byte(10)
write_byte(1)
write_byte(5)
write_byte(0)
write_byte(200)
write_byte(0)
write_byte(0)
write_byte(200)
write_byte(10)
message_end()
return HAM_IGNORED;
}
__________________