This repository was archived by the owner on Jul 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathins_spotter.sp
More file actions
119 lines (103 loc) · 3.21 KB
/
ins_spotter.sp
File metadata and controls
119 lines (103 loc) · 3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
public Plugin:myinfo = {
name = "[INS] Spotter Perk",
description = "Spotter perk",
author = "Neko-",
version = "1.0.1",
};
new g_iPlayerEquipGear;
int g_nSpotterID = 29;
new bool:g_nPlayerCanBeMark[MAXPLAYERS+1] = {true, ...};
public OnPluginStart()
{
//Find player gear offset
g_iPlayerEquipGear = FindSendPropInfo("CINSPlayer", "m_EquippedGear");
HookEvent("player_pick_squad", Event_PlayerPickSquad_Post, EventHookMode_Post);
}
public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon, &nSubType, &nCmdNum, &nTickCount, &nSeed)
{
if((!IsFakeClient(client)) && (IsPlayerAlive(client)))
{
int nSpotterItemID = GetEntData(client, g_iPlayerEquipGear + (4 * 4));
if(nSpotterItemID == g_nSpotterID)
{
int nTargetView = getClientViewClient(client);
int nTargetAim = GetClientAimTarget(client, true);
if((nTargetView == nTargetAim) && (GetClientTeam(client) != GetClientTeam(nTargetAim)) && (IsPlayerAlive(nTargetAim)) && (g_nPlayerCanBeMark[nTargetAim]))
{
int nValue = GetEntProp(nTargetAim, Prop_Send, "m_bGlowEnabled");
if(!nValue)
{
SetEntProp(nTargetAim, Prop_Send, "m_bGlowEnabled", true);
CreateTimer(3.0, Timer_RemoveGlowTarget, nTargetAim);
}
}
}
}
}
public OnClientPostAdminCheck(client)
{
g_nPlayerCanBeMark[client] = true;
}
public OnClientDisconnect(client)
{
g_nPlayerCanBeMark[client] = true;
}
public Event_PlayerPickSquad_Post(Handle:event, const String:name[], bool:dontBroadcast )
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
decl String:class_template[64];
GetEventString(event, "class_template",class_template,sizeof(class_template));
//Bot class imposter (To prevent bot with this class from getting mark)
if(StrContains(class_template, "imposter") > -1)
{
g_nPlayerCanBeMark[client] = false;
}
}
public Action:Timer_RemoveGlowTarget(Handle:Timer, any client)
{
int nValue = GetEntProp(client, Prop_Send, "m_bGlowEnabled");
if(IsValidClient(client) && IsPlayerAlive(client) && (nValue))
{
SetEntProp(client, Prop_Send, "m_bGlowEnabled", false);
}
}
stock int getClientViewClient(int client) {
float m_vecOrigin[3];
float m_angRotation[3];
GetClientEyePosition(client, m_vecOrigin);
GetClientEyeAngles(client, m_angRotation);
Handle tr = TR_TraceRayFilterEx(m_vecOrigin, m_angRotation, MASK_VISIBLE, RayType_Infinite, TraceEntityFilter:FilterOutPlayer, client);
int pEntity = -1;
if (TR_DidHit(tr)) {
pEntity = TR_GetEntityIndex(tr);
delete tr;
if (!IsValidClient(client))
return -1;
if (!IsValidEntity(pEntity))
return -1;
float playerPos[3];
float entPos[3];
GetClientAbsOrigin(client, playerPos);
GetEntPropVector(pEntity, Prop_Data, "m_vecOrigin", entPos);
return pEntity;
}
delete tr;
return -1;
}
public bool:FilterOutPlayer(entity, contentsMask, any:data)
{
if (entity == data)
{
return false;
}
return true;
}
bool:IsValidClient(client)
{
if ( !( 1 <= client <= MaxClients ) || !IsClientInGame(client) )
return false;
return true;
}