void GetSpecCount(int client)
{
int count = 0;
for(int j = 1; j <= MAXPLAYERS; j++)
{
if (!IsClientInGame(j) || !IsClientObserver(j))
continue;
if (IsClientSourceTV(j))
continue;
int iSpecMode = GetEntProp(j, Prop_Send, "m_iObserverMode");
// The client isn't spectating any one person, so ignore them.
if (iSpecMode != 4 && iSpecMode != 5)
continue;
// Find out who the client is spectating.
int iTarget = GetEntPropEnt(j, Prop_Send, "m_hObserverTarget");
// Are they spectating the same player as User?
if (iTarget == client && j != client)
{
count++;
}
}
return count;
}