rodrigo286 |
04-06-2012 18:57 |
Re: Only attacker call
Compiled 100%
But HP does not appear, I did something wrong?
PHP Code:
GetClientAimHullTarget(client,Float:resultPos[3]) {
//Hull trace calculation by berni all credits for this goes to him!
decl Float:pos[3];
GetClientAimTargetPos(client, pos);
decl Float:vEyePosition[3];
GetClientEyePosition(client, vEyePosition);
decl Float:m_vecMins[3], Float:m_vecMaxs[3];
//GetEntPropVector(entity, Prop_Send, "m_vecMins", m_vecMins);
//GetEntPropVector(entity, Prop_Send, "m_vecMaxs", m_vecMaxs);
m_vecMins[0] = m_vecMins[1] = m_vecMins[2] = 0.0;
m_vecMaxs[0] = m_vecMaxs[1] = 1.0;
m_vecMaxs[2] = 1.0;
new Handle:trace = TR_TraceHullFilterEx(vEyePosition, pos, m_vecMins, m_vecMaxs, TRACE_FILTER,TraceEntityFilter,client);
TR_GetEndPosition(resultPos, trace);
if(TR_DidHit(trace)){
new entity = TR_GetEntityIndex(trace);
CloseHandle(trace);
return entity;
}
CloseHandle(trace);
return -1;
}
public Event_hurt(Handle:event, const String:name[], bool:dontBroadcast)
{
if(GetConVarBool(g_cvar_enable))
{
new String:weapon[64];
new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
GetEventString(event, "weapon", weapon, sizeof(weapon));
if( StrEqual(weapon,"smokegrenade") )
{
return;
}
if( StrEqual(weapon,"hegrenade") )
{
return;
}
if( StrEqual(weapon,"flashbang") )
{
return;
}
CreateTimer(HUD_INTERVALL, Timer_DisplayHud, GetClientSerial(attacker), TIMER_FLAG_NO_MAPCHANGE);
}
}
public Action:Timer_DisplayHud(Handle:timer, any:serial) {
decl Float:pos[3];
for (new client=1; client<=MaxClients; ++client) {
if(!g_bClientShowDisplay[client]){
continue;
}
if (IsClientInGame(client) && IsPlayerAlive(client) && !IsFakeClient(client)) {
new aimTarget = GetClientAimHullTarget(client, pos);
ShowHPInfo(client, aimTarget);
}
}
return Plugin_Continue;
}
public ShowHPInfo(client, target) {
if(GetClientTeam(client) == CS_TEAM_CT) {
return;
}
if (!GetConVarBool(g_cvar_enable)) {
return;
}
if(g_bDontOverRideHealthDisplay[client]){
return;
}
new String:targetname[MAX_TARGET_LENGTH];
new bool:success = GetEntityName(target,targetname,sizeof(targetname));
if(success){
new String:health[MAX_HEALTH_LENGTH];
GetEntityHealthString(target, health);
new String:showstring[MAX_SHOWSTRING_LENGTH];
g_bClearedDisplay[client] = false;
Format(showstring,MAX_SHOWSTRING_LENGTH,"%s tem (%s) de vida restante.",targetname,health);
if(!StrEqual(showstring,g_szOldShowString[client],false) || ((GetGameTime() - g_iUpdateHintTimeout[client]) > 4.0)){
PrintHintText(client,showstring);
strcopy(g_szOldShowString[client],MAX_SHOWSTRING_LENGTH,showstring);
g_iUpdateHintTimeout[client] = GetGameTime();
}
}
else if(!g_bClearedDisplay[client]) {
g_bClearedDisplay[client] = true;
PrintHintText(client,HINTBOX_BLANK);
strcopy(g_szOldShowString[client],sizeof(g_szOldShowString[]),HINTBOX_BLANK);
}
}
Thanks.
|