#pragma semicolon 1
#pragma newdecls required
#include <sdktools_trace>
#include <sdktools_tempents>
#include <sdktools_tempents_stocks>
#include <sdktools_engine>
#include <sdktools_functions>
int iTracer;
public Plugin myinfo =
{
name = "Trace Dead",
author = "Kr3sh",
description = "Tracer bullet for dead player",
version = "1.1 FiX",
url = "https://t.me/kr3sh"
};
public void OnPluginStart()
{
HookEvent("player_death", Event_PlayerDeath, EventHookMode_Post);
}
public void OnMapStart()
{
iTracer = PrecacheModel("effects/gunshiptracer.vmt");
}
public void Event_PlayerDeath(Event hEvent, const char[] sEvName, bool bDontBroadcast)
{
int client = GetClientOfUserId(hEvent.GetInt("userid"));
int attacker = GetClientOfUserId(hEvent.GetInt("attacker"));
if(!IsClientValid(client) || IsClientValid(attacker) || client == attacker)
return;
float fPosClient[3], fPosAttacker[3];
Trace_GetLookPos(attacker, fPosClient);
GetClientEyePosition(attacker, fPosAttacker);
TE_SetupBeamPoints(fPosAttacker, fPosClient, iTracer,0,0,0,2.0,4.0,4.0,2,1.1,{125, 125, 125, 190},1);
TE_SendToClient(client);
TE_SetupBeamPoints(fPosClient, fPosAttacker, iTracer,0,0,0,2.0,6.0,8.0,2,0.0,{255, 255, 255, 190},6);
TE_SendToClient(client);
}
static void Trace_GetLookPos(int client, float fPos[3])
{
Handle hTrace;
float EyePosition[3], EyeAngles[3];
GetClientEyePosition(client, EyePosition);
GetClientEyeAngles(client, EyeAngles);
hTrace = TR_TraceRayFilterEx(EyePosition, EyeAngles, MASK_SOLID, RayType_Infinite, Trace_GetLookPos_Filter, client);
TR_GetEndPosition(fPos, hTrace);
delete hTrace;
}
public bool Trace_GetLookPos_Filter(int ent, int mask, int client)
{
return client != ent;
}
static bool IsClientValid(int client)
{
return 0 < client <= MaxClients && IsClientInGame(client);
}