I made this. And tested.
PHP Code:
#include <sdktools>
// settings for m_takedamage
#define DAMAGE_NO 0
#define DAMAGE_EVENTS_ONLY 1 // Call damage functions, but don't modify health
#define DAMAGE_YES 2
#define DAMAGE_AIM 3
public void OnPluginStart()
{
HookEventEx("player_connect", player_connect);
for(int i = 1; i <= MaxClients; i++)
{
if(IsClientInGame(i))
CreateTimer(0.8, player_timer, GetClientUserId(i), TIMER_REPEAT);
}
}
public void player_connect(Event event, const char[] name, bool dontBroadcast)
{
CreateTimer(0.8, player_timer, event.GetInt("userid", 0), TIMER_REPEAT);
}
public Action player_timer(Handle timer, any userid)
{
static bool hint[MAXPLAYERS+1];
if(userid == 0)
return Plugin_Stop;
int client = GetClientOfUserId(userid);
if(client == 0)
return Plugin_Stop;
if(!IsClientInGame(client) || IsFakeClient(client))
{
hint[client] = false;
return Plugin_Continue;
}
float eyepos[3], eyeangle[3], startpos[3], endpos[3];
GetClientEyePosition(client, eyepos);
GetClientEyeAngles(client, eyeangle);
GetAngleVectors(eyeangle, startpos, NULL_VECTOR, NULL_VECTOR);
ScaleVector(startpos, 10.0);
AddVectors(startpos, eyepos, startpos);
GetAngleVectors(eyeangle, endpos, NULL_VECTOR, NULL_VECTOR);
ScaleVector(endpos, 160.0);
AddVectors(endpos, eyepos, endpos);
TR_TraceHullFilter(startpos, endpos, {-4.0,-4.0,-4.0}, {4.0,4.0,4.0}, MASK_SHOT_HULL, TraceFilter, client);
int entity = TR_GetEntityIndex();
if(entity < MaxClients)
{
if(hint[client])
{
hint[client] = false;
PrintCenterText(client, " ");
}
return Plugin_Continue;
}
char clsname[MAX_NAME_LENGTH];
GetEntityClassname(entity, clsname, sizeof(clsname));
//PrintToServer("clsname %s %i %i", clsname, GetEntProp(entity, Prop_Data, "m_takedamage"), entity);
if(!HasEntProp(entity, Prop_Data, "m_takedamage")
|| GetEntProp(entity, Prop_Data, "m_takedamage") <= DAMAGE_NO
|| !HasEntProp(entity, Prop_Data, "m_iHealth")
|| GetEntProp(entity, Prop_Data, "m_iHealth") <= 0)
{
if(hint[client])
{
hint[client] = false;
PrintCenterText(client, " ");
}
return Plugin_Continue;
}
hint[client] = true;
PrintCenterText(client , "HEALTH\n %d" , GetEntProp(entity, Prop_Data, "m_iHealth"));
return Plugin_Continue;
}
public bool TraceFilter(int entity, int contentsMask, any data)
{
return (entity != data);
}