#include <sdktools_engine>
#include <sdktools_functions>
#include <sdktools_trace>
#include <sdktools_tempents>
#include <sdktools_tempents_stocks>

public Plugin:myinfo = {name = "Awp Traces",author = "Danyas [autor eventscripts pluign maniek23]",description = "Script which makes AWP sniper rifle to leave nice looking bullet traces",version = "1.0"}

new tracer_fx;
public OnPluginStart(){HookEvent("weapon_fire", Event_OnWeaponFire);} //Хукаем выстрел
public OnMapStart(){tracer_fx = PrecacheModel("effects/gunshiptracer.vmt"); } //Делаем прекеш для трейсера
public Action:Event_OnWeaponFire(Handle:event, const String:name[], bool:silent)
{
	new client = GetClientOfUserId(GetEventInt(event, "userid"));
	decl String:weapon[16], Float:pos[3], Float:clientpos[3]; 
	GetEventString(event, "weapon", weapon, sizeof(weapon));
 	if (StrEqual(weapon, "awp", false)) // проверяем из какого оружия сделан выстрел
	{
		wS_GetLookPos(client, pos); //получаем позицию стреляющего + направление прицена
		GetClientEyePosition(client, clientpos); // получаем позицию направления прицела
		TE_SetupBeamPoints(clientpos, pos, tracer_fx,0,0,0,2.0,4.0,4.0,2,1.1,{125, 125, 125, 190},1); // делаем первый трейсер 
		TE_SendToAll(); // показываем его 
		TE_SetupBeamPoints(pos, clientpos, tracer_fx,0,0,0,2.0,6.0,8.0,2,0.0,{255, 255, 255, 190},6); // делаем второй трейсер 
		TE_SendToAll(); // показываем его 
	}
	return Plugin_Handled;
}

//Ty wS for that
public bool:wS_GetLookPos_Filter(ent, mask, any:client)
{ 
	return client != ent; 
}

wS_GetLookPos(client, Float:wS_Pos[3])
{
decl Float:EyePosition[3], Float:EyeAngles[3], Handle:h_trace; 
GetClientEyePosition(client, EyePosition); GetClientEyeAngles(client, EyeAngles); 
h_trace = TR_TraceRayFilterEx(EyePosition, EyeAngles, MASK_SOLID, RayType_Infinite, wS_GetLookPos_Filter, client); 
TR_GetEndPosition(wS_Pos, h_trace); CloseHandle(h_trace); 
}