#pragma semicolon 1
#include <amxmodx>
#include <reapi>
#define DECOY_IMPULSE 1337
#define HEALTH_IMPULSE 4545
#define MOLOTOV_IMPULSE 7691
new g_iModelIndex_LaserBeam;
public plugin_init()
{
register_plugin("Team Grenade Trails", "1.0.0", "fl0wer");
RegisterHookChain(RG_ThrowHeGrenade, "@ThrowHeGrenade_Post", true);
RegisterHookChain(RG_ThrowFlashbang, "@ThrowFlashbang_Post", true);
RegisterHookChain(RG_ThrowSmokeGrenade, "@ThrowSmokeGrenade_Post", true);
}
public plugin_precache()
{
g_iModelIndex_LaserBeam = precache_model("sprites/laserbeam.spr");
}
@ThrowHeGrenade_Post(id)
{
ThrowGrenade_TeamTrail(id, { 255, 0, 0 });
}
@ThrowFlashbang_Post(id)
{
ThrowGrenade_TeamTrail(id, { 255, 255, 255 });
}
@ThrowSmokeGrenade_Post(id)
{
ThrowGrenade_TeamTrail(id, { 0, 255, 0 });
}
ThrowGrenade_TeamTrail(id, color[3])
{
new entity = GetHookChainReturn(ATYPE_INTEGER);
if (is_nullent(entity))
return;
switch(get_entvar(entity, var_impulse)) {
case DECOY_IMPULSE: {
color[0] = 255;
color[1] = 0;
color[2] = 255;
}
case MOLOTOV_IMPULSE: {
color[0] = 255;
color[1] = 150;
color[2] = 0;
}
case HEALTH_IMPULSE: {
color[0] = 255;
color[1] = 150;
color[2] = 150;
}
}
new TeamName:team = get_member(id, m_iTeam);
for (new i = 1; i <= MaxClients; i++)
{
if (!is_user_connected(i))
continue;
if (get_member(i, m_iTeam) != team)
continue;
message_begin_f(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, i);
TE_BeamFollow(entity, g_iModelIndex_LaserBeam, 3, 10, color, 150);
}
}
TE_BeamFollow(entity, spriteIndex, life, lineWidth, color[3], brightness)
{
write_byte(TE_BEAMFOLLOW);
write_short(entity);
write_short(spriteIndex);
write_byte(life);
write_byte(lineWidth);
write_byte(color[0]);
write_byte(color[1]);
write_byte(color[2]);
write_byte(brightness);
message_end();
}