#pragma semicolon 1
#include <amxmodx>
#include <fakemeta>
#include <reapi>
new const EVENTS[][] = {
"events/ak47.sc",
"events/aug.sc",
"events/awp.sc",
"events/deagle.sc",
"events/elite_left.sc",
"events/elite_right.sc",
"events/famas.sc",
"events/fiveseven.sc",
"events/g3sg1.sc",
"events/galil.sc",
"events/glock18.sc",
//"events/knife.sc",
"events/m249.sc",
//"events/m3.sc",
"events/m4a1.sc",
"events/mac10.sc",
"events/mp5n.sc",
"events/p228.sc",
"events/p90.sc",
"events/scout.sc",
"events/sg550.sc",
"events/sg552.sc",
"events/tmp.sc",
"events/ump45.sc",
"events/usp.sc",
//"events/xm1014.sc"
};
new g_beamSprite;
new g_fwd_precache_event;
new g_guns_events_bitsum = 0;
#define is_player(%1) (0 < %1 <= MaxClients)
#define is_gunshot_event(%1) (g_guns_events_bitsum & (1 << %1))
public plugin_precache()
{
g_beamSprite = precache_model("sprites/dot.spr");
g_fwd_precache_event = register_forward(FM_PrecacheEvent, "on_precache_event_post", true);
}
public on_precache_event_post(type, const szName[])
{
for (new i = 0; i < sizeof EVENTS; i++) {
if (equali(szName, EVENTS[i])) {
g_guns_events_bitsum |= (1 << get_orig_retval());
break;
}
}
}
public plugin_init()
{
register_plugin("Visual Bullets Check", "1.0.0", "the_hunter");
register_forward(FM_PlaybackEvent, "on_playback_event_post", true);
unregister_forward(FM_PrecacheEvent, g_fwd_precache_event, true);
}
public on_playback_event_post(flags, invoker, event)
{
if (!is_gunshot_event(event) || !is_player(invoker) || is_user_bot(invoker))
return;
new clip;
new weapon = get_user_weapon(invoker, clip);
new clipSize = rg_get_weapon_info(weapon, WI_GUN_CLIP_SIZE);
// If ammo left more than 20% - return
if (!clip || clip > floatround(clipSize * 0.20, floatround_ceil))
return;
static vecEndPos[3];
get_user_origin(invoker, vecEndPos, Origin_AimEndEyes);
message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, vecEndPos, invoker);
{
write_byte(TE_BEAMENTPOINT);
write_short(invoker | 0x1000); // start entity
write_coord(vecEndPos[0]); // end position X
write_coord(vecEndPos[1]); // end position Y
write_coord(vecEndPos[2]); // end position Z
write_short(g_beamSprite); // sprite index
write_byte(1); // starting frame
write_byte(5); // frame rate in 0.1's
write_byte(1); // life in 0.1's
write_byte(5); // line width in 0.1's
write_byte(0); // noise amplitude in 0.01's
write_byte(255); // red
write_byte(215); // green
write_byte(0); // blue
write_byte(200); // brightness
write_byte(150); // scroll speed in 0.1's
}
message_end();
}