enum
{
SPECMODE_FIRSTPERSON = 4,
SPECMODE_3RDPERSON
};
...
public Action Timer_UpdateHudHint(Handle timer, any client)
{
int iSpecMode;
static char szText[254];
szText[0] = '\0';
// Dealing with a client who is in the game and playing.
if(IsPlayerAlive(client))
{
for(int i = 1; i <= MaxClients; i++)
{
if(!IsClientInGame(i) || !IsClientObserver(i)) continue;
// The 'client' is not an admin and do not display admins is enabled and the client (i) is an admin, so ignore them.
if(!IsPlayerAdmin(client) && g_bNoAdmins && IsPlayerAdmin(i)) continue;
iSpecMode = GetEntProp(i, Prop_Send, "m_iObserverMode");
// The client isn't spectating any one person, so ignore them.
if(iSpecMode != SPECMODE_FIRSTPERSON && iSpecMode != SPECMODE_3RDPERSON) continue;
// Find out who the client is spectating.
// Are they spectating our player?
if(GetEntPropEnt(i, Prop_Send, "m_hObserverTarget") == client)
Format(szText, sizeof(szText), "%s%N\n", szText, i);
}
}
else
{
int iSpecModeUser = GetEntProp(client, Prop_Send, "m_iObserverMode");
if(iSpecModeUser == SPECMODE_FIRSTPERSON || iSpecModeUser == SPECMODE_3RDPERSON)
{
// Find out who the User is spectating.
int iTargetUser = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget");
for(int i = 1; i <= MaxClients; i++)
{
if(!IsClientInGame(i) || !IsClientObserver(i)) continue;
// The 'client' is not an admin and do not display admins is enabled and the client (i) is an admin, so ignore them.
if(!IsPlayerAdmin(client) && g_bNoAdmins && IsPlayerAdmin(i)) continue;
iSpecMode = GetEntProp(i, Prop_Send, "m_iObserverMode");
// The client isn't spectating any one person, so ignore them.
if(iSpecMode != SPECMODE_FIRSTPERSON && iSpecMode != SPECMODE_3RDPERSON) continue;
// Find out who the client is spectating.
// Are they spectating the same player as User?
if(GetEntPropEnt(i, Prop_Send, "m_hObserverTarget") == iTargetUser) Format(szText, sizeof(szText), "%s%N\n", szText, i);
}
}
}
if(szText[0])
{
iSpecMode = 0;
while(szText[iSpecMode]) iSpecMode++;
szText[iSpecMode-1] = 0;
}
// Send our message
Handle hBuffer = StartMessageOne("KeyHintText", client);
BfWriteByte(hBuffer, 1);
BfWriteString(hBuffer, szText);
EndMessage();
return Plugin_Continue;
}